Skip to content

Commit c633af9

Browse files
Send supported protocol version to the testing platform (#43003)
1 parent 813d50e commit c633af9

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

Diff for: src/Cli/dotnet/commands/dotnet-test/CliConstants.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ internal static class HandshakeInfoPropertyNames
4040
internal const byte Architecture = 1;
4141
internal const byte Framework = 2;
4242
internal const byte OS = 3;
43-
internal const byte ProtocolVersion = 4;
43+
internal const byte SupportedProtocolVersions = 4;
4444
internal const byte HostType = 5;
4545
internal const byte ModulePath = 6;
4646
internal const byte ExecutionId = 7;

Diff for: src/Cli/dotnet/commands/dotnet-test/TestApplication.cs

+16-3
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private Task<IResponse> OnRequest(IRequest request)
105105
{
106106
OnHandshakeInfo(handshakeInfo);
107107

108-
return Task.FromResult((IResponse)CreateHandshakeInfo());
108+
return Task.FromResult((IResponse)CreateHandshakeInfo(GetSupportedProtocolVersion(handshakeInfo)));
109109
}
110110
break;
111111

@@ -155,14 +155,27 @@ private Task<IResponse> OnRequest(IRequest request)
155155
return Task.FromResult((IResponse)VoidResponse.CachedInstance);
156156
}
157157

158-
private static HandshakeInfo CreateHandshakeInfo() =>
158+
private static string GetSupportedProtocolVersion(HandshakeInfo handshakeInfo)
159+
{
160+
handshakeInfo.Properties.TryGetValue(HandshakeInfoPropertyNames.SupportedProtocolVersions, out string protocolVersions);
161+
162+
string version = string.Empty;
163+
if (protocolVersions is not null && protocolVersions.Split(";").Contains(ProtocolConstants.Version))
164+
{
165+
version = ProtocolConstants.Version;
166+
}
167+
168+
return version;
169+
}
170+
171+
private static HandshakeInfo CreateHandshakeInfo(string version) =>
159172
new(new Dictionary<byte, string>
160173
{
161174
{ HandshakeInfoPropertyNames.PID, Process.GetCurrentProcess().Id.ToString() },
162175
{ HandshakeInfoPropertyNames.Architecture, RuntimeInformation.OSArchitecture.ToString() },
163176
{ HandshakeInfoPropertyNames.Framework, RuntimeInformation.FrameworkDescription },
164177
{ HandshakeInfoPropertyNames.OS, RuntimeInformation.OSDescription },
165-
{ HandshakeInfoPropertyNames.ProtocolVersion, ProtocolConstants.Version }
178+
{ HandshakeInfoPropertyNames.SupportedProtocolVersions, version }
166179
});
167180

168181
private async Task<int> StartProcess(ProcessStartInfo processStartInfo)

Diff for: src/Cli/dotnet/commands/dotnet-test/TestingPlatformCommand.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,14 @@ private void OnTestResultReceived(object sender, EventArgs args)
183183
{
184184
var successfulTestResultMessage = successfulTestResultEventArgs.SuccessfulTestResultMessage;
185185
VSTestTrace.SafeWriteTrace(() => $"TestResultMessage: {successfulTestResultMessage.Uid}, {successfulTestResultMessage.DisplayName}, " +
186-
$"{successfulTestResultMessage.State}, {successfulTestResultMessage.Reason}, {successfulTestResultMessage.SessionUid}");
186+
$"{successfulTestResultMessage.State}, {successfulTestResultMessage.Reason}, {successfulTestResultMessage.SessionUid}, {successfulTestResultMessage.ExecutionId}");
187187
}
188188
else if (args is FailedTestResultEventArgs failedTestResultEventArgs)
189189
{
190190
var failedTestResultMessage = failedTestResultEventArgs.FailedTestResultMessage;
191191
VSTestTrace.SafeWriteTrace(() => $"TestResultMessage: {failedTestResultMessage.Uid}, {failedTestResultMessage.DisplayName}, " +
192192
$"{failedTestResultMessage.State}, {failedTestResultMessage.Reason}, {failedTestResultMessage.ErrorMessage}," +
193-
$" {failedTestResultMessage.ErrorStackTrace}, {failedTestResultMessage.SessionUid}");
193+
$" {failedTestResultMessage.ErrorStackTrace}, {failedTestResultMessage.SessionUid}, {failedTestResultMessage.ExecutionId}");
194194
}
195195
}
196196

@@ -204,7 +204,7 @@ private void OnFileArtifactInfoReceived(object sender, FileArtifactInfoEventArgs
204204
var fileArtifactInfo = args.FileArtifactInfo;
205205
VSTestTrace.SafeWriteTrace(() => $"FileArtifactInfo: {fileArtifactInfo.FullPath}, {fileArtifactInfo.DisplayName}, " +
206206
$"{fileArtifactInfo.Description}, {fileArtifactInfo.TestUid}, {fileArtifactInfo.TestDisplayName}, " +
207-
$"{fileArtifactInfo.SessionUid}");
207+
$"{fileArtifactInfo.SessionUid}, {fileArtifactInfo.ExecutionId}");
208208
}
209209

210210
private void OnSessionEventReceived(object sender, SessionEventArgs args)
@@ -215,7 +215,7 @@ private void OnSessionEventReceived(object sender, SessionEventArgs args)
215215
}
216216

217217
var sessionEvent = args.SessionEvent;
218-
VSTestTrace.SafeWriteTrace(() => $"TestSessionEvent: {sessionEvent.SessionType}, {sessionEvent.SessionUid}");
218+
VSTestTrace.SafeWriteTrace(() => $"TestSessionEvent: {sessionEvent.SessionType}, {sessionEvent.SessionUid}, {sessionEvent.ExecutionId}");
219219
}
220220

221221
private void OnErrorReceived(object sender, ErrorEventArgs args)

0 commit comments

Comments
 (0)