Skip to content

Commit 7f89d9c

Browse files
authored
Run code analysis on generated code to support Razor routes (#45496)
1 parent 74a2287 commit 7f89d9c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Framework/AspNetCoreAnalyzers/src/Analyzers/RouteEmbeddedLanguage/RoutePatternAnalyzer.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class RoutePatternAnalyzer : DiagnosticAnalyzer
2424
DiagnosticDescriptors.RoutePatternUnusedParameter
2525
});
2626

27-
public void Analyze(SemanticModelAnalysisContext context)
27+
private void AnalyzeSemanticModel(SemanticModelAnalysisContext context)
2828
{
2929
var semanticModel = context.SemanticModel;
3030
var syntaxTree = semanticModel.SyntaxTree;
@@ -165,9 +165,10 @@ private record struct InsertPoint(ISymbol ExistingParameter, bool Before);
165165

166166
public override void Initialize(AnalysisContext context)
167167
{
168-
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.ReportDiagnostics);
168+
// Run on generated code to include routes specified in Razor files.
169+
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics);
169170
context.EnableConcurrentExecution();
170171

171-
context.RegisterSemanticModelAction(Analyze);
172+
context.RegisterSemanticModelAction(AnalyzeSemanticModel);
172173
}
173174
}

0 commit comments

Comments
 (0)