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

Deprecate CompilationWithAnalyzers.IsDiagnosticAnalyzerSuppressed public API #67592

Closed
mavasani opened this issue Mar 31, 2023 · 6 comments · Fixed by #67671
Closed

Deprecate CompilationWithAnalyzers.IsDiagnosticAnalyzerSuppressed public API #67592

mavasani opened this issue Mar 31, 2023 · 6 comments · Fixed by #67671
Assignees
Labels
api-approved API was approved in API review, it can be implemented Area-Analyzers Area-Compilers Bug Concept-API This issue involves adding, removing, clarification, or modification of an API. Performance-Scenario-Diagnostics This issue affects diagnostics computation performance for lightbulb, background analysis, tagger.

Comments

@mavasani
Copy link
Member

mavasani commented Mar 31, 2023

/// <summary>
/// Returns true if all the diagnostics that can be produced by this analyzer are suppressed through options.
/// </summary>
/// <param name="analyzer">Analyzer to be checked for suppression.</param>
/// <param name="options">Compilation options.</param>
/// <param name="onAnalyzerException">
/// Optional delegate which is invoked when an analyzer throws an exception.
/// Delegate can do custom tasks such as report the given analyzer exception diagnostic, report a non-fatal watson for the exception, etc.
/// </param>
public static bool IsDiagnosticAnalyzerSuppressed(
DiagnosticAnalyzer analyzer,
CompilationOptions options,
Action<Exception, DiagnosticAnalyzer, Diagnostic>? onAnalyzerException = null)
{

  • This static API on CompilationWithAnalyzers was introduced prior to the editorconfig support in the compiler layer and only accounts for severity configurations via rulesets and command line switches.
  • With it's current input parameters, i.e. just the analyzer and CompilationOptions, this API can no longer return the correct value when severities are configured in editorconfig/globalconfig files.
  • This API is no longer used anywhere in IDE code: https://sourceroslyn.io/#Microsoft.CodeAnalysis/DiagnosticAnalyzer/CompilationWithAnalyzers.cs,554e9af46aec830e,references
  • Supporting this method requires us to thread in null value for compilation in lot of internal driver code, which makes the code unnecessarily complex and unintuitive.
@mavasani mavasani added Bug Area-Analyzers Concept-API This issue involves adding, removing, clarification, or modification of an API. Area-Compilers api-ready-for-review API is ready for review, it is NOT ready for implementation labels Mar 31, 2023
@mavasani mavasani self-assigned this Mar 31, 2023
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label Mar 31, 2023
@CyrusNajmabadi
Copy link
Member

Yes. Let's def deprecate this :)

@mavasani mavasani removed the untriaged Issues and PRs which have not yet been triaged by a lead label Apr 6, 2023
mavasani added a commit to mavasani/roslyn that referenced this issue Apr 6, 2023
@mavasani
Copy link
Member Author

mavasani commented Apr 6, 2023

Draft PR: #67671

@333fred
Copy link
Member

333fred commented Apr 13, 2023

API Review

  • Could we pull the existing impl out so it doesn't have to be updated in the future?
    • This could be pretty complex, it calls into some gnarly code.
    • What's the timeline for deprecation?
  • Put it on the BannedAPI list for Roslyn users?

We'll move forward with obsoletion, and investigate how difficult freezing the current implementation will be. If it's easy, then we can remove at the next major version. If it's not, then we'll need to discuss when we want to break the functionality of the API.

@333fred 333fred added api-needs-work API needs work before it is approved, it is NOT ready for implementation and removed api-ready-for-review API is ready for review, it is NOT ready for implementation labels Apr 13, 2023
@mavasani
Copy link
Member Author

We'll move forward with obsoletion, and investigate how difficult freezing the current implementation will be. If it's easy, then we can remove at the next major version. If it's not, then we'll need to discuss when we want to break the functionality of the API.

Thanks! I was able to refactor the code in #67671 to freeze the current implementation and also restore the unit tests for this public API, while also cleaning up the code in AnalyzerExecutor and AnalyzerManager for rest of the code paths.

@mavasani mavasani added api-ready-for-review API is ready for review, it is NOT ready for implementation and removed api-needs-work API needs work before it is approved, it is NOT ready for implementation labels Apr 14, 2023
@333fred
Copy link
Member

333fred commented Apr 14, 2023

@mavasani let's send an email to API review and let them know we plan to move forward with the deprecation/removal in the next major version.

@mavasani
Copy link
Member Author

@mavasani let's send an email to API review and let them know we plan to move forward with the deprecation/removal in the next major version.

FYI: This proposal was accepted via offline email discussion.

@333fred 333fred added api-approved API was approved in API review, it can be implemented and removed api-ready-for-review API is ready for review, it is NOT ready for implementation labels Apr 27, 2023
@mavasani mavasani added the Performance-Scenario-Diagnostics This issue affects diagnostics computation performance for lightbulb, background analysis, tagger. label May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-approved API was approved in API review, it can be implemented Area-Analyzers Area-Compilers Bug Concept-API This issue involves adding, removing, clarification, or modification of an API. Performance-Scenario-Diagnostics This issue affects diagnostics computation performance for lightbulb, background analysis, tagger.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants