在Visual Studio代码上为OmniSharp设置C#格式选项?
问题描述:
我试图利用与Visual Studio代码的集成,但无法弄清楚如何设置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等。在Visual Studio代码上为OmniSharp设置C#格式选项?
答
刚刚得到这个工作使用最新的omnisharp(dev分支)和omnisharp.json
(粘贴在下面)在我的项目的.sln
相同的文件夹中。 自从v1.9-beta18开始,它应该可以与所有releases一起工作,我只是从源代码编译,因为我不使用受支持的系统。
{
"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,
}
}
你有没有解决这个问题,我已经花了半天只是试图让我的C#括号正确设置 – Jaybeecave
不,我从来没有。 – csells