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

Merge main to main-vs-deps #54112

Merged
merged 19 commits into from
Jun 16, 2021
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
11 changes: 11 additions & 0 deletions src/EditorFeatures/VisualBasicTest/NavigateTo/NavigateToTests.vb
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,17 @@ End Class", Async Function(w)
End Function)
End Function

<Theory>
<CombinatorialData>
Public Async Function TestFindAbstractMethod(testHost As TestHost, composition As Composition) As Task
Await TestAsync(testHost, composition, "MustInherit Class A
Public MustOverride Sub M()
End Class", Async Function(w)
Dim item = (Await _aggregator.GetItemsAsync("M")).Single
VerifyNavigateToResultItem(item, "M", "[|M|]()", PatternMatchKind.Exact, NavigateToItemKind.Method, Glyph.MethodPublic, additionalInfo:=String.Format(FeaturesResources.in_0_project_1, "A", "Test"))
End Function)
End Function

<WorkItem(1111131, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1111131")>
<Theory>
<CombinatorialData>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static CompletionItem Create(
{
// We don't need arity to recover symbol if we already have SymbolKeyData or it's 0.
// (but it still needed below to decide whether to show generic suffix)
builder.Add(TypeAritySuffixName, AbstractDeclaredSymbolInfoFactoryService.GetMetadataAritySuffix(arity));
builder.Add(TypeAritySuffixName, ArityUtilities.GetMetadataAritySuffix(arity));
}

properties = builder.ToImmutableDictionaryAndFree();
Expand Down
50 changes: 32 additions & 18 deletions src/VisualStudio/Core/Def/Telemetry/VSTelemetryLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@

#nullable disable

using System;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Threading;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.VisualStudio.Telemetry;
using Roslyn.Utilities;
Expand Down Expand Up @@ -55,15 +53,12 @@ public void Log(FunctionId functionId, LogMessage logMessage)

public void LogBlockStart(FunctionId functionId, LogMessage logMessage, int blockId, CancellationToken cancellationToken)
{
if (!(logMessage is KeyValueLogMessage kvLogMessage))
{
return;
}

try
{
// guard us from exception thrown by telemetry
_pendingScopes[blockId] = CreateAndStartScope(kvLogMessage.Kind, functionId);
var kind = GetKind(logMessage);

_pendingScopes[blockId] = CreateAndStartScope(kind, functionId);
}
catch
{
Expand All @@ -72,22 +67,18 @@ public void LogBlockStart(FunctionId functionId, LogMessage logMessage, int bloc

public void LogBlockEnd(FunctionId functionId, LogMessage logMessage, int blockId, int delta, CancellationToken cancellationToken)
{
if (!(logMessage is KeyValueLogMessage kvLogMessage))
{
return;
}

try
{
// guard us from exception thrown by telemetry
var kind = kvLogMessage.Kind;
var kind = GetKind(logMessage);

switch (kind)
{
case LogType.Trace:
EndScope<OperationEvent>(functionId, blockId, kvLogMessage, cancellationToken);
EndScope<OperationEvent>(functionId, blockId, logMessage, cancellationToken);
return;
case LogType.UserAction:
EndScope<UserTaskEvent>(functionId, blockId, kvLogMessage, cancellationToken);
EndScope<UserTaskEvent>(functionId, blockId, logMessage, cancellationToken);
return;
default:
throw ExceptionUtilities.UnexpectedValue(kind);
Expand All @@ -98,7 +89,16 @@ public void LogBlockEnd(FunctionId functionId, LogMessage logMessage, int blockI
}
}

private void EndScope<T>(FunctionId functionId, int blockId, KeyValueLogMessage kvLogMessage, CancellationToken cancellationToken)
private static LogType GetKind(LogMessage logMessage)
=> logMessage is KeyValueLogMessage kvLogMessage
? kvLogMessage.Kind
: logMessage.LogLevel switch
{
>= LogLevel.Information => LogType.UserAction,
_ => LogType.Trace
};

private void EndScope<T>(FunctionId functionId, int blockId, LogMessage logMessage, CancellationToken cancellationToken)
where T : OperationEvent
{
if (!_pendingScopes.TryRemove(blockId, out var value))
Expand All @@ -109,7 +109,7 @@ private void EndScope<T>(FunctionId functionId, int blockId, KeyValueLogMessage

var operation = (TelemetryScope<T>)value;

AppendProperties(operation.EndEvent, functionId, kvLogMessage);
UpdateEvent(operation.EndEvent, functionId, logMessage);
operation.End(cancellationToken.IsCancellationRequested ? TelemetryResult.UserCancel : TelemetryResult.Success);
}

Expand All @@ -132,10 +132,24 @@ private static TelemetryEvent CreateTelemetryEvent(FunctionId functionId, LogMes
var eventName = functionId.GetEventName();
var telemetryEvent = new TelemetryEvent(eventName);

return UpdateEvent(telemetryEvent, functionId, logMessage);
}

private static TelemetryEvent UpdateEvent(TelemetryEvent telemetryEvent, FunctionId functionId, LogMessage logMessage)
{
if (logMessage is KeyValueLogMessage kvLogMessage)
{
telemetryEvent = AppendProperties(telemetryEvent, functionId, kvLogMessage);
}
else
{
var message = logMessage.GetMessage();
if (!string.IsNullOrWhiteSpace(message))
{
var propertyName = functionId.GetPropertyName("Message");
telemetryEvent.Properties.Add(propertyName, message);
}
}

return telemetryEvent;
}
Expand Down
Loading