Пример #1
0
        public override void Initialize(AnalysisContext analysisContext)
        {
            analysisContext.RegisterCompilationStartAction(
                (context) =>
            {
                var eventHandler = WellKnownTypes.EventHandler(context.Compilation);
                if (eventHandler == null)
                {
                    return;
                }

                var genericEventHandler = WellKnownTypes.GenericEventHandler(context.Compilation);
                if (genericEventHandler == null)
                {
                    return;
                }

                var eventArgs = WellKnownTypes.EventArgs(context.Compilation);
                if (eventArgs == null)
                {
                    return;
                }

                var comSourceInterfacesAttribute = WellKnownTypes.ComSourceInterfaceAttribute(context.Compilation);
                if (comSourceInterfacesAttribute == null)
                {
                    return;
                }

                context.RegisterSymbolAction(GetAnalyzer(context.Compilation, eventHandler, genericEventHandler, eventArgs, comSourceInterfacesAttribute).AnalyzeSymbol, SymbolKind.Event);
            });
        }
Пример #2
0
        public override void Initialize(AnalysisContext analysisContext)
        {
            analysisContext.EnableConcurrentExecution();
            analysisContext.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);

            analysisContext.RegisterCompilationStartAction(
                (context) =>
            {
                INamedTypeSymbol eventHandler = WellKnownTypes.EventHandler(context.Compilation);
                if (eventHandler == null)
                {
                    return;
                }

                INamedTypeSymbol genericEventHandler = WellKnownTypes.GenericEventHandler(context.Compilation);
                if (genericEventHandler == null)
                {
                    return;
                }

                INamedTypeSymbol eventArgs = WellKnownTypes.EventArgs(context.Compilation);
                if (eventArgs == null)
                {
                    return;
                }

                INamedTypeSymbol comSourceInterfacesAttribute = WellKnownTypes.ComSourceInterfaceAttribute(context.Compilation);
                if (comSourceInterfacesAttribute == null)
                {
                    return;
                }

                context.RegisterSymbolAction(GetAnalyzer(context.Compilation, eventHandler, genericEventHandler, eventArgs, comSourceInterfacesAttribute).AnalyzeSymbol, SymbolKind.Event);
            });
        }
Пример #3
0
        public ICompilationEndedAnalyzer OnCompilationStarted(Compilation compilation, Action <Diagnostic> addDiagnostic, CancellationToken cancellationToken)
        {
            var eventHandler = WellKnownTypes.EventHandler(compilation);

            if (eventHandler == null)
            {
                return(null);
            }

            var genericEventHandler = WellKnownTypes.GenericEventHandler(compilation);

            if (genericEventHandler == null)
            {
                return(null);
            }

            var eventArgs = WellKnownTypes.EventArgs(compilation);

            if (eventArgs == null)
            {
                return(null);
            }

            var comSourceInterfacesAttribute = WellKnownTypes.ComSourceInterfaceAttribute(compilation);

            if (comSourceInterfacesAttribute == null)
            {
                return(null);
            }

            return(GetAnalyzer(compilation, eventHandler, genericEventHandler, eventArgs, comSourceInterfacesAttribute));
        }