diff --git a/src/Cli/dotnet/commands/dotnet-test/CliConstants.cs b/src/Cli/dotnet/commands/dotnet-test/CliConstants.cs index de00b296ab83..75c151aa1ff8 100644 --- a/src/Cli/dotnet/commands/dotnet-test/CliConstants.cs +++ b/src/Cli/dotnet/commands/dotnet-test/CliConstants.cs @@ -40,7 +40,7 @@ internal static class HandshakeInfoPropertyNames internal const byte Architecture = 1; internal const byte Framework = 2; internal const byte OS = 3; - internal const byte ProtocolVersion = 4; + internal const byte SupportedProtocolVersions = 4; internal const byte HostType = 5; internal const byte ModulePath = 6; internal const byte ExecutionId = 7; diff --git a/src/Cli/dotnet/commands/dotnet-test/TestApplication.cs b/src/Cli/dotnet/commands/dotnet-test/TestApplication.cs index 0208955272f2..db69c2ae6a44 100644 --- a/src/Cli/dotnet/commands/dotnet-test/TestApplication.cs +++ b/src/Cli/dotnet/commands/dotnet-test/TestApplication.cs @@ -105,7 +105,7 @@ private Task OnRequest(IRequest request) { OnHandshakeInfo(handshakeInfo); - return Task.FromResult((IResponse)CreateHandshakeInfo()); + return Task.FromResult((IResponse)CreateHandshakeInfo(GetSupportedProtocolVersion(handshakeInfo))); } break; @@ -155,14 +155,27 @@ private Task OnRequest(IRequest request) return Task.FromResult((IResponse)VoidResponse.CachedInstance); } - private static HandshakeInfo CreateHandshakeInfo() => + private static string GetSupportedProtocolVersion(HandshakeInfo handshakeInfo) + { + handshakeInfo.Properties.TryGetValue(HandshakeInfoPropertyNames.SupportedProtocolVersions, out string protocolVersions); + + string version = string.Empty; + if (protocolVersions is not null && protocolVersions.Split(";").Contains(ProtocolConstants.Version)) + { + version = ProtocolConstants.Version; + } + + return version; + } + + private static HandshakeInfo CreateHandshakeInfo(string version) => new(new Dictionary { { HandshakeInfoPropertyNames.PID, Process.GetCurrentProcess().Id.ToString() }, { HandshakeInfoPropertyNames.Architecture, RuntimeInformation.OSArchitecture.ToString() }, { HandshakeInfoPropertyNames.Framework, RuntimeInformation.FrameworkDescription }, { HandshakeInfoPropertyNames.OS, RuntimeInformation.OSDescription }, - { HandshakeInfoPropertyNames.ProtocolVersion, ProtocolConstants.Version } + { HandshakeInfoPropertyNames.SupportedProtocolVersions, version } }); private async Task StartProcess(ProcessStartInfo processStartInfo) diff --git a/src/Cli/dotnet/commands/dotnet-test/TestingPlatformCommand.cs b/src/Cli/dotnet/commands/dotnet-test/TestingPlatformCommand.cs index 379a0889714c..222004503de1 100644 --- a/src/Cli/dotnet/commands/dotnet-test/TestingPlatformCommand.cs +++ b/src/Cli/dotnet/commands/dotnet-test/TestingPlatformCommand.cs @@ -183,14 +183,14 @@ private void OnTestResultReceived(object sender, EventArgs args) { var successfulTestResultMessage = successfulTestResultEventArgs.SuccessfulTestResultMessage; VSTestTrace.SafeWriteTrace(() => $"TestResultMessage: {successfulTestResultMessage.Uid}, {successfulTestResultMessage.DisplayName}, " + - $"{successfulTestResultMessage.State}, {successfulTestResultMessage.Reason}, {successfulTestResultMessage.SessionUid}"); + $"{successfulTestResultMessage.State}, {successfulTestResultMessage.Reason}, {successfulTestResultMessage.SessionUid}, {successfulTestResultMessage.ExecutionId}"); } else if (args is FailedTestResultEventArgs failedTestResultEventArgs) { var failedTestResultMessage = failedTestResultEventArgs.FailedTestResultMessage; VSTestTrace.SafeWriteTrace(() => $"TestResultMessage: {failedTestResultMessage.Uid}, {failedTestResultMessage.DisplayName}, " + $"{failedTestResultMessage.State}, {failedTestResultMessage.Reason}, {failedTestResultMessage.ErrorMessage}," + - $" {failedTestResultMessage.ErrorStackTrace}, {failedTestResultMessage.SessionUid}"); + $" {failedTestResultMessage.ErrorStackTrace}, {failedTestResultMessage.SessionUid}, {failedTestResultMessage.ExecutionId}"); } } @@ -204,7 +204,7 @@ private void OnFileArtifactInfoReceived(object sender, FileArtifactInfoEventArgs var fileArtifactInfo = args.FileArtifactInfo; VSTestTrace.SafeWriteTrace(() => $"FileArtifactInfo: {fileArtifactInfo.FullPath}, {fileArtifactInfo.DisplayName}, " + $"{fileArtifactInfo.Description}, {fileArtifactInfo.TestUid}, {fileArtifactInfo.TestDisplayName}, " + - $"{fileArtifactInfo.SessionUid}"); + $"{fileArtifactInfo.SessionUid}, {fileArtifactInfo.ExecutionId}"); } private void OnSessionEventReceived(object sender, SessionEventArgs args) @@ -215,7 +215,7 @@ private void OnSessionEventReceived(object sender, SessionEventArgs args) } var sessionEvent = args.SessionEvent; - VSTestTrace.SafeWriteTrace(() => $"TestSessionEvent: {sessionEvent.SessionType}, {sessionEvent.SessionUid}"); + VSTestTrace.SafeWriteTrace(() => $"TestSessionEvent: {sessionEvent.SessionType}, {sessionEvent.SessionUid}, {sessionEvent.ExecutionId}"); } private void OnErrorReceived(object sender, ErrorEventArgs args)