Skip to content

Commit

Permalink
Make sure all diagnostics are enabled for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
sharwell committed May 16, 2015
1 parent 9a7eb6c commit 78c0f9c
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,22 @@ protected static async Task<ImmutableArray<Diagnostic>> GetSortedDiagnosticsFrom
projects.Add(document.Project);
}

var supportedDiagnosticsSpecificOptions = new Dictionary<string, ReportDiagnostic>();
foreach (var diagnostic in analyzer.SupportedDiagnostics)
{
// make sure the analyzers we are testing are enabled
supportedDiagnosticsSpecificOptions[diagnostic.Id] = ReportDiagnostic.Default;
}

var diagnostics = ImmutableArray.CreateBuilder<Diagnostic>();
foreach (var project in projects)
{
var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
// update the project compilation options
var modifiedSpecificDiagnosticOptions = project.CompilationOptions.SpecificDiagnosticOptions.SetItems(supportedDiagnosticsSpecificOptions);
var modifiedCompilationOptions = project.CompilationOptions.WithSpecificDiagnosticOptions(modifiedSpecificDiagnosticOptions);
var processedProject = project.WithCompilationOptions(modifiedCompilationOptions);

var compilation = await processedProject.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
var compilationWithAnalyzers = compilation.WithAnalyzers(ImmutableArray.Create(analyzer), null, cancellationToken);
var compilerDiagnostics = compilation.GetDiagnostics(cancellationToken);
var compilerErrors = compilerDiagnostics.Where(i => i.Severity == DiagnosticSeverity.Error);
Expand Down

0 comments on commit 78c0f9c

Please sign in to comment.