public void Instantiates_With_The_Given_Data(DiagnosticLevel level, Action <DiagnosticEventArgs> handler) { var d = new DiagnosticFactory(level, handler); Assert.Equal(level, d.GetProperty <DiagnosticLevel>("MinimumLevel")); Assert.Equal(handler, d.GetProperty <Action <DiagnosticEventArgs> >("EventHandler")); }
private void onCompilation(CompilationAnalysisContext context) { if (!context.Options.AdditionalFiles.Any()) { return; } var srcFiles = FileFilter.GetFiles(context.Options.AdditionalFiles).ToList(); if (!srcFiles.Any()) { return; } foreach (IAdditionalTextAnalyzer analyzer in Analyzers) { var diagnosticInfo = analyzer.GetDiagnosticInfo(srcFiles, context.CancellationToken); foreach (var info in diagnosticInfo) { var supportedDiagnostic = GetSupportedDiagnosticAttribute(analyzer); var diagnostic = DiagnosticFactory.Create(supportedDiagnostic.GetDescriptor(), info); context.ReportDiagnostic(diagnostic); } } }
public void Instantiates_With_The_Given_Data(object source, DiagnosticLevel level, Action <DiagnosticGeneratedEventArgs> handler) { var d = new DiagnosticFactory(source, level, handler); Assert.Equal(source, d.GetProperty <object>("Source")); Assert.Equal(level, d.GetProperty <DiagnosticLevel>("MinimumLevel")); Assert.Equal(handler, d.GetProperty <Action <DiagnosticGeneratedEventArgs> >("EventHandler")); }
public void Does_Not_Raise_Event_On_Info_When_Level_Is_Gt_Info(string message) { DiagnosticEventArgs e = null; var d = new DiagnosticFactory(this, DiagnosticLevel.Warning, (args) => { e = args; }); d.Info(message); Assert.Null(e); }
public void Does_Not_Raise_Event_On_Debug_When_Level_Is_Gt_Debug(string message) { DiagnosticGeneratedEventArgs e = null; var d = new DiagnosticFactory(this, DiagnosticLevel.Info, (args) => { e = args; }); d.Debug(message); Assert.Null(e); }
public void Does_Not_Raise_Event_On_Warning_When_Level_Is_Gt_Warning(string message) { DiagnosticEventArgs e = null; var d = new DiagnosticFactory(DiagnosticLevel.None, (args) => { e = args; }); d.Warning(message); Assert.Null(e); }
public void Raises_Event_On_Info(string message) { DiagnosticEventArgs e = null; var d = new DiagnosticFactory(this, DiagnosticLevel.Info, (args) => { e = args; }); d.Info(message); Assert.Equal(message, e.Message); Assert.Equal(DiagnosticLevel.Info, e.Level); Assert.False(e.IncludesException); Assert.Null(e.Exception); }
private void AnalyzeNode(SyntaxNodeAnalysisContext context, SyntaxKind kind) { var analyzersForKind = Analyzers.Where(p => ((ISyntaxNodeAnalyzer)p).Kind == kind); foreach (ISyntaxNodeAnalyzer syntaxNodeAnalyzer in analyzersForKind) { var diagnosticInfo = syntaxNodeAnalyzer.GetDiagnosticInfo(context); foreach (var info in diagnosticInfo) { var supportedDiagnostic = GetSupportedDiagnosticAttribute(syntaxNodeAnalyzer); var diagnostic = DiagnosticFactory.Create(supportedDiagnostic.GetDescriptor(), info); context.ReportDiagnostic(diagnostic); } } }
public void Raises_Event_On_Debug_With_Exception(string message, Exception ex) { DiagnosticEventArgs e = null; var d = new DiagnosticFactory(DiagnosticLevel.Debug, (args) => { e = args; }); d.Debug(message, ex); Assert.Equal(message, e.Message); Assert.Equal(ex, e.Exception); Assert.Equal(DiagnosticLevel.Debug, e.Level); Assert.True(e.IncludesException); Assert.NotNull(e.Exception); }
private PumaCompilationAnalysisReporterService(DiagnosticFactory diagnosticFactory) { _diagnosticFactory = diagnosticFactory; }