diff --git a/src/EditorFeatures/Core.Wpf/InlineRename/UI/SmartRename/SmartRenameViewModel.cs b/src/EditorFeatures/Core.Wpf/InlineRename/UI/SmartRename/SmartRenameViewModel.cs index fbb4afed7d98e..73e39b7eab634 100644 --- a/src/EditorFeatures/Core.Wpf/InlineRename/UI/SmartRename/SmartRenameViewModel.cs +++ b/src/EditorFeatures/Core.Wpf/InlineRename/UI/SmartRename/SmartRenameViewModel.cs @@ -21,6 +21,7 @@ using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Shared.TestHooks; +using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.InlineRename.UI.SmartRename; @@ -37,6 +38,9 @@ internal sealed partial class SmartRenameViewModel : INotifyPropertyChanged, IDi private bool _isDisposed; private TimeSpan AutomaticFetchDelay => _smartRenameSession.AutomaticFetchDelay; private Task _getSuggestionsTask = Task.CompletedTask; + private TimeSpan _semanticContextDelay; + private bool _semanticContextError; + private bool _semanticContextUsed; public event PropertyChangedEventHandler? PropertyChanged; @@ -176,6 +180,8 @@ await Task.Delay(_smartRenameSession.AutomaticFetchDelay, cancellationToken) if (IsUsingSemanticContext) { + var stopwatch = SharedStopwatch.StartNew(); + _semanticContextUsed = true; var document = this.BaseViewModel.Session.TriggerDocument; var smartRenameContext = ImmutableDictionary>.Empty; try @@ -188,9 +194,11 @@ await Task.Delay(_smartRenameSession.AutomaticFetchDelay, cancellationToken) smartRenameContext = ImmutableDictionary.CreateRange>( context .Select(n => new KeyValuePair>(n.Key, n.Value))); + _semanticContextDelay = stopwatch.Elapsed; } catch (Exception e) when (FatalError.ReportAndCatch(e, ErrorSeverity.Diagnostic)) { + _semanticContextError = true; // use empty smartRenameContext } _ = await _smartRenameSession.GetSuggestionsAsync(smartRenameContext, cancellationToken) diff --git a/src/EditorFeatures/Core.Wpf/InlineRename/UI/SmartRename/SmartRenameViewModel_Telemetry.cs b/src/EditorFeatures/Core.Wpf/InlineRename/UI/SmartRename/SmartRenameViewModel_Telemetry.cs index 572060b76a5e0..c023e6c1e1083 100644 --- a/src/EditorFeatures/Core.Wpf/InlineRename/UI/SmartRename/SmartRenameViewModel_Telemetry.cs +++ b/src/EditorFeatures/Core.Wpf/InlineRename/UI/SmartRename/SmartRenameViewModel_Telemetry.cs @@ -52,6 +52,10 @@ private void PostTelemetry(bool isCommit) m[nameof(SuggestionsPanelTelemetry.CollapseSuggestionsPanelWhenRenameStarts)] = _suggestionsPanelTelemetry.CollapseSuggestionsPanelWhenRenameStarts; m["CollapseSuggestionsPanelWhenRenameEnds"] = _globalOptionService.GetOption(InlineRenameUIOptionsStorage.CollapseSuggestionsPanel); m["smartRenameSessionInProgress"] = _smartRenameSession.IsInProgress; + m["smartRenameCorrelationId"] = _smartRenameSession.CorrelationId; + m["smartRenameSemanticContextUsed"] = _semanticContextUsed; + m["smartRenameSemanticContextDelay"] = _semanticContextDelay; + m["smartRenameSemanticContextError"] = _semanticContextError; })); } else @@ -63,6 +67,10 @@ private void PostTelemetry(bool isCommit) m["UseDropDown"] = true; m[nameof(SuggestionsDropdownTelemetry.DropdownButtonClickTimes)] = _suggestionsDropdownTelemetry.DropdownButtonClickTimes; m["smartRenameSessionInProgress"] = _smartRenameSession.IsInProgress; + m["smartRenameCorrelationId"] = _smartRenameSession.CorrelationId; + m["smartRenameSemanticContextUsed"] = _semanticContextUsed; + m["smartRenameSemanticContextDelay"] = _semanticContextDelay; + m["smartRenameSemanticContextError"] = _semanticContextError; })); } } diff --git a/src/EditorFeatures/Core.Wpf/Lightup/ISmartRenameSessionWrapper.cs b/src/EditorFeatures/Core.Wpf/Lightup/ISmartRenameSessionWrapper.cs index 9ee6e53ca2168..45efb9baff566 100644 --- a/src/EditorFeatures/Core.Wpf/Lightup/ISmartRenameSessionWrapper.cs +++ b/src/EditorFeatures/Core.Wpf/Lightup/ISmartRenameSessionWrapper.cs @@ -29,6 +29,7 @@ namespace Microsoft.CodeAnalysis.EditorFeatures.Lightup; private static readonly Func s_statusMessageAccessor; private static readonly Func s_statusMessageVisibilityAccessor; private static readonly Func> s_suggestedNamesAccessor; + private static readonly Func s_correlationIdAccessor; private static readonly Func? s_renameContextImmutableListCreateBuilderAccessor; private static readonly Action? s_renameContextImmutableListBuilderAddAccessor; private static readonly Func? s_renameContextImmutableListBuilderToArrayAccessor; @@ -52,6 +53,7 @@ static ISmartRenameSessionWrapper() s_statusMessageAccessor = LightupHelpers.CreatePropertyAccessor(s_wrappedType, nameof(StatusMessage), ""); s_statusMessageVisibilityAccessor = LightupHelpers.CreatePropertyAccessor(s_wrappedType, nameof(StatusMessageVisibility), false); s_suggestedNamesAccessor = LightupHelpers.CreatePropertyAccessor>(s_wrappedType, nameof(SuggestedNames), []); + s_correlationIdAccessor = LightupHelpers.CreatePropertyAccessor(s_wrappedType, nameof(CorrelationId), Guid.Empty); if (s_wrappedRenameContextType is not null) { @@ -93,6 +95,7 @@ private ISmartRenameSessionWrapper(object instance) public string StatusMessage => s_statusMessageAccessor(_instance); public bool StatusMessageVisibility => s_statusMessageVisibilityAccessor(_instance); public IReadOnlyList SuggestedNames => s_suggestedNamesAccessor(_instance); + public Guid CorrelationId => s_correlationIdAccessor(_instance); public event PropertyChangedEventHandler PropertyChanged {