Skip to content

Commit c3337aa

Browse files
authored
Merge pull request #2836 from savpek/feature/enableroslynanalyzers-flag
enableRoslynAnalyzers flag.
2 parents 1279c53 + 2672b86 commit c3337aa

File tree

5 files changed

+15
-1
lines changed

5 files changed

+15
-1
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,11 @@
704704
"default": false,
705705
"description": "If true, MSBuild project system will only load projects for files that were opened in the editor. This setting is useful for big C# codebases and allows for faster initialization of code navigation features only for projects that are relevant to code that is being edited. With this setting enabled OmniSharp may load fewer projects and may thus display incomplete reference lists for symbols."
706706
},
707+
"omnisharp.enableRoslynAnalyzers": {
708+
"type": "boolean",
709+
"default": false,
710+
"description": "Enables support for roslyn analyzers, code fixes and rulesets."
711+
},
707712
"razor.plugin.path": {
708713
"type": [
709714
"string",

src/omnisharp/options.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ export class Options {
2525
public razorDisabled: boolean,
2626
public razorDevMode: boolean,
2727
public enableMsBuildLoadProjectsOnDemand: boolean,
28+
public enableRoslynAnalyzers: boolean,
2829
public razorPluginPath?: string,
2930
public defaultLaunchSolution?: string,
3031
public monoPath?: string,
3132
public maxProjectFileCountForDiagnosticAnalysis?: number | null) { }
3233

33-
3434
public static Read(vscode: vscode): Options {
3535
// Extra effort is taken below to ensure that legacy versions of options
3636
// are supported below. In particular, these are:
@@ -62,6 +62,8 @@ export class Options {
6262
const defaultLaunchSolution = omnisharpConfig.get<string>('defaultLaunchSolution', undefined);
6363
const useEditorFormattingSettings = omnisharpConfig.get<boolean>('useEditorFormattingSettings', true);
6464

65+
const enableRoslynAnalyzers = omnisharpConfig.get<boolean>('enableRoslynAnalyzers', false);
66+
6567
const useFormatting = csharpConfig.get<boolean>('format.enable', true);
6668

6769
const showReferencesCodeLens = csharpConfig.get<boolean>('referencesCodeLens.enabled', true);
@@ -101,6 +103,7 @@ export class Options {
101103
razorDisabled,
102104
razorDevMode,
103105
enableMsBuildLoadProjectsOnDemand,
106+
enableRoslynAnalyzers,
104107
razorPluginPath,
105108
defaultLaunchSolution,
106109
monoPath,

src/omnisharp/server.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,10 @@ export class OmniSharpServer {
327327
args.push('MsBuild:LoadProjectsOnDemand=true');
328328
}
329329

330+
if (options.enableRoslynAnalyzers === true) {
331+
args.push('RoslynExtensionsOptions:EnableAnalyzersSupport=true');
332+
}
333+
330334
let launchInfo: LaunchInfo;
331335
try {
332336
launchInfo = await this._omnisharpManager.GetOmniSharpLaunchInfo(this.packageJSON.defaults.omniSharp, options.path, serverUrl, latestVersionFileServerPath, installPath, this.extensionPath);

test/unitTests/optionStream.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ suite('OptionStream', () => {
5151
options.minFindSymbolsFilterLength.should.equal(0);
5252
options.maxFindSymbolsItems.should.equal(1000);
5353
options.enableMsBuildLoadProjectsOnDemand.should.equal(false);
54+
options.enableRoslynAnalyzers.should.equal(false);
5455
expect(options.defaultLaunchSolution).to.be.undefined;
5556
});
5657

test/unitTests/options.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ suite("Options tests", () => {
3131
options.minFindSymbolsFilterLength.should.equal(0);
3232
options.maxFindSymbolsItems.should.equal(1000);
3333
options.enableMsBuildLoadProjectsOnDemand.should.equal(false);
34+
options.enableRoslynAnalyzers.should.equal(false);
3435
expect(options.defaultLaunchSolution).to.be.undefined;
3536
});
3637

0 commit comments

Comments
 (0)