Exemplo n.º 1
0
        public override void Initialize(AnalysisContext context)
        {
            context.EnableConcurrentExecution();
            context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);

            context.RegisterCompilationStartAction(ctx =>
            {
                var massTransitCtx = new MassTransitContext(ctx.Compilation);

                if (ContextDefined(massTransitCtx))
                {
                    AnalyzeCompilation(ctx, massTransitCtx);
                }
            });
        }
Exemplo n.º 2
0
 protected virtual bool ContextDefined(MassTransitContext massTransitCtx) => massTransitCtx.Version != null;
Exemplo n.º 3
0
 protected abstract void AnalyzeCompilation(CompilationStartAnalysisContext ctx, MassTransitContext massTransitCtx);
Exemplo n.º 4
0
        protected override void AnalyzeCompilation(CompilationStartAnalysisContext ctx, MassTransitContext massTransitCtx)
        {
            ctx.RegisterSyntaxNodeAction(context =>
            {
                var none   = (InvocationExpressionSyntax)context.Node;
                var symbol = context.SemanticModel.GetSymbolInfo(none);

                if (symbol.Symbol?.Kind != SymbolKind.Method)
                {
                    return;
                }

                var methodSymbol = (IMethodSymbol)symbol.Symbol;

                if (onMethods.Contains($"{methodSymbol.ContainingNamespace}.{methodSymbol.ContainingType.Name}.{methodSymbol.Name}"))
                {
                    Analyze(context, none, methodSymbol);
                }
            }, SyntaxKind.InvocationExpression);
        }