From 645e8e3c29a2a78372ffa79e83bc37c3c803177a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Thu, 30 Jun 2022 11:25:35 +0200 Subject: [PATCH 1/3] Upgrade to Newtonsoft.Json 13.0.1 (#3815) --- eng/Versions.props | 2 +- .../Microsoft.TestPlatform.Protocol.csproj | 2 +- scripts/build.ps1 | 5 ++-- scripts/build.sh | 3 ++- scripts/build/TestPlatform.Dependencies.props | 2 +- .../JsonDataSerializer.cs | 23 +++++++++++------ .../Serialization/TestCaseConverter.cs | 24 +++++++++++++++--- .../Serialization/TestObjectConverter.cs | 21 ++++++++++------ .../Serialization/TestResultConverter.cs | 25 +++++++++++-------- .../TestRunStatisticsConverter.cs | 4 +-- ...taCollectorAttachmentProcessorAppDomain.cs | 3 ++- ...DataCollectorAttachmentProcessorWrapper.cs | 2 +- .../Resources/xlf/Resources.cs.xlf | 2 +- .../Resources/xlf/Resources.de.xlf | 2 +- .../Resources/xlf/Resources.ru.xlf | 2 +- .../Resources/xlf/Resources.zh-Hans.xlf | 2 +- .../Resources/xlf/Resources.zh-Hant.xlf | 2 +- .../Hosting/DotnetTestHostManager.cs | 4 +-- src/package/ThirdPartyNotices.txt | 2 +- src/testhost.arm64/app.config | 7 +++++- src/testhost.x86/app.config | 5 ++++ src/testhost/app.config | 7 +++++- src/vstest.console/app.config | 7 +++++- .../DotnetArchitectureSwitchTests.Windows.cs | 2 +- .../JsonDataSerializerTests.cs | 2 +- .../TestCaseSerializationTests.cs | 2 +- .../Serialization/TestObjectConverterTests.cs | 2 +- .../TestResultSerializationTests.cs | 2 +- .../Client/DiscoveryCriteriaTests.cs | 2 +- .../ProtocolV1Tests.cs | 2 +- .../ProtocolV2Tests.cs | 2 +- .../DotnetHostArchitectureVerifierTests.cs | 2 +- .../Hosting/DotnetTestHostManagerTests.cs | 10 ++++---- .../NewtonSoftDependency/App.config | 2 +- .../NewtonSoftDependency.csproj | 4 ++- 35 files changed, 126 insertions(+), 66 deletions(-) diff --git a/eng/Versions.props b/eng/Versions.props index 81210565d2..15f3098424 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -38,7 +38,7 @@ 4.16.1 5.3.0.1 2.3.0 - 9.0.1 + 13.0.1 4.6.0-preview4.19202.2 4.4.0 5.3.0 diff --git a/samples/Microsoft.TestPlatform.Protocol/Microsoft.TestPlatform.Protocol.csproj b/samples/Microsoft.TestPlatform.Protocol/Microsoft.TestPlatform.Protocol.csproj index fe32a2b77e..98c4134b0c 100644 --- a/samples/Microsoft.TestPlatform.Protocol/Microsoft.TestPlatform.Protocol.csproj +++ b/samples/Microsoft.TestPlatform.Protocol/Microsoft.TestPlatform.Protocol.csproj @@ -11,6 +11,6 @@ - + \ No newline at end of file diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 4c87d1d505..c9b9cea075 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -641,11 +641,12 @@ function Publish-Package { } # Copy dependency of Microsoft.TestPlatform.TestHostRuntimeProvider - $newtonsoft = Join-Path $env:TP_PACKAGES_DIR "newtonsoft.json\9.0.1\lib\net45\Newtonsoft.Json.dll" + $newtonsoftJsonVersion = ([xml](Get-Content $env:TP_ROOT_DIR\eng\Versions.props)).Project.PropertyGroup.NewtonsoftJsonVersion + $newtonsoft = Join-Path $env:TP_PACKAGES_DIR "newtonsoft.json\$newtonsoftJsonVersion\lib\net45\Newtonsoft.Json.dll" Write-Verbose "Copy-Item $newtonsoft $fullCLRPackage451Dir -Force" Copy-Item $newtonsoft $fullCLRPackage451Dir -Force - $newtonsoft = Join-Path $env:TP_PACKAGES_DIR "newtonsoft.json\9.0.1\lib\netstandard1.0\Newtonsoft.Json.dll" + $newtonsoft = Join-Path $env:TP_PACKAGES_DIR "newtonsoft.json\$newtonsoftJsonVersion\lib\netstandard1.0\Newtonsoft.Json.dll" Write-Verbose "Copy-Item $newtonsoft $coreCLR20PackageDir -Force" Copy-Item $newtonsoft $coreCLR20PackageDir -Force diff --git a/scripts/build.sh b/scripts/build.sh index 95114c2c24..329a71cdfd 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -150,6 +150,7 @@ TPB_LocalizedBuild=$DISABLE_LOCALIZED_BUILD TPB_Verbose=$VERBOSE TPB_EXTERNALS_VERSION=$(grep TestPlatformExternalsVersion $TP_ROOT_DIR/scripts/build/TestPlatform.Dependencies.props | head -1 | cut -d'>' -f2 | cut -d'<' -f1 || echo $VERSION) TPB_CC_EXTERNALS_VERSION=$(grep MicrosoftInternalCodeCoverageVersion $TP_ROOT_DIR/eng/Versions.props | head -1 | cut -d'>' -f2 | cut -d'<' -f1 || echo $VERSION) +TPB_NEWTONSOFT_JSON_VERSION=$(grep NewtonsoftJsonVersion $TP_ROOT_DIR/eng/Versions.props | head -1 | cut -d'>' -f2 | cut -d'<' -f1 || echo $VERSION) TPB_BRANCH="$(git -C "." rev-parse --abbrev-ref HEAD 2>/dev/null)" || TPB_BRANCH="LOCALBRANCH" # detached HEAD TPB_COMMIT="$(git -C "." rev-parse HEAD 2>/dev/null)" || TPB_COMMIT="LOCALBUILD" # detached HEAD @@ -436,7 +437,7 @@ function publish_package() done #*************************************************************************************************************# - newtonsoft=$TP_PACKAGES_DIR/newtonsoft.json/9.0.1/lib/netstandard1.0/Newtonsoft.Json.dll + newtonsoft=$TP_PACKAGES_DIR/newtonsoft.json/$TPB_NEWTONSOFT_JSON_VERSION/lib/netstandard1.0/Newtonsoft.Json.dll cp $newtonsoft $packageDir done diff --git a/scripts/build/TestPlatform.Dependencies.props b/scripts/build/TestPlatform.Dependencies.props index bd1aaaf5a4..f0f6bbd02a 100644 --- a/scripts/build/TestPlatform.Dependencies.props +++ b/scripts/build/TestPlatform.Dependencies.props @@ -57,7 +57,7 @@ 5.11.0 5.0.0 - 9.0.1 + 13.0.1 17.3.0-preview-2-32502-021 diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/JsonDataSerializer.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/JsonDataSerializer.cs index bc140ce8bc..a7a623b2e9 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/JsonDataSerializer.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/JsonDataSerializer.cs @@ -96,7 +96,7 @@ public Message DeserializeMessage(string rawMessage) // PERF: This is slow, we deserialize the message, and the payload into JToken just to get the header. We then // deserialize the data from the JToken, but that is twice as expensive as deserializing the whole object directly into the final object type. // We need this for backward compatibility though. - return Deserialize(rawMessage); + return Deserialize(rawMessage)!; } // PERF: Try grabbing the version and message type from the string directly, we are pretty certain how the message is serialized @@ -105,7 +105,7 @@ public Message DeserializeMessage(string rawMessage) { // PERF: If the fast path fails, deserialize into header object that does not have any Payload. When the message type info // is at the start of the message, this is also pretty fast. Again, this won't touch the payload. - MessageHeader header = JsonConvert.DeserializeObject(rawMessage, JsonSettings); + MessageHeader header = JsonConvert.DeserializeObject(rawMessage, JsonSettings)!; version = header.Version; messageType = header.MessageType; } @@ -161,13 +161,19 @@ public Message DeserializeMessage(string rawMessage) var messageWithRawMessage = (VersionedMessageWithRawMessage)message; var rawMessage = messageWithRawMessage.RawMessage; + if (rawMessage == null) + { + return default; + } + // The deserialized message can still have a version (0 or 1), that should use the old deserializer if (payloadSerializer == PayloadSerializerV2) { // PERF: Fast path is compatibile only with protocol versions that use serializer_2, // and this is faster than deserializing via deserializer_2. var messageWithPayload = JsonConvert.DeserializeObject>(rawMessage, FastJsonSettings); - return messageWithPayload.Payload; + + return messageWithPayload == null ? default : messageWithPayload.Payload; } else { @@ -175,7 +181,7 @@ public Message DeserializeMessage(string rawMessage) // This is still better than deserializing the JToken in DeserializeMessage because here we know that the payload // will actually be used. TPDebug.Assert(rawMessage is not null, "rawMessage should not be null"); - var rawMessagePayload = Deserialize(rawMessage).Payload; + var rawMessagePayload = Deserialize(rawMessage)?.Payload; TPDebug.Assert(rawMessagePayload is not null, "rawMessagePayload should not be null"); return Deserialize(payloadSerializer, rawMessagePayload); } @@ -286,7 +292,7 @@ private static bool TryGetSubstringUntilDelimiter(string rawMessage, int start, /// Version of serializer to be used. /// Target type to deserialize. /// An instance of . - public T Deserialize(string json, int version = 1) + public T? Deserialize(string json, int version = 1) { var payloadSerializer = GetPayloadSerializer(version); return Deserialize(payloadSerializer, json); @@ -327,6 +333,9 @@ public string SerializePayload(string? messageType, object? payload, int version // so when we resolved the old serializer we should use non-fast path. if (DisableFastJson || payloadSerializer == PayloadSerializerV1) { + if (payload == null) + return string.Empty; + var serializedPayload = JToken.FromObject(payload, payloadSerializer); return version > 1 ? @@ -387,7 +396,7 @@ private static string Serialize(JsonSerializer serializer, T data) /// Serializer. /// Data to be deserialized. /// Deserialized data. - private static T Deserialize(JsonSerializer serializer, string data) + private static T? Deserialize(JsonSerializer serializer, string data) { using var stringReader = new StringReader(data); using var jsonReader = new JsonTextReader(stringReader); @@ -403,7 +412,7 @@ private static T Deserialize(JsonSerializer serializer, string data) /// Deserialized data. private static T Deserialize(JsonSerializer serializer, JToken jToken) { - return jToken.ToObject(serializer); + return jToken.ToObject(serializer)!; } private static JsonSerializer GetPayloadSerializer(int? version) diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestCaseConverter.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestCaseConverter.cs index c6f2d5b30a..dfab1947d5 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestCaseConverter.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestCaseConverter.cs @@ -22,7 +22,7 @@ public override bool CanConvert(Type objectType) } /// - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) { var testCase = new TestCase(); @@ -38,11 +38,22 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist // key value pairs. foreach (var property in properties.Values()) { - var testProperty = property["Key"].ToObject(serializer); + var testProperty = property?["Key"]?.ToObject(serializer); + + if (testProperty == null) + { + return null; + } // Let the null values be passed in as null data - var token = property["Value"]; + var token = property?["Value"]; string? propertyData = null; + + if (token == null) + { + return null; + } + if (token.Type != JTokenType.Null) { // If the property is already a string. No need to convert again. @@ -86,8 +97,13 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist } /// - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) { + if (value == null) + { + return; + } + // P2 to P1 var testCase = (TestCase)value; diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestObjectConverter.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestObjectConverter.cs index 2d37268fae..5d6bf81035 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestObjectConverter.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestObjectConverter.cs @@ -30,7 +30,7 @@ public override bool CanConvert(Type objectType) } /// - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + public override object ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) { if (objectType != typeof(List>)) { @@ -55,12 +55,17 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist // key value pairs. foreach (var property in properties) { - var testProperty = property["Key"].ToObject(serializer); + var testProperty = property?["Key"]?.ToObject(serializer); + + if (testProperty == null) + { + continue; + } // Let the null values be passed in as null data - var token = property["Value"]; + var token = property?["Value"]; object? propertyData = null; - if (token.Type != JTokenType.Null) + if (token != null && token.Type != JTokenType.Null) { // If the property is already a string. No need to convert again. if (token.Type == JTokenType.String) @@ -82,7 +87,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist } /// - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) { // Create an array of dictionary } @@ -122,7 +127,7 @@ public override bool CanConvert(Type objectType) } /// - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + public override object ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) { if (objectType != typeof(List>)) { @@ -135,7 +140,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist return new List>(); } - var deserializedProperties = serializer.Deserialize>>(reader); + var deserializedProperties = serializer.Deserialize>>(reader)!; // Initialize the list capacity to be the number of properties we might add. var propertyList = new List>(deserializedProperties.Count); @@ -177,7 +182,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist } /// - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) { // Create an array of dictionary } diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestResultConverter.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestResultConverter.cs index 1fa361fef8..3ec65e3500 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestResultConverter.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestResultConverter.cs @@ -22,11 +22,11 @@ public override bool CanConvert(Type objectType) } /// - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + public override object ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) { var data = JObject.Load(reader); - var testCase = data["TestCase"].ToObject(serializer); + var testCase = data["TestCase"]!.ToObject(serializer)!; var testResult = new TestResult(testCase); // Add attachments for the result @@ -35,9 +35,9 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist { foreach (var attachment in attachments.Values()) { - if (attachment.Type != JTokenType.Null) + if (attachment!.Type != JTokenType.Null) { - testResult.Attachments.Add(attachment.ToObject(serializer)); + testResult.Attachments.Add(attachment!.ToObject(serializer)!); } } } @@ -48,14 +48,14 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist { foreach (var message in messages.Values()) { - if (message.Type != JTokenType.Null) + if (message!.Type != JTokenType.Null) { - testResult.Messages.Add(message.ToObject(serializer)); + testResult.Messages.Add(message.ToObject(serializer)!); } } } - JToken properties = data["Properties"]; + JToken properties = data["Properties"]!; if (properties == null || !properties.HasValues) { return testResult; @@ -65,12 +65,12 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist // key value pairs. foreach (var property in properties.Values()) { - var testProperty = property["Key"].ToObject(serializer); + var testProperty = property!["Key"]!.ToObject(serializer)!; // Let the null values be passed in as null data var token = property["Value"]; string? propertyData = null; - if (token.Type != JTokenType.Null) + if (token!.Type != JTokenType.Null) { // If the property is already a string. No need to convert again. if (token.Type == JTokenType.String) @@ -115,8 +115,13 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist } /// - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) { + if (value == null) + { + return; + } + // P2 to P1 var testResult = (TestResult)value; diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestRunStatisticsConverter.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestRunStatisticsConverter.cs index 05a03fdf57..c9fba0eb44 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestRunStatisticsConverter.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestRunStatisticsConverter.cs @@ -21,13 +21,13 @@ public override bool CanConvert(Type objectType) } /// - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) { return serializer.Deserialize(reader); } /// - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) { serializer.Serialize(writer, value); } diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/AttachmentsProcessing/DataCollectorAttachmentProcessorAppDomain.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/AttachmentsProcessing/DataCollectorAttachmentProcessorAppDomain.cs index 4c78f33fb9..3ac0618b76 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/AttachmentsProcessing/DataCollectorAttachmentProcessorAppDomain.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/AttachmentsProcessing/DataCollectorAttachmentProcessorAppDomain.cs @@ -157,7 +157,8 @@ public async Task> ProcessAttachmentSetsAsync(XmlElem cancellationToken.Register(() => _wrapper.CancelProcessAttachment()); _processAttachmentSetsLogger = logger; _progressReporter = progressReporter; - return JsonDataSerializer.Instance.Deserialize(await Task.Run(() => _wrapper.ProcessAttachment(configurationElement.OuterXml, JsonDataSerializer.Instance.Serialize(attachments.ToArray()))).ConfigureAwait(false)); + var result = await Task.Run(() => _wrapper.ProcessAttachment(configurationElement.OuterXml, JsonDataSerializer.Instance.Serialize(attachments.ToArray()))).ConfigureAwait(false); + return JsonDataSerializer.Instance.Deserialize(result)!; } public void Dispose() diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/AttachmentsProcessing/DataCollectorAttachmentProcessorWrapper.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/AttachmentsProcessing/DataCollectorAttachmentProcessorWrapper.cs index 7858a5293b..773026148f 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/AttachmentsProcessing/DataCollectorAttachmentProcessorWrapper.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/AttachmentsProcessing/DataCollectorAttachmentProcessorWrapper.cs @@ -62,7 +62,7 @@ public DataCollectorAttachmentProcessorRemoteWrapper(string pipeShutdownMessageP { var doc = new XmlDocument(); doc.LoadXml(configurationElement); - AttachmentSet[] attachmentSets = JsonDataSerializer.Instance.Deserialize(attachments); + AttachmentSet[] attachmentSets = JsonDataSerializer.Instance.Deserialize(attachments)!; SynchronousProgress progress = new(Report); _processAttachmentCts = new CancellationTokenSource(); diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.cs.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.cs.xlf index f046e6a9d6..6ce331df99 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.cs.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.cs.xlf @@ -189,4 +189,4 @@ - + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.de.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.de.xlf index 166cebad19..b28ec035e0 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.de.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.de.xlf @@ -189,4 +189,4 @@ - + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ru.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ru.xlf index 50021e2125..caef05539b 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ru.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ru.xlf @@ -189,4 +189,4 @@ - + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hans.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hans.xlf index 83546bb429..6607b5fe80 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hans.xlf @@ -189,4 +189,4 @@ - + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hant.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hant.xlf index 8ac04fed92..5074bc573d 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hant.xlf @@ -189,4 +189,4 @@ - + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs b/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs index 155db28c54..062a5ae6e5 100644 --- a/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs +++ b/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs @@ -765,8 +765,8 @@ private string GetTestHostPath(string runtimeConfigDevPath, string depsFilePath, using (JsonTextReader reader = new(file)) { JObject context = (JObject)JToken.ReadFrom(reader); - JObject runtimeOptions = (JObject)context.GetValue("runtimeOptions"); - JToken additionalProbingPaths = runtimeOptions.GetValue("additionalProbingPaths"); + JObject runtimeOptions = (JObject)context.GetValue("runtimeOptions")!; + JToken additionalProbingPaths = runtimeOptions.GetValue("additionalProbingPaths")!; foreach (var x in additionalProbingPaths) { EqtTrace.Verbose("DotnetTestHostmanager: Looking for path {0} in folder {1}", testHostPath, x.ToString()); diff --git a/src/package/ThirdPartyNotices.txt b/src/package/ThirdPartyNotices.txt index 8efcee2fa8..4c85ae8285 100644 --- a/src/package/ThirdPartyNotices.txt +++ b/src/package/ThirdPartyNotices.txt @@ -8,7 +8,7 @@ and the licenses under which Microsoft received such components are set forth be informational purposes only. Microsoft reserves all rights not expressly granted herein, whether by implication, estoppel or otherwise. -1. Newtonsoft version 9.0.1 (https://github.com/JamesNK/Newtonsoft.Json) +1. Newtonsoft version 13.0.1 (https://github.com/JamesNK/Newtonsoft.Json) 2. Mono.Cecil version 0.11.3 (https://github.com/jbevain/cecil) diff --git a/src/testhost.arm64/app.config b/src/testhost.arm64/app.config index 2a67681b5e..e889aff770 100644 --- a/src/testhost.arm64/app.config +++ b/src/testhost.arm64/app.config @@ -46,6 +46,11 @@ + + + + + @@ -61,4 +66,4 @@ - \ No newline at end of file + diff --git a/src/testhost.x86/app.config b/src/testhost.x86/app.config index 254425ccbe..a7be49fb01 100644 --- a/src/testhost.x86/app.config +++ b/src/testhost.x86/app.config @@ -46,6 +46,11 @@ + + + + + diff --git a/src/testhost/app.config b/src/testhost/app.config index 2a67681b5e..e889aff770 100644 --- a/src/testhost/app.config +++ b/src/testhost/app.config @@ -46,6 +46,11 @@ + + + + + @@ -61,4 +66,4 @@ - \ No newline at end of file + diff --git a/src/vstest.console/app.config b/src/vstest.console/app.config index e6f209a541..bbc2c9a12b 100644 --- a/src/vstest.console/app.config +++ b/src/vstest.console/app.config @@ -20,6 +20,11 @@ + + + + + @@ -54,4 +59,4 @@ --> - \ No newline at end of file + diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/DotnetArchitectureSwitchTests.Windows.cs b/test/Microsoft.TestPlatform.AcceptanceTests/DotnetArchitectureSwitchTests.Windows.cs index f07623f621..1e65859ebd 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/DotnetArchitectureSwitchTests.Windows.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/DotnetArchitectureSwitchTests.Windows.cs @@ -33,7 +33,7 @@ public void Use_EnvironmentVariables(string architectureFrom, string architectur string sdkVersion = GetLatestSdkVersion(dotnetPath); string runtimeConfigFile = Path.Combine(dotnetRunnerPath.FullName, "vstest.console.runtimeconfig.json"); JObject patchRuntimeConfig = JObject.Parse(File.ReadAllText(runtimeConfigFile)); - patchRuntimeConfig["runtimeOptions"]["framework"]["version"] = sdkVersion; + patchRuntimeConfig!["runtimeOptions"]!["framework"]!["version"] = sdkVersion; File.WriteAllText(runtimeConfigFile, patchRuntimeConfig.ToString()); var environmentVariables = new Dictionary diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/JsonDataSerializerTests.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/JsonDataSerializerTests.cs index 9743127b79..b69773b62e 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/JsonDataSerializerTests.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/JsonDataSerializerTests.cs @@ -80,7 +80,7 @@ public void DeserializeShouldDeserializeAnObjectWhichHadSelfReferencingLoopBefor var json = _jsonDataSerializer.SerializePayload("dummy", classWithSelfReferencingLoop); // This line should deserialize properly - var result = _jsonDataSerializer.Deserialize(json, 1); + var result = _jsonDataSerializer.Deserialize(json, 1)!; Assert.AreEqual(typeof(ClassWithSelfReferencingLoop), result.GetType()); Assert.IsNull(result.InfiniteRefernce); diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TestCaseSerializationTests.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TestCaseSerializationTests.cs index 97fd73d599..23ce72f4d0 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TestCaseSerializationTests.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TestCaseSerializationTests.cs @@ -260,7 +260,7 @@ private static string Serialize(T data, int version = 1) private static T Deserialize(string json, int version = 1) { - return JsonDataSerializer.Instance.Deserialize(json, version); + return JsonDataSerializer.Instance.Deserialize(json, version)!; } private void VerifyDummyPropertyIsRegistered() diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TestObjectConverterTests.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TestObjectConverterTests.cs index 70a7a7cf80..8ea98a42e1 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TestObjectConverterTests.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TestObjectConverterTests.cs @@ -164,6 +164,6 @@ private static string Serialize(T data) private static T Deserialize(string json) { - return JsonDataSerializer.Instance.Deserialize(json); + return JsonDataSerializer.Instance.Deserialize(json)!; } } diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TestResultSerializationTests.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TestResultSerializationTests.cs index 21903d3da9..087c01c46e 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TestResultSerializationTests.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TestResultSerializationTests.cs @@ -296,7 +296,7 @@ private static string Serialize(T data, int version) private static T Deserialize(string json, int version) { - return JsonDataSerializer.Instance.Deserialize(json, version); + return JsonDataSerializer.Instance.Deserialize(json, version)!; } private static void VerifyDummyPropertyIsRegistered() diff --git a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Client/DiscoveryCriteriaTests.cs b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Client/DiscoveryCriteriaTests.cs index 513fbd21b2..7041273030 100644 --- a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Client/DiscoveryCriteriaTests.cs +++ b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Client/DiscoveryCriteriaTests.cs @@ -44,7 +44,7 @@ public void DiscoveryCriteriaShouldBeDeserializable() { var json = "{\"Sources\":[\"sampleTest.dll\"],\"AdapterSourceMap\":{\"_none_\":[\"sampleTest.dll\"]},\"FrequencyOfDiscoveredTestsEvent\":100,\"DiscoveredTestEventTimeout\":\"10675199.02:48:05.4775807\",\"RunSettings\":\"\",\"TestCaseFilter\":\"TestFilter\"}"; - var criteria = JsonConvert.DeserializeObject(json, Settings); + var criteria = JsonConvert.DeserializeObject(json, Settings)!; Assert.AreEqual(TimeSpan.MaxValue, criteria.DiscoveredTestEventTimeout); Assert.AreEqual(100, criteria.FrequencyOfDiscoveredTestsEvent); diff --git a/test/Microsoft.TestPlatform.PerformanceTests/ProtocolV1Tests.cs b/test/Microsoft.TestPlatform.PerformanceTests/ProtocolV1Tests.cs index 58eeca5cc9..fd39dc11f1 100644 --- a/test/Microsoft.TestPlatform.PerformanceTests/ProtocolV1Tests.cs +++ b/test/Microsoft.TestPlatform.PerformanceTests/ProtocolV1Tests.cs @@ -121,6 +121,6 @@ private static string SerializeV1(T data) private static T DeserializeV1(string json) { - return JsonDataSerializer.Instance.Deserialize(json, version: 1); + return JsonDataSerializer.Instance.Deserialize(json, version: 1)!; } } diff --git a/test/Microsoft.TestPlatform.PerformanceTests/ProtocolV2Tests.cs b/test/Microsoft.TestPlatform.PerformanceTests/ProtocolV2Tests.cs index 5a9eacf09a..a474c81ac3 100644 --- a/test/Microsoft.TestPlatform.PerformanceTests/ProtocolV2Tests.cs +++ b/test/Microsoft.TestPlatform.PerformanceTests/ProtocolV2Tests.cs @@ -118,6 +118,6 @@ private static string SerializeV2(T data) private static T DeserializeV2(string json) { - return JsonDataSerializer.Instance.Deserialize(json, version: 2); + return JsonDataSerializer.Instance.Deserialize(json, version: 2)!; } } diff --git a/test/Microsoft.TestPlatform.SmokeTests/DotnetHostArchitectureVerifierTests.cs b/test/Microsoft.TestPlatform.SmokeTests/DotnetHostArchitectureVerifierTests.cs index 0e8518fd9c..ef73a36798 100644 --- a/test/Microsoft.TestPlatform.SmokeTests/DotnetHostArchitectureVerifierTests.cs +++ b/test/Microsoft.TestPlatform.SmokeTests/DotnetHostArchitectureVerifierTests.cs @@ -32,7 +32,7 @@ public void VerifyHostArchitecture(string architecture) string sdkVersion = GetLatestSdkVersion(dotnetPath); string runtimeConfigFile = Path.Combine(dotnetRunnerPath.FullName, "vstest.console.runtimeconfig.json"); JObject patchRuntimeConfig = JObject.Parse(File.ReadAllText(runtimeConfigFile)); - patchRuntimeConfig["runtimeOptions"]["framework"]["version"] = sdkVersion; + patchRuntimeConfig!["runtimeOptions"]!["framework"]!["version"] = sdkVersion; File.WriteAllText(runtimeConfigFile, patchRuntimeConfig.ToString()); var environmentVariables = new Dictionary diff --git a/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DotnetTestHostManagerTests.cs b/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DotnetTestHostManagerTests.cs index 4b97c13465..c3cf1a5d7a 100644 --- a/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DotnetTestHostManagerTests.cs +++ b/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DotnetTestHostManagerTests.cs @@ -327,7 +327,7 @@ public void GetTestHostProcessStartInfoShouldUseTestHostExeFromNugetIfNotFoundIn ""microsoft.testplatform.testhost/15.0.0-Dev"": { ""dependencies"": { ""Microsoft.TestPlatform.ObjectModel"": ""15.0.0-Dev"", - ""Newtonsoft.Json"": ""9.0.1"" + ""Newtonsoft.Json"": ""13.0.1"" }, ""runtime"": { ""lib/netstandard1.5/Microsoft.TestPlatform.CommunicationUtilities.dll"": { }, @@ -397,7 +397,7 @@ public void GetTestHostProcessStartInfoShouldUseTestHostX86ExeFromNugetIfNotFoun ""microsoft.testplatform.testhost/15.0.0-Dev"": { ""dependencies"": { ""Microsoft.TestPlatform.ObjectModel"": ""15.0.0-Dev"", - ""Newtonsoft.Json"": ""9.0.1"" + ""Newtonsoft.Json"": ""13.0.1"" }, ""runtime"": { ""lib/netstandard1.5/Microsoft.TestPlatform.CommunicationUtilities.dll"": { }, @@ -735,7 +735,7 @@ public void GetTestHostProcessStartInfoShouldIncludeTestHostPathFromDepsFile() ""microsoft.testplatform.testhost/15.0.0-Dev"": { ""dependencies"": { ""Microsoft.TestPlatform.ObjectModel"": ""15.0.0-Dev"", - ""Newtonsoft.Json"": ""9.0.1"" + ""Newtonsoft.Json"": ""13.0.1"" }, ""runtime"": { ""lib/netstandard1.5/Microsoft.TestPlatform.CommunicationUtilities.dll"": { }, @@ -800,7 +800,7 @@ public void GetTestHostProcessStartInfoShouldIncludeTestHostPathFromSourceDirect ""microsoft.testplatform.testhost/15.0.0-Dev"": { ""dependencies"": { ""Microsoft.TestPlatform.ObjectModel"": ""15.0.0-Dev"", - ""Newtonsoft.Json"": ""9.0.1"" + ""Newtonsoft.Json"": ""13.0.1"" }, ""runtime"": { ""lib/netstandard1.5/Microsoft.TestPlatform.CommunicationUtilities.dll"": { }, @@ -868,7 +868,7 @@ public void GetTestHostProcessStartInfoShouldSkipInvalidAdditionalProbingPaths() ""microsoft.testplatform.testhost/15.0.0-Dev"": { ""dependencies"": { ""Microsoft.TestPlatform.ObjectModel"": ""15.0.0-Dev"", - ""Newtonsoft.Json"": ""9.0.1"" + ""Newtonsoft.Json"": ""13.0.1"" }, ""runtime"": { ""lib/netstandard1.5/Microsoft.TestPlatform.CommunicationUtilities.dll"": { }, diff --git a/test/TestAssets/NewtonSoftDependency/App.config b/test/TestAssets/NewtonSoftDependency/App.config index 776d09c68c..f71f97e6bb 100644 --- a/test/TestAssets/NewtonSoftDependency/App.config +++ b/test/TestAssets/NewtonSoftDependency/App.config @@ -4,7 +4,7 @@ - + diff --git a/test/TestAssets/NewtonSoftDependency/NewtonSoftDependency.csproj b/test/TestAssets/NewtonSoftDependency/NewtonSoftDependency.csproj index 7a30726cdf..802266e3b9 100644 --- a/test/TestAssets/NewtonSoftDependency/NewtonSoftDependency.csproj +++ b/test/TestAssets/NewtonSoftDependency/NewtonSoftDependency.csproj @@ -26,7 +26,9 @@ - + + From 914f35d3956a3004891d388810296b4318269652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Mon, 13 Feb 2023 09:20:56 +0100 Subject: [PATCH 2/3] Update versions --- eng/Versions.props | 2 +- scripts/build/TestPlatform.Dependencies.props | 2 +- scripts/build/TestPlatform.Settings.targets | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/Versions.props b/eng/Versions.props index 15f3098424..267ffd131b 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -2,7 +2,7 @@ - 17.3.1 + 17.3.2 release false diff --git a/scripts/build/TestPlatform.Dependencies.props b/scripts/build/TestPlatform.Dependencies.props index f0f6bbd02a..e2357b924b 100644 --- a/scripts/build/TestPlatform.Dependencies.props +++ b/scripts/build/TestPlatform.Dependencies.props @@ -11,7 +11,7 @@ - 17.3.1-dev + 17.3.2-dev diff --git a/scripts/build/TestPlatform.Settings.targets b/scripts/build/TestPlatform.Settings.targets index 44b6f2701f..017526dc65 100644 --- a/scripts/build/TestPlatform.Settings.targets +++ b/scripts/build/TestPlatform.Settings.targets @@ -5,7 +5,7 @@ - 17.3.1 + 17.3.2 preview true preview From a294d98a9d06eefd3ef4c91a31d0149914a7d716 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Thu, 16 Feb 2023 15:47:15 +0100 Subject: [PATCH 3/3] Move version to 17.3.3 --- eng/Versions.props | 2 +- scripts/build/TestPlatform.Dependencies.props | 2 +- scripts/build/TestPlatform.Settings.targets | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/Versions.props b/eng/Versions.props index 267ffd131b..c041a3cc92 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -2,7 +2,7 @@ - 17.3.2 + 17.3.3 release false diff --git a/scripts/build/TestPlatform.Dependencies.props b/scripts/build/TestPlatform.Dependencies.props index e2357b924b..1a76c97d11 100644 --- a/scripts/build/TestPlatform.Dependencies.props +++ b/scripts/build/TestPlatform.Dependencies.props @@ -11,7 +11,7 @@ - 17.3.2-dev + 17.3.3-dev diff --git a/scripts/build/TestPlatform.Settings.targets b/scripts/build/TestPlatform.Settings.targets index 017526dc65..a0ee0d219b 100644 --- a/scripts/build/TestPlatform.Settings.targets +++ b/scripts/build/TestPlatform.Settings.targets @@ -5,7 +5,7 @@ - 17.3.2 + 17.3.3 preview true preview