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

            analysisContext.RegisterCompilationStartAction(compilationContext =>
            {
                if (!compilationContext.Compilation.TryGetOrCreateTypeByMetadataName(WellKnownTypeNames.SystemIDisposable, out var disposableType))
                {
                    return;
                }

                DisposableFieldAnalyzer analyzer = GetAnalyzer(disposableType);
                compilationContext.RegisterSymbolAction(analyzer.AnalyzeSymbol, SymbolKind.NamedType);
            });
        }
Example #2
0
        public override void Initialize(AnalysisContext analysisContext)
        {
            analysisContext.EnableConcurrentExecution();
            analysisContext.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);

            analysisContext.RegisterCompilationStartAction(compilationContext =>
            {
                INamedTypeSymbol disposableType = WellKnownTypes.IDisposable(compilationContext.Compilation);
                if (disposableType == null)
                {
                    return;
                }

                DisposableFieldAnalyzer analyzer = GetAnalyzer(disposableType);
                compilationContext.RegisterSymbolAction(analyzer.AnalyzeSymbol, SymbolKind.NamedType);
            });
        }
        public override void Initialize(AnalysisContext analysisContext)
        {
            analysisContext.RegisterCompilationStartAction(compilationContext =>
            {
                INamedTypeSymbol disposableType = WellKnownTypes.IDisposable(compilationContext.Compilation);

                if (disposableType == null)
                {
                    return;
                }

                DisposableFieldAnalyzer analyzer = GetAnalyzer(disposableType);
                compilationContext.RegisterSymbolAction(context =>
                {
                    analyzer.AnalyzeSymbol(context);
                },
                                                        SymbolKind.NamedType);
            });
        }