Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect the newly added Background analysis scope option in OmniSharp #6058

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1252,11 +1252,6 @@
"default": false,
"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."
},
"omnisharp.enableRoslynAnalyzers": {
"type": "boolean",
"default": false,
"description": "Enables support for roslyn analyzers, code fixes and rulesets."
},
"omnisharp.enableEditorConfigSupport": {
"type": "boolean",
"default": true,
Expand All @@ -1283,11 +1278,6 @@
"default": false,
"description": "(EXPERIMENTAL) Enables support for resolving completion edits asynchronously. This can speed up time to show the completion list, particularly override and partial method completion lists, at the cost of slight delays after inserting a completion item. Most completion items will have no noticeable impact with this feature, but typing immediately after inserting an override or partial method completion, before the insert is completed, can have unpredictable results."
},
"omnisharp.analyzeOpenDocumentsOnly": {
"type": "boolean",
"default": false,
"description": "Only run analyzers against open files when 'enableRoslynAnalyzers' is true"
},
"omnisharp.testRunSettings": {
"type": "string",
"description": "Path to the .runsettings file which should be used when running unit tests."
Expand Down
13 changes: 12 additions & 1 deletion src/features/diagnosticsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,18 @@ class OmniSharpDiagnosticsProvider extends AbstractSupport {
) {
super(server, languageMiddlewareFeature);

this._analyzersEnabled = vscode.workspace.getConfiguration('omnisharp').get('enableRoslynAnalyzers', false);
const analyzersEnabledLegacyOption = vscode.workspace
.getConfiguration('omnisharp')
.get('enableRoslynAnalyzers', false);
const useOmnisharpServer = vscode.workspace.getConfiguration('dotnet').get('server.useOmnisharp', false);
const analyzersEnabledNewOption =
vscode.workspace
.getConfiguration('dotnet')
.get<string>(
'backgroundAnalysis.analyzerDiagnosticsScope',
useOmnisharpServer ? 'none' : 'openFiles'
) != 'none';
this._analyzersEnabled = analyzersEnabledLegacyOption || analyzersEnabledNewOption;
this._validationAdvisor = validationAdvisor;
this._diagnostics = vscode.languages.createDiagnosticCollection('csharp');
this._suppressHiddenDiagnostics = vscode.workspace
Expand Down
17 changes: 15 additions & 2 deletions src/shared/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,18 @@ export class Options {
'omnisharp.useEditorFormattingSettings',
true
);
const enableRoslynAnalyzers = Options.readOption<boolean>(config, 'omnisharp.enableRoslynAnalyzers', false);
const enableRoslynAnalyzersLegacyOption = Options.readOption<boolean>(
config,
'omnisharp.enableRoslynAnalyzers',
false
);
const diagnosticAnalysisScope = Options.readOption<string>(
config,
'dotnet.backgroundAnalysis.analyzerDiagnosticsScope',
useOmnisharpServer ? 'none' : 'openFiles'
);
const enableRoslynAnalyzersNewOption = diagnosticAnalysisScope != 'none';
const enableRoslynAnalyzers = enableRoslynAnalyzersLegacyOption || enableRoslynAnalyzersNewOption;
const enableEditorConfigSupport = Options.readOption<boolean>(
config,
'omnisharp.enableEditorConfigSupport',
Expand All @@ -138,11 +149,13 @@ export class Options {
'omnisharp.enableImportCompletion'
);
const enableAsyncCompletion = Options.readOption<boolean>(config, 'omnisharp.enableAsyncCompletion', false);
const analyzeOpenDocumentsOnly = Options.readOption<boolean>(
const analyzeOpenDocumentsOnlyLegacyOption = Options.readOption<boolean>(
config,
'omnisharp.analyzeOpenDocumentsOnly',
false
);
const analyzeOpenDocumentsOnlyNewOption = diagnosticAnalysisScope == 'openFiles';
const analyzeOpenDocumentsOnly = analyzeOpenDocumentsOnlyLegacyOption || analyzeOpenDocumentsOnlyNewOption;
const organizeImportsOnFormat = Options.readOption<boolean>(config, 'omnisharp.organizeImportsOnFormat', false);
const disableMSBuildDiagnosticWarning = Options.readOption<boolean>(
config,
Expand Down
4 changes: 2 additions & 2 deletions test/unitTests/options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ suite('Options tests', () => {
options.omnisharpOptions.minFindSymbolsFilterLength.should.equal(0);
options.omnisharpOptions.maxFindSymbolsItems.should.equal(1000);
options.omnisharpOptions.enableMsBuildLoadProjectsOnDemand.should.equal(false);
options.omnisharpOptions.enableRoslynAnalyzers.should.equal(false);
options.omnisharpOptions.enableRoslynAnalyzers.should.equal(true);
options.omnisharpOptions.enableEditorConfigSupport.should.equal(true);
options.omnisharpOptions.enableDecompilationSupport.should.equal(false);
options.omnisharpOptions.enableImportCompletion.should.equal(false);
options.omnisharpOptions.enableAsyncCompletion.should.equal(false);
options.omnisharpOptions.analyzeOpenDocumentsOnly.should.equal(false);
options.omnisharpOptions.analyzeOpenDocumentsOnly.should.equal(true);
mavasani marked this conversation as resolved.
Show resolved Hide resolved
options.omnisharpOptions.testRunSettings.should.equal('');
});

Expand Down