private async Task <ImmutableDictionary <TestFile, ImmutableArray <DiagnosticAnalyzer> > > GetFilteredDocumentAnalyzersAsync(TestFile codeFile, TestFile codeFile2, TestFile editorconfigFile) { using var host = CreateOmniSharpHost(new[] { codeFile, codeFile2, editorconfigFile }); var project = host.Workspace.CurrentSolution.Projects.Single(); var compilation = await project.GetCompilationAsync(); var allAnalyzers = GetConfigurableAnalyzers(host, project); Assert.NotEmpty(allAnalyzers); var analyzersMap = ImmutableDictionary.CreateBuilder <TestFile, ImmutableArray <DiagnosticAnalyzer> >(); foreach (var document in project.Documents) { var documentAnalyzers = await CSharpDiagnosticWorkerWithAnalyzers.FilterAnalyzersBySeverityAsync(allAnalyzers, document, project.AnalyzerOptions, compilation, ReportDiagnostic.Hidden); var testFile = document.FilePath == codeFile.FileName ? codeFile : codeFile2; analyzersMap.Add(testFile, documentAnalyzers); } Assert.Equal(2, analyzersMap.Count); return(analyzersMap.ToImmutable()); }
private async Task <ImmutableArray <DiagnosticAnalyzer> > GetFilteredProjectAnalyzersAsync(TestFile codeFile, TestFile editorconfigFile) { using var host = CreateOmniSharpHost(new[] { codeFile, editorconfigFile }); var project = host.Workspace.CurrentSolution.Projects.Single(); var compilation = await project.GetCompilationAsync(); var allAnalyzers = GetConfigurableAnalyzers(host, project); Assert.NotEmpty(allAnalyzers); return(await CSharpDiagnosticWorkerWithAnalyzers.FilterAnalyzersBySeverityAsync(allAnalyzers, project, compilation, ReportDiagnostic.Hidden)); }