33using System . Collections . Generic ;
44using System . Collections . Immutable ;
55using System . Linq ;
6+ using Analyzer . Utilities . Extensions ;
67using Microsoft . CodeAnalysis ;
78using Microsoft . CodeAnalysis . CSharp ;
89using Microsoft . CodeAnalysis . CSharp . Syntax ;
@@ -2607,7 +2608,7 @@ private bool CheckMethods(InvocationExpressionSyntax invocationExpression, Compi
26072608 ReportDiagnostic ( context , IncorrectAnalysisReturnTypeRule , analysisMethodSyntax . Identifier . GetLocation ( ) , analysisMethodSyntax . Identifier . ValueText ) ;
26082609 return false ;
26092610 }
2610- else if ( analysisMethod . Parameters . Length != 1 || ! Equals ( analysisMethod . Parameters . First ( ) . Type , context . Compilation . GetTypeByMetadataName ( "Microsoft.CodeAnalysis.Diagnostics.SyntaxNodeAnalysisContext" ) ) )
2611+ else if ( analysisMethod . Parameters . Length != 1 || ! Equals ( analysisMethod . Parameters . First ( ) . Type , context . Compilation . GetOrCreateTypeByMetadataName ( "Microsoft.CodeAnalysis.Diagnostics.SyntaxNodeAnalysisContext" ) ) )
26112612 {
26122613 ReportDiagnostic ( context , IncorrectAnalysisParameterRule , analysisMethodSyntax . ParameterList . GetLocation ( ) , analysisMethodSyntax . Identifier . ValueText ) ;
26132614 return false ;
@@ -2766,7 +2767,7 @@ private CheckInitializeInfo CheckInitialize(CompilationAnalysisContext context)
27662767 private BlockSyntax InitializeOverview ( CompilationAnalysisContext context )
27672768 {
27682769 ImmutableArray < IParameterSymbol > parameters = _initializeSymbol . Parameters ;
2769- if ( parameters . Length != 1 || ! Equals ( parameters [ 0 ] . Type , context . Compilation . GetTypeByMetadataName ( "Microsoft.CodeAnalysis.Diagnostics.AnalysisContext" ) )
2770+ if ( parameters . Length != 1 || ! Equals ( parameters [ 0 ] . Type , context . Compilation . GetOrCreateTypeByMetadataName ( "Microsoft.CodeAnalysis.Diagnostics.AnalysisContext" ) )
27702771 || _initializeSymbol . DeclaredAccessibility != Accessibility . Public || ! _initializeSymbol . IsOverride || ! _initializeSymbol . ReturnsVoid )
27712772 {
27722773 ReportDiagnostic ( context , IncorrectInitSigRule , _initializeSymbol . Locations [ 0 ] , _initializeSymbol . Name ) ;
@@ -2866,9 +2867,9 @@ internal protected void AddMethod(SymbolAnalysisContext context)
28662867 return ;
28672868 }
28682869
2869- if ( ! Equals ( sym . ContainingType . BaseType , context . Compilation . GetTypeByMetadataName ( "Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer" ) ) )
2870+ if ( ! Equals ( sym . ContainingType . BaseType , context . Compilation . GetOrCreateTypeByMetadataName ( "Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer" ) ) )
28702871 {
2871- if ( ! Equals ( sym . ContainingType . BaseType , context . Compilation . GetTypeByMetadataName ( "Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider" ) ) )
2872+ if ( ! Equals ( sym . ContainingType . BaseType , context . Compilation . GetOrCreateTypeByMetadataName ( "Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider" ) ) )
28722873 {
28732874 return ;
28742875 }
@@ -2918,9 +2919,9 @@ internal protected void AddProperty(SymbolAnalysisContext context)
29182919 return ;
29192920 }
29202921
2921- if ( ! Equals ( sym . ContainingType . BaseType , context . Compilation . GetTypeByMetadataName ( "Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer" ) ) )
2922+ if ( ! Equals ( sym . ContainingType . BaseType , context . Compilation . GetOrCreateTypeByMetadataName ( "Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer" ) ) )
29222923 {
2923- if ( ! Equals ( sym . ContainingType . BaseType , context . Compilation . GetTypeByMetadataName ( "Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider" ) ) )
2924+ if ( ! Equals ( sym . ContainingType . BaseType , context . Compilation . GetOrCreateTypeByMetadataName ( "Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider" ) ) )
29242925 {
29252926 return ;
29262927 }
@@ -2967,7 +2968,7 @@ internal protected void AddField(SymbolAnalysisContext context)
29672968 return ;
29682969 }
29692970
2970- if ( ! Equals ( sym . ContainingType . BaseType , context . Compilation . GetTypeByMetadataName ( "Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer" ) ) )
2971+ if ( ! Equals ( sym . ContainingType . BaseType , context . Compilation . GetOrCreateTypeByMetadataName ( "Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer" ) ) )
29712972 {
29722973 return ;
29732974 }
@@ -2995,7 +2996,7 @@ internal protected void AddClass(SymbolAnalysisContext context)
29952996 return ;
29962997 }
29972998
2998- if ( ! Equals ( sym . BaseType , context . Compilation . GetTypeByMetadataName ( "Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer" ) ) )
2999+ if ( ! Equals ( sym . BaseType , context . Compilation . GetOrCreateTypeByMetadataName ( "Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer" ) ) )
29993000 {
30003001 if ( sym . ContainingType == null )
30013002 {
@@ -3007,7 +3008,7 @@ internal protected void AddClass(SymbolAnalysisContext context)
30073008 return ;
30083009 }
30093010
3010- if ( Equals ( sym . ContainingType . BaseType , context . Compilation . GetTypeByMetadataName ( "Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer" ) ) )
3011+ if ( Equals ( sym . ContainingType . BaseType , context . Compilation . GetOrCreateTypeByMetadataName ( "Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer" ) ) )
30113012 {
30123013 if ( _otherAnalyzerClassSymbols . Contains ( sym ) )
30133014 {
@@ -3021,7 +3022,7 @@ internal protected void AddClass(SymbolAnalysisContext context)
30213022 }
30223023 }
30233024
3024- if ( Equals ( sym . BaseType , context . Compilation . GetTypeByMetadataName ( "Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer" ) ) )
3025+ if ( Equals ( sym . BaseType , context . Compilation . GetOrCreateTypeByMetadataName ( "Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer" ) ) )
30253026 {
30263027 _analyzerClassSymbol = sym ;
30273028 }
0 commit comments