Skip to content
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 @@ -206,8 +206,15 @@ public void RequestResults()
Logger.Log(FunctionId.Copilot_On_The_Fly_Docs_Loading_State_Entered, KeyValueLogMessage.Create(m =>
{
m["SymbolHeaderText"] = _onTheFlyDocsElement.SymbolSignature;
m["HasDocumentationComments"] = _onTheFlyDocsElement.HasComments;
}, LogLevel.Information));

OnTheFlyDocsLogger.LogOnTheFlyDocsResultsRequested();
if (_onTheFlyDocsElement.HasComments)
{
OnTheFlyDocsLogger.LogOnTheFlyDocsResultsRequestedWithDocComments();
}

ResultsRequested?.Invoke(this, EventArgs.Empty);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ public OnTheFlyDocsViewFactory(IViewElementFactoryService factoryService, IAsync
throw new InvalidOperationException("QuickInfoSession is null");
}

OnTheFlyDocsLogger.LogShowedOnTheFlyDocsLink();
Copy link
Member

@genlu genlu Jun 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we log whether a symbol has doc-comment here? That would tell us how often a symbol user hover over has no doc, right?


if (editorFeaturesOnTheFlyDocsElement.OnTheFlyDocsElement.HasComments)
{
OnTheFlyDocsLogger.LogShowedOnTheFlyDocsLinkWithDocComments();
}

return new OnTheFlyDocsView(textView, _factoryService, _listenerProvider, quickInfoSession, _threadingContext, editorFeaturesOnTheFlyDocsElement) as TView;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@ protected override NullableFlowState GetNullabilityAnalysis(SemanticModel semant
return null;
}

if (symbol.MetadataToken != 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this does what we want? Great!

{
OnTheFlyDocsLogger.LogHoveredMetadataSymbol();
}
else
{
OnTheFlyDocsLogger.LogHoveredSourceSymbol();
}

if (symbol.DeclaringSyntaxReferences.Length == 0)
{
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using Microsoft.CodeAnalysis.ChangeSignature;
using Microsoft.CodeAnalysis.Completion.Log;
using Microsoft.CodeAnalysis.QuickInfo;

namespace Microsoft.CodeAnalysis.Common;

Expand All @@ -13,5 +14,6 @@ public static void Report()
{
CompletionProvidersLogger.ReportTelemetry();
ChangeSignatureLogger.ReportTelemetry();
OnTheFlyDocsLogger.ReportTelemetry();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ namespace Microsoft.CodeAnalysis.QuickInfo;
/// <param name="symbolSignature">formatted string representation of a symbol/></param>
/// <param name="declarationCode">the symbol's declaration code</param>
/// <param name="language">the language of the symbol</param>
internal sealed class OnTheFlyDocsElement(string symbolSignature, ImmutableArray<string> declarationCode, string language)
/// <param name="hasComments">whether the symbol has comments</param>
internal sealed class OnTheFlyDocsElement(string symbolSignature, ImmutableArray<string> declarationCode, string language, bool hasComments = false)
{
public string SymbolSignature { get; } = symbolSignature;
public ImmutableArray<string> DeclarationCode { get; } = declarationCode;
public string Language { get; } = language;

// Added for telemetry collection purposes.
public bool HasComments { get; set; } = hasComments;
}
52 changes: 52 additions & 0 deletions src/Features/Core/Portable/QuickInfo/OnTheFlyDocsLogger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using Microsoft.CodeAnalysis.Internal.Log;

namespace Microsoft.CodeAnalysis.QuickInfo;

internal static class OnTheFlyDocsLogger
{
private static readonly CountLogAggregator<ActionInfo> s_countLogAggregator = new();

private enum ActionInfo
{
HoveredSourceSymbol,
HoveredMetadataSymbol,
ShowedOnTheFlyDocsLink,
ShowedOnTheFlyDocsLinkWithDocComments,
OnTheFlyDocsResultsRequested,
OnTheFlyDocsResultsRequestedWithDocComments,
}

internal static void LogHoveredSourceSymbol()
=> s_countLogAggregator.IncreaseCount(ActionInfo.HoveredSourceSymbol);

internal static void LogHoveredMetadataSymbol()
=> s_countLogAggregator.IncreaseCount(ActionInfo.HoveredMetadataSymbol);

internal static void LogShowedOnTheFlyDocsLink()
=> s_countLogAggregator.IncreaseCount(ActionInfo.ShowedOnTheFlyDocsLink);

internal static void LogShowedOnTheFlyDocsLinkWithDocComments()
=> s_countLogAggregator.IncreaseCount(ActionInfo.ShowedOnTheFlyDocsLinkWithDocComments);

internal static void LogOnTheFlyDocsResultsRequested()
=> s_countLogAggregator.IncreaseCount(ActionInfo.OnTheFlyDocsResultsRequested);

internal static void LogOnTheFlyDocsResultsRequestedWithDocComments()
=> s_countLogAggregator.IncreaseCount(ActionInfo.OnTheFlyDocsResultsRequestedWithDocComments);

public static void ReportTelemetry()
{
Logger.Log(FunctionId.InheritanceMargin_GetInheritanceMemberItems, KeyValueLogMessage.Create(m =>
{
foreach (var kv in s_countLogAggregator)
{
m[kv.Key.ToString()] = kv.Value.GetCount();
}
}));
}
}
6 changes: 6 additions & 0 deletions src/Features/Core/Portable/QuickInfo/QuickInfoUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,13 @@ public static async Task<QuickInfoItem> CreateQuickInfoItemAsync(
}

if (groups.TryGetValue(SymbolDescriptionGroups.Documentation, out var docParts) && !docParts.IsDefaultOrEmpty)
{
AddSection(QuickInfoSectionKinds.DocumentationComments, docParts);
if (onTheFlyDocsElement != null)
{
onTheFlyDocsElement.HasComments = true;
}
}

if (options.QuickInfoOptions.ShowRemarksInQuickInfo &&
groups.TryGetValue(SymbolDescriptionGroups.RemarksDocumentation, out var remarksDocumentation) &&
Expand Down
1 change: 1 addition & 0 deletions src/VisualStudio/Core/Def/RoslynPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Microsoft.CodeAnalysis.Common;
using Microsoft.CodeAnalysis.EditAndContinue;
using Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.AsyncCompletion;
using Microsoft.CodeAnalysis.Editor.QuickInfo;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.Notification;
Expand Down