Example #1
0
 public AnalyzerCompilationStartAnalysisContext(
     DiagnosticAnalyzer analyzer,
     HostCompilationStartAnalysisScope scope,
     Compilation compilation,
     AnalyzerOptions options,
     CompilationAnalysisValueProviderFactory compilationAnalysisValueProviderFactory,
     CancellationToken cancellationToken)
     : base(compilation, options, cancellationToken)
 {
     _analyzer = analyzer;
     _scope    = scope;
     _compilationAnalysisValueProviderFactory = compilationAnalysisValueProviderFactory;
 }
            public Task <HostCompilationStartAnalysisScope> GetCompilationAnalysisScopeAsync(
                HostSessionStartAnalysisScope sessionScope,
                AnalyzerExecutor analyzerExecutor)
            {
                lock (_gate)
                {
                    if (_lazyCompilationScopeTask == null)
                    {
                        _lazyCompilationScopeTask = Task.Run(() =>
                        {
                            var compilationAnalysisScope = new HostCompilationStartAnalysisScope(sessionScope);
                            analyzerExecutor.ExecuteCompilationStartActions(sessionScope.GetAnalyzerActions(_analyzer).CompilationStartActions, compilationAnalysisScope);
                            return(compilationAnalysisScope);
                        }, analyzerExecutor.CancellationToken);
                    }

                    return(_lazyCompilationScopeTask);
                }
            }