diff --git a/eng/Versions.props b/eng/Versions.props
index de4504d99f..b9a89ae3ea 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -2,7 +2,7 @@
- 17.3.2
+ 17.3.3
release
false
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..1a76c97d11 100644
--- a/scripts/build/TestPlatform.Dependencies.props
+++ b/scripts/build/TestPlatform.Dependencies.props
@@ -11,7 +11,7 @@
- 17.3.1-dev
+ 17.3.3-dev
@@ -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/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
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 @@