我试图利用与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)没有匹配标准的OmniSharp config.json格式,因此设置大括号+换行符属性不起作用,例如methodBraceStyle.它确实可以设置tabSize等.
只需使用最新的omnisharp(dev分支)和omnisharp.json
(粘贴在下面)与我的项目相同的文件夹即可使用.sln
.它应该适用于自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, } }
可用选项列在此文件中:https://github.com/bstockus/omnisharp-roslyn/blob/dev/src/OmniSharp.Abstractions/Options/FormattingOptions.cs