private async Task <ImmutableDictionary <DiagnosticAnalyzer, DiagnosticAnalysisResult> > RemoveCompilerSemanticErrorsIfProjectNotLoadedAsync( ImmutableDictionary <DiagnosticAnalyzer, DiagnosticAnalysisResult> result, Project project, CancellationToken cancellationToken) { // see whether solution is loaded successfully var projectLoadedSuccessfully = await project.HasSuccessfullyLoadedAsync(cancellationToken).ConfigureAwait(false); if (projectLoadedSuccessfully) { return(result); } var compilerAnalyzer = HostAnalyzers.GetCompilerDiagnosticAnalyzer(project.Language); if (compilerAnalyzer == null) { // this language doesn't support compiler analyzer return(result); } if (!result.TryGetValue(compilerAnalyzer, out var analysisResult)) { // no result from compiler analyzer return(result); } Logger.Log(FunctionId.Diagnostics_ProjectDiagnostic, p => $"Failed to Load Successfully ({p.FilePath ?? p.Name})", project); // get rid of any result except syntax from compiler analyzer result var newCompilerAnalysisResult = analysisResult.DropExceptSyntax(); // return new result return(result.SetItem(compilerAnalyzer, newCompilerAnalysisResult)); }
public ImmutableDictionary <string, ImmutableArray <DiagnosticDescriptor> > GetDiagnosticDescriptorsPerReference(Project project) => HostAnalyzers.GetDiagnosticDescriptorsPerReference(AnalyzerInfoCache, project);