diff --git a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs index b896d0b363112..781feabf5d46e 100644 --- a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs +++ b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs @@ -115,7 +115,7 @@ public async Task OpenSolutionAsync(string solutionFilePath) foreach (var project in await buildHost.GetProjectsInSolutionAsync(solutionFilePath, CancellationToken.None)) { - _projectsToLoadAndReload.AddWork(new ProjectToLoad(project.ProjectPath, project.ProjectGuid)); + _projectsToLoadAndReload.AddWork(new ProjectToLoad(project.ProjectPath, project.ProjectGuid, ReportTelemetry: true)); } // Wait for the in progress batch to complete and send a project initialized notification to the client. @@ -131,7 +131,7 @@ public async Task OpenProjectsAsync(ImmutableArray projectFilePaths) using (await _gate.DisposableWaitAsync()) { - _projectsToLoadAndReload.AddWork(projectFilePaths.Select(p => new ProjectToLoad(p, ProjectGuid: null))); + _projectsToLoadAndReload.AddWork(projectFilePaths.Select(p => new ProjectToLoad(p, ProjectGuid: null, ReportTelemetry: true))); // Wait for the in progress batch to complete and send a project initialized notification to the client. await _projectsToLoadAndReload.WaitUntilCurrentBatchCompletesAsync(); @@ -278,7 +278,7 @@ private async Task LoadOrReloadProjectAsync(ProjectToLoad projectToLoad, T _workspaceFactory.ProjectSystemHostInfo); var loadedProject = new LoadedProject(projectSystemProject, _workspaceFactory.Workspace.Services.SolutionServices, _fileChangeWatcher, _workspaceFactory.TargetFrameworkManager); - loadedProject.NeedsReload += (_, _) => _projectsToLoadAndReload.AddWork(projectToLoad); + loadedProject.NeedsReload += (_, _) => _projectsToLoadAndReload.AddWork(projectToLoad with { ReportTelemetry = false }); existingProjects.Add(loadedProject); (targetTelemetryInfo, targetNeedsRestore) = await loadedProject.UpdateWithNewProjectInfoAsync(loadedProjectInfo, _logger); @@ -288,7 +288,11 @@ private async Task LoadOrReloadProjectAsync(ProjectToLoad projectToLoad, T } } - await _projectLoadTelemetryReporter.ReportProjectLoadTelemetryAsync(telemetryInfos, projectToLoad, cancellationToken); + if (projectToLoad.ReportTelemetry) + { + await _projectLoadTelemetryReporter.ReportProjectLoadTelemetryAsync(telemetryInfos, projectToLoad, cancellationToken); + } + diagnosticLogItems = await loadedFile.GetDiagnosticLogItemsAsync(cancellationToken); if (diagnosticLogItems.Any()) { diff --git a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/ProjectToLoad.cs b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/ProjectToLoad.cs index bacfa547fffd8..ae11154877798 100644 --- a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/ProjectToLoad.cs +++ b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/ProjectToLoad.cs @@ -9,7 +9,7 @@ namespace Microsoft.CodeAnalysis.LanguageServer.HostWorkspace; /// /// The project path (and the guid if it game from a solution) of the project to load. /// -internal record ProjectToLoad(string Path, string? ProjectGuid) +internal record ProjectToLoad(string Path, string? ProjectGuid, bool ReportTelemetry) { public static IEqualityComparer Comparer = new ProjectToLoadComparer();