Пример #1
0
        public void Register(AnalysisContext context, ICompilationAnalyzer analyzer)
        {
            var additionalTextAnalyzer = analyzer as IAdditionalTextAnalyzer;

            if (additionalTextAnalyzer == null)
            {
                return;
            }

            context.RegisterCompilationAction(c =>
            {
                var pumaContext = new PumaCompilationAnalysisContext(additionalTextAnalyzer.GetDiagnosticId(), c);
                additionalTextAnalyzer.OnCompilationEnd(pumaContext);
                while (!additionalTextAnalyzer.VulnerableAdditionalText.IsEmpty)
                {
                    DiagnosticInfo additionalText;
                    if (!additionalTextAnalyzer.VulnerableAdditionalText.TryPop(out additionalText))
                    {
                        continue;
                    }

                    var supportedDiagnostic = additionalTextAnalyzer.GetSupportedDiagnosticAttribute();

                    var diagnostic = _diagnosticFactory.Create(supportedDiagnostic.GetDescriptor(), additionalText);

                    c.ReportDiagnostic(diagnostic);
                }
            });
        }
Пример #2
0
 internal void RegisterCompilationEndAction(Action <PumaCompilationAnalysisContext> compilationEndAction, DiagnosticId diagnosticId)
 {
     _context.RegisterCompilationEndAction(c =>
     {
         var pumaCompilationEndContext = new PumaCompilationAnalysisContext(diagnosticId, c);
         compilationEndAction.Invoke(pumaCompilationEndContext);
     });
 }