Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only report project load events for initial load in VSCode #74688

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -131,7 +131,7 @@ public async Task OpenProjectsAsync(ImmutableArray<string> 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();
Expand Down Expand Up @@ -278,7 +278,7 @@ private async Task<bool> 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);
Expand All @@ -288,7 +288,11 @@ private async Task<bool> 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())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.CodeAnalysis.LanguageServer.HostWorkspace;
/// <summary>
/// The project path (and the guid if it game from a solution) of the project to load.
/// </summary>
internal record ProjectToLoad(string Path, string? ProjectGuid)
internal record ProjectToLoad(string Path, string? ProjectGuid, bool ReportTelemetry)
{
public static IEqualityComparer<ProjectToLoad> Comparer = new ProjectToLoadComparer();

Expand Down
Loading