public override void Initialize(AnalysisContext analysisContext)
        {
            analysisContext.EnableConcurrentExecution();
            analysisContext.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);

            analysisContext.RegisterCompilationStartAction(compilationStartAnalysisContext =>
            {
                var namespaceRuleAnalyzer = new NamespaceRuleAnalyzer();
                compilationStartAnalysisContext.RegisterSymbolAction(
                    symbolAnalysisContext => namespaceRuleAnalyzer.Analyze(symbolAnalysisContext),
                    SymbolKind.NamedType);

                compilationStartAnalysisContext.RegisterSymbolAction(AnalyzeTypeRule, SymbolKind.NamedType);
                compilationStartAnalysisContext.RegisterSymbolAction(AnalyzeMemberRule, SymbolKind.Event, SymbolKind.Method, SymbolKind.Property);
                compilationStartAnalysisContext.RegisterSymbolAction(AnalyzeMemberParameterRule, SymbolKind.Method);
            });
        }
Esempio n. 2
0
        public override void Initialize(AnalysisContext analysisContext)
        {
            analysisContext.EnableConcurrentExecution();
            analysisContext.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);

            analysisContext.RegisterCompilationStartAction(compilationStartAnalysisContext =>
            {
                var analyzedSymbolKinds = compilationStartAnalysisContext.Options.GetAnalyzedSymbolKindsOption(MemberParameterRule,
                                                                                                               s_defaultAnalyzedSymbolKinds, compilationStartAnalysisContext.CancellationToken);

                if (analyzedSymbolKinds.Contains(SymbolKind.Namespace))
                {
                    var namespaceRuleAnalyzer = new NamespaceRuleAnalyzer();

                    compilationStartAnalysisContext.RegisterSymbolAction(
                        symbolAnalysisContext => namespaceRuleAnalyzer.Analyze(symbolAnalysisContext),
                        SymbolKind.NamedType);
                }

                if (analyzedSymbolKinds.Contains(SymbolKind.NamedType))
                {
                    compilationStartAnalysisContext.RegisterSymbolAction(AnalyzeTypeRule, SymbolKind.NamedType);
                }

                if (analyzedSymbolKinds.Contains(SymbolKind.Event))
                {
                    compilationStartAnalysisContext.RegisterSymbolAction(AnalyzeMemberRule, SymbolKind.Event);
                }

                if (analyzedSymbolKinds.Contains(SymbolKind.Method))
                {
                    compilationStartAnalysisContext.RegisterSymbolAction(AnalyzeMemberRule, SymbolKind.Method);
                }

                if (analyzedSymbolKinds.Contains(SymbolKind.Property))
                {
                    compilationStartAnalysisContext.RegisterSymbolAction(AnalyzeMemberRule, SymbolKind.Property);
                }

                if (analyzedSymbolKinds.Contains(SymbolKind.Parameter))
                {
                    compilationStartAnalysisContext.RegisterSymbolAction(AnalyzeMemberParameterRule, SymbolKind.Method);
                }
            });
        }
        public override void Initialize(AnalysisContext analysisContext)
        {
            analysisContext.EnableConcurrentExecution();
            analysisContext.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);

            analysisContext.RegisterCompilationStartAction(compilationStartAnalysisContext =>
            {
                var namespaceRuleAnalyzer = new NamespaceRuleAnalyzer();

                compilationStartAnalysisContext.RegisterSymbolAction(
                    symbolAnalysisContext => namespaceRuleAnalyzer.Analyze(symbolAnalysisContext),
                    SymbolKind.NamedType);

                compilationStartAnalysisContext.RegisterSymbolAction(AnalyzeTypeRule, SymbolKind.NamedType);

                compilationStartAnalysisContext.RegisterSymbolAction(AnalyzeMemberRule,
                    SymbolKind.Event, SymbolKind.Method, SymbolKind.Property);

                compilationStartAnalysisContext.RegisterSymbolAction(AnalyzeMemberParameterRule, SymbolKind.Method);
            });
        }