From 2b9bfa9ac99ea6488bfa4c2e8aa57fea50eeae65 Mon Sep 17 00:00:00 2001 From: Vita Chumakova Date: Mon, 17 Nov 2025 11:10:29 +0400 Subject: [PATCH] Fix CA1515 diagnostic when extension members are present --- .../Maintainability/MakeTypesInternal.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/MakeTypesInternal.cs b/src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/MakeTypesInternal.cs index e405bd81d63e..e8bd0d6f98d3 100644 --- a/src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/MakeTypesInternal.cs +++ b/src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/MakeTypesInternal.cs @@ -49,7 +49,7 @@ private void AnalyzeType(SymbolAnalysisContext context) { INamedTypeSymbol namedTypeSymbol = (INamedTypeSymbol)context.Symbol; if (namedTypeSymbol.IsPublic() - && GetIdentifier(namedTypeSymbol.DeclaringSyntaxReferences[0].GetSyntax()) is SyntaxToken identifier) + && GetIdentifier(namedTypeSymbol.DeclaringSyntaxReferences[0].GetSyntax()) is { SyntaxTree: not null } identifier) { context.ReportDiagnostic(identifier.CreateDiagnostic(Rule)); } @@ -59,4 +59,4 @@ private void AnalyzeType(SymbolAnalysisContext context) public override ImmutableArray SupportedDiagnostics { get; } = ImmutableArray.Create(Rule); } -} \ No newline at end of file +}