diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestResult.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestResult.cs
index 031babb579..661d7fc9fb 100644
--- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestResult.cs
+++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestResult.cs
@@ -164,17 +164,6 @@ internal sealed class TestResultErrorInfo : IXmlTestStore
[StoreXmlSimpleField("StackTrace", "")]
private string stackTrace;
- ///
- /// Initializes a new instance of the class.
- ///
- ///
- /// The message.
- ///
- public TestResultErrorInfo(string message)
- {
- Debug.Assert(message != null, "message is null");
- this.message = message;
- }
///
/// Gets or sets the message.
@@ -370,8 +359,14 @@ public TestResultId Id
///
public string ErrorMessage
{
- get { return (this.errorInfo == null) ? string.Empty : this.errorInfo.Message; }
- set { this.errorInfo = new TestResultErrorInfo(value); }
+ get { return this.errorInfo?.Message ?? string.Empty; }
+ set
+ {
+ if (this.errorInfo == null)
+ this.errorInfo = new TestResultErrorInfo();
+
+ this.errorInfo.Message = value;
+ }
}
///
@@ -379,11 +374,13 @@ public string ErrorMessage
///
public string ErrorStackTrace
{
- get { return (this.errorInfo == null) ? string.Empty : this.errorInfo.StackTrace; }
+ get { return this.errorInfo?.StackTrace ?? string.Empty; }
set
{
- Debug.Assert(this.errorInfo != null, "errorInfo is null");
+ if (this.errorInfo == null)
+ this.errorInfo = new TestResultErrorInfo();
+
this.errorInfo.StackTrace = value;
}
}