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

Log telemetry item when parse or compilation options change #48215

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Telemetry;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.LanguageServices.Implementation.TaskList;
using Roslyn.Utilities;
Expand All @@ -27,6 +28,7 @@ internal sealed class VisualStudioProject

private readonly VisualStudioWorkspaceImpl _workspace;
private readonly HostDiagnosticUpdateSource _hostDiagnosticUpdateSource;
private readonly IWorkspaceTelemetryService _telemetryService;

/// <summary>
/// Provides dynamic source files for files added through <see cref="AddDynamicSourceFile" />.
Expand Down Expand Up @@ -138,6 +140,8 @@ internal VisualStudioProject(
_dynamicFileInfoProviders = dynamicFileInfoProviders;
_hostDiagnosticUpdateSource = hostDiagnosticUpdateSource;

_telemetryService = _workspace.Services.GetRequiredService<IWorkspaceTelemetryService>();
davidwengier marked this conversation as resolved.
Show resolved Hide resolved

Id = id;
Language = language;
_displayName = displayName;
Expand Down Expand Up @@ -195,7 +199,7 @@ private void ChangeProjectProperty<T>(ref T field, T newValue, Func<Solution, So

field = newValue;

if (logThrowAwayTelemetry)
if (logThrowAwayTelemetry && _telemetryService.HasActiveSession)
{
TryReportCompilationThrownAway(_workspace.CurrentSolution.State, Id);
}
Expand Down