Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,12 @@ private static SemicolonBehavior MoveCaretToFinalPositionInStatement(bool specul
// actually move it.
if (!speculative)
{
Logger.Log(FunctionId.CommandHandler_CompleteStatement, KeyValueLogMessage.Create(LogType.UserAction, m =>
Logger.Log(FunctionId.CommandHandler_CompleteStatement, KeyValueLogMessage.Create(LogType.UserAction, static (m, args) =>
{
var (isInsideDelimiters, statementNode) = args;
m[nameof(isInsideDelimiters)] = isInsideDelimiters;
m[nameof(statementNode)] = statementNode.Kind();
}));
}, (isInsideDelimiters, statementNode)));

if (!args.TextView.TryMoveCaretToAndEnsureVisible(targetPosition))
return SemicolonBehavior.None;
Expand Down
17 changes: 9 additions & 8 deletions src/EditorFeatures/Core.Wpf/QuickInfo/OnTheFlyDocsView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ private async Task SetResultTextAsync(ICopilotCodeAnalysisService copilotService
else
{
SetResultText(EditorFeaturesResources.An_error_occurred_while_generating_documentation_for_this_code);
Logger.Log(FunctionId.Copilot_On_The_Fly_Docs_Error_Displayed, KeyValueLogMessage.Create(m =>
Logger.Log(FunctionId.Copilot_On_The_Fly_Docs_Error_Displayed, KeyValueLogMessage.Create(static (m, copilotRequestTime) =>
{
m["ElapsedTime"] = copilotRequestTime;
}, LogLevel.Information));
}, copilotRequestTime, LogLevel.Information));
}

CurrentState = OnTheFlyDocsState.Finished;
Expand All @@ -232,19 +232,20 @@ private async Task SetResultTextAsync(ICopilotCodeAnalysisService copilotService
SetResultText(responseString);
CurrentState = OnTheFlyDocsState.Finished;

Logger.Log(FunctionId.Copilot_On_The_Fly_Docs_Results_Displayed, KeyValueLogMessage.Create(m =>
Logger.Log(FunctionId.Copilot_On_The_Fly_Docs_Results_Displayed, KeyValueLogMessage.Create(static (m, args) =>
{
var (copilotRequestTime, responseString) = args;
m["ElapsedTime"] = copilotRequestTime;
m["ResponseLength"] = responseString.Length;
}, LogLevel.Information));
}, (copilotRequestTime, responseString), LogLevel.Information));
}
}
catch (OperationCanceledException)
{
Logger.Log(FunctionId.Copilot_On_The_Fly_Docs_Results_Canceled, KeyValueLogMessage.Create(m =>
Logger.Log(FunctionId.Copilot_On_The_Fly_Docs_Results_Canceled, KeyValueLogMessage.Create(static (m, stopwatch) =>
{
m["ElapsedTime"] = stopwatch.Elapsed;
}, LogLevel.Information));
}, stopwatch, LogLevel.Information));
}
catch (Exception e) when (FatalError.ReportAndCatch(e))
{
Expand Down Expand Up @@ -274,10 +275,10 @@ public OnTheFlyDocsState CurrentState
public void RequestResults()
{
CurrentState = OnTheFlyDocsState.Loading;
Logger.Log(FunctionId.Copilot_On_The_Fly_Docs_Loading_State_Entered, KeyValueLogMessage.Create(m =>
Logger.Log(FunctionId.Copilot_On_The_Fly_Docs_Loading_State_Entered, KeyValueLogMessage.Create(static (m, _onTheFlyDocsInfo) =>
{
m["HasDocumentationComments"] = _onTheFlyDocsInfo.HasComments;
}, LogLevel.Information));
}, _onTheFlyDocsInfo, LogLevel.Information));

OnTheFlyDocsLogger.LogOnTheFlyDocsResultsRequested();
if (_onTheFlyDocsInfo.HasComments)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ private async Task InvokeWorkerAsync(IProgress<CodeAnalysisProgress> progressTra
progressTracker.Report(CodeAnalysisProgress.Description(EditorFeaturesResources.Applying_changes));

using (Logger.LogBlock(
FunctionId.CodeFixes_ApplyChanges, KeyValueLogMessage.Create(LogType.UserAction, m => CreateLogProperties(m)), cancellationToken))
FunctionId.CodeFixes_ApplyChanges, KeyValueLogMessage.Create(
LogType.UserAction, static (m, @this) => @this.CreateLogProperties(m), this), cancellationToken))
{
var document = this.SubjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ public bool ExecuteCommand(ToggleLineCommentCommandArgs args, CommandExecutionCo
internal override CommentSelectionResult CollectEdits(Document document, ICommentSelectionService service,
ITextBuffer subjectBuffer, NormalizedSnapshotSpanCollection selectedSpans, ValueTuple command, CancellationToken cancellationToken)
{
using (Logger.LogBlock(FunctionId.CommandHandler_ToggleLineComment, KeyValueLogMessage.Create(LogType.UserAction, m =>
using (Logger.LogBlock(FunctionId.CommandHandler_ToggleLineComment, KeyValueLogMessage.Create(LogType.UserAction, static (m, args) =>
{
var (document, subjectBuffer) = args;
m[LanguageNameString] = document.Project.Language;
m[LengthString] = subjectBuffer.CurrentSnapshot.Length;
}), cancellationToken))
}, (document, subjectBuffer)), cancellationToken))
{
var commentInfo = service.GetInfo();
if (commentInfo.SupportsSingleLineComment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ public async Task<ImmutableArray<IntentSource>> ComputeIntentsAsync(IntentReques
var languageName = currentDocument.Project.Language;
if (!_lazyIntentProviders.TryGetValue((LanguageName: languageName, IntentName: intentRequestContext.IntentName), out var provider))
{
Logger.Log(FunctionId.Intellicode_UnknownIntent, KeyValueLogMessage.Create(LogType.UserAction, m =>
Logger.Log(FunctionId.Intellicode_UnknownIntent, KeyValueLogMessage.Create(LogType.UserAction, static (m, args) =>
{
var (intentRequestContext, languageName) = args;
m["intent"] = intentRequestContext.IntentName;
m["language"] = languageName;
}));
}, (intentRequestContext, languageName)));

return [];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private async Task StreamingFindReferencesAsync(

using (Logger.LogBlock(
FunctionId.CommandHandler_FindAllReference,
KeyValueLogMessage.Create(LogType.UserAction, m => m["type"] = "streaming"),
KeyValueLogMessage.Create(LogType.UserAction, static m => m["type"] = "streaming"),
cancellationToken))
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ internal sealed partial class FormatCommandHandler(

private void Format(ITextView textView, ITextBuffer textBuffer, Document document, TextSpan? selectionOpt, CancellationToken cancellationToken)
{
using (Logger.LogBlock(FunctionId.CommandHandler_FormatCommand, KeyValueLogMessage.Create(LogType.UserAction, m => m["Span"] = selectionOpt?.Length ?? -1), cancellationToken))
using (Logger.LogBlock(FunctionId.CommandHandler_FormatCommand, KeyValueLogMessage.Create(
LogType.UserAction, static (m, selectionOpt) => m["Span"] = selectionOpt?.Length ?? -1, selectionOpt), cancellationToken))
using (var transaction = CreateEditTransaction(textView, EditorFeaturesResources.Formatting))
{
_threadingContext.JoinableTaskFactory.Run(() => FormatAsync(
Expand Down
4 changes: 2 additions & 2 deletions src/EditorFeatures/Core/InlineRename/InlineRenameSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,10 @@ private void OnWorkspaceChanged(object sender, WorkspaceChangeEventArgs args)
var changedDocuments = args.NewSolution.GetChangedDocuments(args.OldSolution);
if (changedDocuments.Any())
{
Logger.Log(FunctionId.Rename_InlineSession_Cancel_NonDocumentChangedWorkspaceChange, KeyValueLogMessage.Create(m =>
Logger.Log(FunctionId.Rename_InlineSession_Cancel_NonDocumentChangedWorkspaceChange, KeyValueLogMessage.Create(static (m, args) =>
{
m["Kind"] = Enum.GetName(typeof(WorkspaceChangeKind), args.Kind);
}));
}, args));

Cancel();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ internal static void LogItemManagerUpdateDataPoint(TimeSpan elapsed, bool isCanc

internal static void ReportTelemetry()
{
Logger.Log(FunctionId.Intellisense_AsyncCompletion_Data, KeyValueLogMessage.Create(m =>
Logger.Log(FunctionId.Intellisense_AsyncCompletion_Data, KeyValueLogMessage.Create(static m =>
{
foreach (var kv in s_statisticLogAggregator)
{
Expand Down
5 changes: 3 additions & 2 deletions src/EditorFeatures/Core/Remote/SolutionChecksumUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,13 @@ private async Task DispatchSynchronizeTextChangesAsync(
// Update aggregated telemetry with success status of sending the synchronization data.
var metricName = wasSynchronized.Value ? SynchronizeTextChangesStatusSucceededMetricName : SynchronizeTextChangesStatusFailedMetricName;
var keyName = wasSynchronized.Value ? SynchronizeTextChangesStatusSucceededKeyName : SynchronizeTextChangesStatusFailedKeyName;
TelemetryLogging.LogAggregatedCounter(FunctionId.ChecksumUpdater_SynchronizeTextChangesStatus, KeyValueLogMessage.Create(m =>
TelemetryLogging.LogAggregatedCounter(FunctionId.ChecksumUpdater_SynchronizeTextChangesStatus, KeyValueLogMessage.Create(static (m, args) =>
{
var (keyName, metricName) = args;
m[TelemetryLogging.KeyName] = keyName;
m[TelemetryLogging.KeyValue] = 1L;
m[TelemetryLogging.KeyMetricName] = metricName;
}));
}, (keyName, metricName)));

return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ public override void Apply(Workspace workspace, CancellationToken cancellationTo

if (workspace.Services.GetService<IWorkspaceTelemetryService>()?.IsUserMicrosoftInternal is true)
{
Logger.Log(FunctionId.Copilot_Suggestion_Dismissed, KeyValueLogMessage.Create(m =>
Logger.Log(FunctionId.Copilot_Suggestion_Dismissed, KeyValueLogMessage.Create(static (m, args) =>
{
var (diagnostic, originalMethodNode) = args;
if (diagnostic.Properties.TryGetValue(FixPropertyName, out var fix))
m["FixedMethod"] = fix;

Expand All @@ -49,6 +50,7 @@ public override void Apply(Workspace workspace, CancellationToken cancellationTo
m["Message"] = diagnostic.GetMessage();
m["OriginalMethod"] = originalMethodNode.ToFullString();
},
(diagnostic, originalMethodNode),
LogLevel.Information));
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ internal static void LogAddedParameter_ValueOmitted()

internal static void ReportTelemetry()
{
Logger.Log(FunctionId.ChangeSignature_Data, KeyValueLogMessage.Create(m =>
Logger.Log(FunctionId.ChangeSignature_Data, KeyValueLogMessage.Create(static m =>
{
foreach (var kv in s_countLogAggregator)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ protected async Task<ImmutableArray<CodeActionOperation>> GetFixAllOperationsAsy

using (Logger.LogBlock(
functionId,
KeyValueLogMessage.Create(LogType.UserAction, m =>
KeyValueLogMessage.Create(LogType.UserAction, static (m, correlationId) =>
{
// only set when correlation id is given
// we might not have this info for suppression
if (correlationId.HasValue)
{
m[FixAllLogger.CorrelationId] = correlationId;
}
}),
}, correlationId),
cancellationToken))
{
var glyph = language == null
Expand Down Expand Up @@ -165,11 +165,11 @@ protected async Task<ImmutableArray<CodeActionOperation>> GetFixAllOperationsAsy

using (Logger.LogBlock(
functionId,
KeyValueLogMessage.Create(LogType.UserAction, m =>
KeyValueLogMessage.Create(LogType.UserAction, static (m, fixAllContext) =>
{
m[FixAllLogger.CorrelationId] = fixAllContext.State.CorrelationId;
m[FixAllLogger.FixAllScope] = fixAllContext.State.Scope.ToString();
}),
}, fixAllContext),
fixAllContext.CancellationToken))
{
CodeAction? action = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,12 @@ public async Task<ImmutableArray<CodeRefactoring>> GetRefactoringsAsync(

var providerName = provider.GetType().Name;

var logMessage = KeyValueLogMessage.Create(m =>
var logMessage = KeyValueLogMessage.Create(static (m, args) =>
{
var (providerName, document) = args;
m[TelemetryLogging.KeyName] = providerName;
m[TelemetryLogging.KeyLanguageName] = document.Project.Language;
});
}, (providerName, document));

using (RoslynEventSource.LogInformationalBlock(FunctionId.Refactoring_CodeRefactoringService_GetRefactoringsAsync, providerName, cancellationToken))
using (TelemetryLogging.LogBlockTime(FunctionId.CodeRefactoring_Delay, logMessage, CodeRefactoringTelemetryDelay))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ internal static void LogCustomizedCommitToAddParenthesis(char? commitChar)

internal static void ReportTelemetry()
{
Logger.Log(FunctionId.Intellisense_CompletionProviders_Data, KeyValueLogMessage.Create(m =>
Logger.Log(FunctionId.Intellisense_CompletionProviders_Data, KeyValueLogMessage.Create(static m =>
{
foreach (var kv in s_statisticLogAggregator)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ public static void LogHyperlink(
bool telemetry,
string uri)
{
Logger.Log(FunctionId.Diagnostics_HyperLink, KeyValueLogMessage.Create(m =>
Logger.Log(FunctionId.Diagnostics_HyperLink, KeyValueLogMessage.Create(static (m, args) =>
{
var (from, telemetry, id, description, uri) = args;
m[From] = from;
m[Id] = telemetry ? id : id.GetHashCode().ToString();
m[HasDescription] = description;
m[Uri] = telemetry ? uri : uri.GetHashCode().ToString();
}));
}, (from, telemetry, id, description, uri)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,16 @@ public static void Log(Data data, Action<FunctionId, LogMessage> log, Func<int>

var debugSessionId = getNextId();

log(FunctionId.Debugging_EncSession, KeyValueLogMessage.Create(map =>
log(FunctionId.Debugging_EncSession, KeyValueLogMessage.Create(static (map, args) =>
{
var (data, debugSessionId) = args;
map["SolutionSessionId"] = data.SolutionSessionId.ToString("B").ToUpperInvariant();
map[SessionId] = debugSessionId;
map["SessionCount"] = data.EditSessionData.Count(session => session.InBreakState);
map["EmptySessionCount"] = data.EmptyEditSessionCount;
map["HotReloadSessionCount"] = data.EditSessionData.Count(session => !session.InBreakState);
map["EmptyHotReloadSessionCount"] = data.EmptyHotReloadEditSessionCount;
}));
}, (data, debugSessionId)));

foreach (var editSessionData in data.EditSessionData)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal sealed class TelemetryMessage : IDisposable

public TelemetryMessage(CancellationToken cancellationToken)
{
var logMessage = KeyValueLogMessage.Create(LogType.UserAction, SetLogProperties);
var logMessage = KeyValueLogMessage.Create(LogType.UserAction, static (m, @this) => @this.SetLogProperties(m), this);
_logBlock = Logger.LogBlock(FunctionId.NavigateToExternalSources, logMessage, cancellationToken);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ internal static void LogOnTheFlyDocsResultsRequestedWithDocComments()

public static void ReportTelemetry()
{
Logger.Log(FunctionId.Copilot_On_The_Fly_Docs_Get_Counts, KeyValueLogMessage.Create(m =>
Logger.Log(FunctionId.Copilot_On_The_Fly_Docs_Get_Counts, KeyValueLogMessage.Create(static m =>
{
foreach (var kv in s_countLogAggregator)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,11 +535,12 @@ private async IAsyncEnumerable<CodeFixCollection> StreamFixesAsync(
const int CodeFixTelemetryDelay = 500;

var fixerName = fixer.GetType().Name;
var logMessage = KeyValueLogMessage.Create(m =>
var logMessage = KeyValueLogMessage.Create(static (m, args) =>
{
var (fixerName, document) = args;
m[TelemetryLogging.KeyName] = fixerName;
m[TelemetryLogging.KeyLanguageName] = document.Project.Language;
});
}, (fixerName, document));

using var _ = TelemetryLogging.LogBlockTime(FunctionId.CodeFix_Delay, logMessage, CodeFixTelemetryDelay);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public virtual void Register(Workspace? workspace)
if (workspace is null)
return;

Logger.Log(FunctionId.RegisterWorkspace, KeyValueLogMessage.Create(LogType.Trace, m =>
Logger.Log(FunctionId.RegisterWorkspace, KeyValueLogMessage.Create(LogType.Trace, static (m, workspace) =>
{
m["WorkspaceKind"] = workspace.Kind;
m["WorkspaceCanOpenDocuments"] = workspace.CanOpenDocuments;
m["WorkspaceCanChangeActiveContextDocument"] = workspace.CanChangeActiveContextDocument;
m["WorkspacePartialSemanticsEnabled"] = workspace.PartialSemanticsEnabled;
}));
}, workspace));

lock (_gate)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ private async Task InitializeWorkspaceAsync(ISolutionAnalyzerSetterWorkspaceServ

private static void LogWorkspaceAnalyzerCount(int analyzerCount)
{
Logger.Log(FunctionId.DiagnosticAnalyzerService_Analyzers, KeyValueLogMessage.Create(m => m["AnalyzerCount"] = analyzerCount, LogLevel.Debug));
Logger.Log(FunctionId.DiagnosticAnalyzerService_Analyzers, KeyValueLogMessage.Create(
static (m, analyzerCount) => m["AnalyzerCount"] = analyzerCount, analyzerCount, LogLevel.Debug));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ public void ShowGlobalErrorInfo(string message, TelemetryFeatureName featureName
LogGlobalErrorToActivityLog(message, stackTrace);
_infoBar.ShowInfoBarMessageFromAnyThread(message, items);

Logger.Log(FunctionId.VS_ErrorReportingService_ShowGlobalErrorInfo, KeyValueLogMessage.Create(LogType.UserAction, m =>
Logger.Log(FunctionId.VS_ErrorReportingService_ShowGlobalErrorInfo, KeyValueLogMessage.Create(LogType.UserAction, static (m, args) =>
{
var (message, featureName) = args;
m["Message"] = message;
m["FeatureName"] = featureName.ToString();
}));
}, (message, featureName)));
}

public void ShowDetailedErrorInfo(Exception exception)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public static void ReportTelemetry()
{
Logger.Log(FunctionId.InheritanceMargin_GetInheritanceMemberItems,
KeyValueLogMessage.Create(
m =>
static m =>
{
var histogramLogAggragator = s_histogramLogAggregator.GetValue(ActionInfo.GetInheritanceMarginMembers);
if (histogramLogAggragator != null)
var histogramLogAggregator = s_histogramLogAggregator.GetValue(ActionInfo.GetInheritanceMarginMembers);
if (histogramLogAggregator != null)
{
histogramLogAggragator.WriteTelemetryPropertiesTo(m, nameof(ActionInfo.GetInheritanceMarginMembers) + ".");
histogramLogAggregator.WriteTelemetryPropertiesTo(m, nameof(ActionInfo.GetInheritanceMarginMembers) + ".");
}
}));
}
Expand Down
Loading
Loading