From 70b64e24382eb3f649298a0c217741b5207097a8 Mon Sep 17 00:00:00 2001 From: David Barbet Date: Fri, 20 Oct 2023 18:38:04 -0700 Subject: [PATCH] Ensure execution diagnostics are logged as well --- .../LanguageServerProjectSystem.cs | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs index c849f47d63a5f..9311bc3c886f5 100644 --- a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs +++ b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs @@ -193,7 +193,7 @@ private async ValueTask LoadOrReloadProjectsAsync(ImmutableSegmentedList LoadOrReloadProjectAsync(ProjectToLoad projectToLoad, BuildHostProcessManager buildHostProcessManager, CancellationToken cancellationToken) + private async Task<(LSP.MessageType? FailureType, BuildHostProcessKind? PreferredKind)> LoadOrReloadProjectAsync(ProjectToLoad projectToLoad, BuildHostProcessManager buildHostProcessManager, CancellationToken cancellationToken) { BuildHostProcessKind? preferredBuildHostKind = null; @@ -207,11 +207,10 @@ private async ValueTask LoadOrReloadProjectsAsync(ImmutableSegmentedList item.Kind is WorkspaceDiagnosticKind.Failure)) { - // If there were any total failures, no point in continuing. + _ = LogDiagnostics(projectPath, diagnosticLogItems); + // We have total failures in evaluation, no point in continuing. return (LSP.MessageType.Error, preferredBuildHostKind); } @@ -257,7 +256,14 @@ private async ValueTask LoadOrReloadProjectsAsync(ImmutableSegmentedList diagnosticLogItems) + LSP.MessageType? LogDiagnostics(string projectPath, ImmutableArray diagnosticLogItems) { + if (diagnosticLogItems.IsEmpty) + { + return null; + } + foreach (var logItem in diagnosticLogItems) { var projectName = Path.GetFileName(projectPath); _logger.Log(logItem.Kind is WorkspaceDiagnosticKind.Failure ? LogLevel.Error : LogLevel.Warning, $"{logItem.Kind} while loading {logItem.ProjectFilePath}: {logItem.Message}"); } + + return diagnosticLogItems.Any(logItem => logItem.Kind is WorkspaceDiagnosticKind.Failure) ? LSP.MessageType.Error : LSP.MessageType.Warning; } } }