Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ public static TestNode ToTestNode(

testNode.Properties.Add(new TimingProperty(new(testResult.StartTime, testResult.EndTime, testResult.Duration), []));

var standardErrorMessages = new List<string>();
var standardOutputMessages = new List<string>();
List<string>? standardErrorMessages = null;
List<string>? standardOutputMessages = null;
bool addVSTestProviderProperties = ShouldAddVSTestProviderProperties(namedFeatureCapability, commandLineOptions);
foreach (TestResultMessage testResultMessage in testResult.Messages)
{
Expand All @@ -194,7 +194,7 @@ public static TestNode ToTestNode(
testNode.Properties.Add(new SerializableKeyValuePairStringProperty("vstest.TestCase.StandardError", message));
}

standardErrorMessages.Add(message);
(standardErrorMessages ??= []).Add(message);
}

if (testResultMessage.Category == TestResultMessage.StandardOutCategory)
Expand All @@ -205,7 +205,7 @@ public static TestNode ToTestNode(
testNode.Properties.Add(new SerializableKeyValuePairStringProperty("vstest.TestCase.StandardOutput", message));
}

standardOutputMessages.Add(message);
(standardOutputMessages ??= []).Add(message);
}
}

Expand All @@ -217,12 +217,12 @@ public static TestNode ToTestNode(
}
}

if (standardErrorMessages.Count > 0)
if (standardErrorMessages is { Count: > 0 })
{
testNode.Properties.Add(new StandardErrorProperty(string.Join(Environment.NewLine, standardErrorMessages)));
}

if (standardOutputMessages.Count > 0)
if (standardOutputMessages is { Count: > 0 })
{
testNode.Properties.Add(new StandardOutputProperty(string.Join(Environment.NewLine, standardOutputMessages)));
}
Expand Down