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

Remove diagnostic category flag #74352

Merged
merged 1 commit into from
Jul 11, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ private class ThrowingDoNotCatchDiagnosticAnalyzer<TLanguageKindEnum> : Throwing
public bool IsHighPriority => false;

public DiagnosticAnalyzerCategory GetAnalyzerCategory()
=> DiagnosticAnalyzerCategory.SyntaxTreeWithoutSemanticsAnalysis | DiagnosticAnalyzerCategory.SemanticDocumentAnalysis | DiagnosticAnalyzerCategory.ProjectAnalysis;
=> DiagnosticAnalyzerCategory.SyntaxTreeWithoutSemanticsAnalysis | DiagnosticAnalyzerCategory.SemanticDocumentAnalysis;
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ internal static partial class DiagnosticAnalyzerExtensions
public static DiagnosticAnalyzerCategory GetDiagnosticAnalyzerCategory(this DiagnosticAnalyzer analyzer)
=> analyzer switch
{
FileContentLoadAnalyzer _ => DiagnosticAnalyzerCategory.SyntaxTreeWithoutSemanticsAnalysis,
DocumentDiagnosticAnalyzer _ => DiagnosticAnalyzerCategory.SyntaxTreeWithoutSemanticsAnalysis | DiagnosticAnalyzerCategory.SemanticDocumentAnalysis,
ProjectDiagnosticAnalyzer _ => DiagnosticAnalyzerCategory.ProjectAnalysis,
FileContentLoadAnalyzer => DiagnosticAnalyzerCategory.SyntaxTreeWithoutSemanticsAnalysis,
DocumentDiagnosticAnalyzer => DiagnosticAnalyzerCategory.SyntaxTreeWithoutSemanticsAnalysis | DiagnosticAnalyzerCategory.SemanticDocumentAnalysis,
ProjectDiagnosticAnalyzer => DiagnosticAnalyzerCategory.None,
IBuiltInAnalyzer builtInAnalyzer => builtInAnalyzer.GetAnalyzerCategory(),

// Compiler analyzer supports syntax diagnostics, span-based semantic diagnostics and project level diagnostics.
// For a public analyzer it is not possible to know the diagnostic categorization, so return a worst-case categorization.
_ => analyzer.IsCompilerAnalyzer()
? DiagnosticAnalyzerCategory.SyntaxTreeWithoutSemanticsAnalysis | DiagnosticAnalyzerCategory.SemanticSpanAnalysis | DiagnosticAnalyzerCategory.ProjectAnalysis
: DiagnosticAnalyzerCategory.SyntaxTreeWithoutSemanticsAnalysis | DiagnosticAnalyzerCategory.SemanticDocumentAnalysis | DiagnosticAnalyzerCategory.ProjectAnalysis
? DiagnosticAnalyzerCategory.SyntaxTreeWithoutSemanticsAnalysis | DiagnosticAnalyzerCategory.SemanticSpanAnalysis
: DiagnosticAnalyzerCategory.SyntaxTreeWithoutSemanticsAnalysis | DiagnosticAnalyzerCategory.SemanticDocumentAnalysis,
};

public static bool SupportAnalysisKind(this DiagnosticAnalyzer analyzer, AnalysisKind kind)
Expand Down Expand Up @@ -48,10 +48,4 @@ public static bool SupportsSpanBasedSemanticDiagnosticAnalysis(this DiagnosticAn
var category = analyzer.GetDiagnosticAnalyzerCategory();
return (category & DiagnosticAnalyzerCategory.SemanticSpanAnalysis) != 0;
}

public static bool SupportsProjectDiagnosticAnalysis(this DiagnosticAnalyzer analyzer)
{
var category = analyzer.GetDiagnosticAnalyzerCategory();
return (category & DiagnosticAnalyzerCategory.ProjectAnalysis) != 0;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method was never called. so nothing ever actually checked if hte .ProjectAnalysis flag was set for an analyzer.

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,4 @@ internal enum DiagnosticAnalyzerCategory
/// It needs to re-analyze the whole document for reporting semantic diagnostics even for method body editing scenarios.
/// </summary>
SemanticDocumentAnalysis = 0x0100,

/// <summary>
/// Analyzer reports project diagnostics (i.e. registers a Compilation action and/or Compilation end action diagnostics).
/// </summary>
ProjectAnalysis = 0x1000
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.CodeAnalysis.Simplification;

namespace Microsoft.CodeAnalysis.Diagnostics;

/// <summary>
Expand Down
Loading