我正在尝试利用与 Visual Studio Code 的集成,但无法弄清楚如何设置 C# 格式选项。 Mac 上 OmniSharp exe 旁边的 config.json
(/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/jrieken.vscode-omnisharp/bin/packages/OmniSharp/config.json
) 与 the standard OmniSharp config.json
format 不匹配,因此设置大括号 + 换行符行为属性不起作用,例如methodBraceStyle
。不过,设置 tabSize
等确实有效。
最佳答案
刚刚使用最新的omnisharp(开发分支)和与我的项目的.sln
位于同一文件夹中的omnisharp.json
(粘贴在下面)使其正常工作。
它应该适用于所有 releases从 v1.9-beta18 开始,我只是从源代码编译,因为我不使用受支持的系统。
{
"FormattingOptions": {
"newLine": "\n",
"useTabs": false,
"tabSize": 4,
"indentationSize": 4,
"NewLinesForBracesInTypes": false,
"NewLinesForBracesInMethods": false,
"NewLinesForBracesInProperties": false,
"NewLinesForBracesInAccessors": false,
"NewLinesForBracesInAnonymousMethods": false,
"NewLinesForBracesInControlBlocks": false,
"NewLinesForBracesInAnonymousTypes": false,
"NewLinesForBracesInObjectCollectionArrayInitializers": false,
"NewLinesForBracesInLambdaExpressionBody": false,
"NewLineForElse": false,
"NewLineForCatch": false,
"NewLineForFinally": false,
"NewLineForMembersInObjectInit": false,
"NewLineForMembersInAnonymousTypes": false,
"NewLineForClausesInQuery": false,
}
}
可用属性列在 FormattingOptions.cs
中在 omnisharp-roslyn
repository .
关于visual-studio-code - 在 Visual Studio Code 上设置 OmniSharp 的 C# 格式选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34407922/