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

LSP pull diagnostic handlers should handle None/Disabled option value for compiler and analyzer background analysis options #68798

Closed
mavasani opened this issue Jun 27, 2023 · 1 comment
Assignees
Labels
Area-IDE Bug LSP issues related to the roslyn language server protocol implementation Performance-Scenario-Diagnostics This issue affects diagnostics computation performance for lightbulb, background analysis, tagger. untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@mavasani
Copy link
Contributor

Currently, neither of these handlers consider the below background analysis scope options for disabling compiler and/or analyzer diagnostics:

/// <summary>
/// Option to turn configure background analysis scope for the current user.
/// </summary>
public static readonly PerLanguageOption2<BackgroundAnalysisScope> BackgroundAnalysisScopeOption = new(
"dotnet_solution_crawler_background_analysis_scope", defaultValue: BackgroundAnalysisScope.Default, serializer: EditorConfigValueSerializer.CreateSerializerForEnum<BackgroundAnalysisScope>());

As this is not just a functionality issue, but also affects performance (unnecessarily running analyzers that users don't wish to see diagnostics for), we should prioritize fixing it.

@mavasani mavasani added Bug Area-IDE LSP issues related to the roslyn language server protocol implementation Performance-Scenario-Diagnostics This issue affects diagnostics computation performance for lightbulb, background analysis, tagger. labels Jun 27, 2023
@mavasani mavasani self-assigned this Jun 27, 2023
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label Jun 27, 2023
mavasani added a commit to mavasani/roslyn that referenced this issue Jun 27, 2023
…P/VSCode

Work towards dotnet#68553.
This needs a corresponding change in dotnet/vscode-csharp repo. I verified that this change + the corresponding vscode-csharp change enables FSA support in C# DevKit extension in VSCode.

Needs couple more Roslyn side fixes as a follow-up: dotnet#68797 and dotnet#68798
mavasani added a commit to mavasani/vscode-csharp that referenced this issue Jun 27, 2023
- Adds 2 new background analysis scope options: one for compiler diagnostics and one for analyzer diagnostics
- Both the options allow the same set of values as in VS: Open documents, Entire solution, Current document and None (disabled). Currently, `Current document` option is not yet supported in LSP as we do not have a way to know which is the current active document in LSP server.
- Builds on top of dotnet/roslyn#68799
- Needs couple more Roslyn side changes as a follow-up: dotnet/roslyn#68797 and dotnet/roslyn#68798
@mavasani
Copy link
Contributor Author

mavasani commented Jun 27, 2023

Turns out this already works as expected due to the pre-filtering of analyzers done below:

var stateSets = owner._stateManager
.GetOrCreateStateSets(document.Project).Where(s => DocumentAnalysisExecutor.IsAnalyzerEnabledForProject(s.Analyzer, document.Project, owner.GlobalOptions));

which ends up checking the appropriate background analysis scope option below:

public static bool IsAnalyzerEnabledForProject(DiagnosticAnalyzer analyzer, Project project, IGlobalOptionService globalOptions)
{
var options = project.CompilationOptions;
if (options == null || analyzer == FileContentLoadAnalyzer.Instance || analyzer == GeneratorDiagnosticsPlaceholderAnalyzer.Instance)
{
return true;
}
if (analyzer.IsCompilerAnalyzer())
{
return globalOptions.GetBackgroundCompilerAnalysisScope(project.Language) != CompilerDiagnosticsScope.None;
}
// Check if user has disabled analyzer execution for this project or via options.
if (!project.State.RunAnalyzers || globalOptions.GetBackgroundAnalysisScope(project.Language) == BackgroundAnalysisScope.None)
{
return false;
}

arunchndr added a commit to dotnet/vscode-csharp that referenced this issue Jul 10, 2023
* Increase release CI timeout

* Add CI for release branch

* Add eslint and fix warnings

* Implement report issue command for prerelease extension

* Update O# Roslyn and prepare for release

* Switch to non-deprecated action for asset upload

* Upload all VSIX in one step

* Update .github/workflows/release-ci.yml

Co-authored-by: Joey Robichaud <[email protected]>

* Update release-ci.yml

* review feedback

* use vscode-uri

* Add write permissions to job

* Fix options schema

* Explicitly throw if runtimeId is missing

* Use real looking runtimeId in fake

* Use issue reporter command

* Add server path as an option to allow Razor to re-use the runtime resolver

* Fix brace

* More lint

* Update README.md to notify user about .NET Runtime Tool

* Enable full solution background analysis

- Adds 2 new background analysis scope options: one for compiler diagnostics and one for analyzer diagnostics
- Both the options allow the same set of values as in VS: Open documents, Entire solution, Current document and None (disabled). Currently, `Current document` option is not yet supported in LSP as we do not have a way to know which is the current active document in LSP server.
- Builds on top of dotnet/roslyn#68799
- Needs couple more Roslyn side changes as a follow-up: dotnet/roslyn#68797 and dotnet/roslyn#68798

* Remove the un-supported `Current Document` option

* File renames

* Remove TSLint and configure eslint

* Enable remaining rules from tslint and remove

* Run prettier automatic fixer

* address a couple remaining eslint errors

* Remove incorrectly cased folders

* Remove duplicate license header

* Fix options schema after package.json changes

* Fix chai test assertion library usages

* Avoid using 'solution crawler' terminology in the VSCode option name

* Address feedback and fix test

* Revert unintentional changes from merge

* Some more reverts

* Address feedback and also fix linting issues

* Revert "Merged PR 475885: Add support for F5 for csproj and sln" (#5875)

This reverts commit 173be18.

* Update README.md to make runtime extension note numbered

* Bump Razor to 7.0.0-preview.23328.2

* Allow updatePackageDependencies to work with Razor (well, with prerelease packages)

* Add task for updating Razor deps

* Move to newer version of Roslyn LSP server

* Remove unsupported feature

* Update regexes

* small edits to readme

* deleted extra space in readme

* Try a less recent Razor version

* Update roslyn

---------

Co-authored-by: David Barbet <[email protected]>
Co-authored-by: David Barbet <[email protected]>
Co-authored-by: Joey Robichaud <[email protected]>
Co-authored-by: Joey Robichaud <[email protected]>
Co-authored-by: leslierichardson95 <[email protected]>
Co-authored-by: Manish Vasani <[email protected]>
Co-authored-by: Andrew Wang <[email protected]>
Co-authored-by: David Wengier <[email protected]>
Co-authored-by: Andrew Hall (METAL) <[email protected]>
Co-authored-by: Mika Dumont <[email protected]>
Co-authored-by: Mika Dumont <[email protected]>
Co-authored-by: David Wengier <[email protected]>
arunchndr added a commit to dotnet/vscode-csharp that referenced this issue Jul 18, 2023
* Increase release CI timeout

* Add CI for release branch

* Add eslint and fix warnings

* Implement report issue command for prerelease extension

* Update O# Roslyn and prepare for release

* Switch to non-deprecated action for asset upload

* Upload all VSIX in one step

* Update .github/workflows/release-ci.yml

Co-authored-by: Joey Robichaud <[email protected]>

* Update release-ci.yml

* review feedback

* use vscode-uri

* Add write permissions to job

* Fix options schema

* Explicitly throw if runtimeId is missing

* Use real looking runtimeId in fake

* Use issue reporter command

* Add server path as an option to allow Razor to re-use the runtime resolver

* Fix brace

* More lint

* Update README.md to notify user about .NET Runtime Tool

* Enable full solution background analysis

- Adds 2 new background analysis scope options: one for compiler diagnostics and one for analyzer diagnostics
- Both the options allow the same set of values as in VS: Open documents, Entire solution, Current document and None (disabled). Currently, `Current document` option is not yet supported in LSP as we do not have a way to know which is the current active document in LSP server.
- Builds on top of dotnet/roslyn#68799
- Needs couple more Roslyn side changes as a follow-up: dotnet/roslyn#68797 and dotnet/roslyn#68798

* Remove the un-supported `Current Document` option

* File renames

* Remove TSLint and configure eslint

* Enable remaining rules from tslint and remove

* Run prettier automatic fixer

* address a couple remaining eslint errors

* Remove incorrectly cased folders

* Remove duplicate license header

* Fix options schema after package.json changes

* Fix chai test assertion library usages

* Avoid using 'solution crawler' terminology in the VSCode option name

* Address feedback and fix test

* Revert unintentional changes from merge

* Some more reverts

* Address feedback and also fix linting issues

* Revert "Merged PR 475885: Add support for F5 for csproj and sln" (#5875)

This reverts commit 173be18.

* Update README.md to make runtime extension note numbered

* Bump Razor to 7.0.0-preview.23328.2

* Allow updatePackageDependencies to work with Razor (well, with prerelease packages)

* Add task for updating Razor deps

* Move to newer version of Roslyn LSP server

* Remove unsupported feature

* Update regexes

* small edits to readme

* deleted extra space in readme

* Try a less recent Razor version

* Update roslyn

* Remove pwa- prefix from BlazorDebug (#5908)

This PR removes pwa- from msedge and chrome as this was an older debug
type that is now depricated.

See microsoft/vscode-js-debug#1305

* Add determineBrowserType to CSharpExtensionExports (#5911)

This PR exports the
BlazorDebugConfigurationProvider.determineBrowserType method that it
could be used in vscode-dotnettools to help determine the browser the
user wants to use.

* Bump semver from 5.6.0 to 5.7.2

Bumps [semver](https://github.com/npm/node-semver) from 5.6.0 to 5.7.2.
- [Release notes](https://github.com/npm/node-semver/releases)
- [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md)
- [Commits](npm/node-semver@v5.6.0...v5.7.2)

---
updated-dependencies:
- dependency-name: semver
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

* Update debugger packages to 2.0.2 (#5914)

Co-authored-by: Isadora Rodopoulos <[email protected]>

* Fix static variables used in determineBrowserType (#5919)

This PR fixes the 'this' to be 'BlazorDebugConfigurationProvider' for
the new static variables from #5911

* Add call to setupTelemetryEnvironmentAsync (#5922)

* Add call to setupTelemetryEnvironmentAsync

* Make optional

* Update Roslyn server (#5925)

* Update Roslyn server

* Update package.json

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: David Barbet <[email protected]>
Co-authored-by: David Barbet <[email protected]>
Co-authored-by: Joey Robichaud <[email protected]>
Co-authored-by: Joey Robichaud <[email protected]>
Co-authored-by: leslierichardson95 <[email protected]>
Co-authored-by: Manish Vasani <[email protected]>
Co-authored-by: Andrew Wang <[email protected]>
Co-authored-by: David Wengier <[email protected]>
Co-authored-by: Andrew Hall (METAL) <[email protected]>
Co-authored-by: Mika Dumont <[email protected]>
Co-authored-by: Mika Dumont <[email protected]>
Co-authored-by: David Wengier <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Isadora <[email protected]>
Co-authored-by: Isadora Rodopoulos <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Bug LSP issues related to the roslyn language server protocol implementation Performance-Scenario-Diagnostics This issue affects diagnostics computation performance for lightbulb, background analysis, tagger. untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

1 participant