public override void Initialize(AnalysisContext context) { context.EnableConcurrentExecution(); context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics); context.RegisterCompilationStartAction(compilationStartAnalysisContext => { var syntaxCollector = new SyntaxCollector(); compilationStartAnalysisContext.RegisterSyntaxNodeAction(analysisContext => { syntaxCollector.OnVisitSyntaxNode(analysisContext.Node); }, SyntaxKind.Attribute, SyntaxKind.InvocationExpression); compilationStartAnalysisContext.RegisterCompilationEndAction(compilationContext => { Execute(new GeneratorContext(compilationContext, syntaxCollector)); }); }); }
public GeneratorContext(GeneratorExecutionContext generatorExecutionContext) { _syntaxCollector = (SyntaxCollector)generatorExecutionContext.SyntaxReceiver !; _compilationAnalysisContext = null; _generatorExecutionContext = generatorExecutionContext; }
public GeneratorContext(CompilationAnalysisContext compilationAnalysisContext, SyntaxCollector syntaxCollector) { _compilationAnalysisContext = compilationAnalysisContext; _syntaxCollector = syntaxCollector; _generatorExecutionContext = null; }