@@ -26,44 +26,31 @@ namespace HostApi;
2626[ ExcludeFromCodeCoverage ]
2727[ Target ]
2828public record BuildMessage (
29- // Event from the running command line.
3029 Output Output ,
31- // State of the build message. Defines the specifics of the build message, what information it contains.
3230 BuildMessageState State ,
33- // Associated service message.
3431 IServiceMessage ? ServiceMessage = default ,
35- // Text of the build message.
3632 string Text = "" ,
37- // Details of the build message error.
3833 string ErrorDetails = "" ,
39- // Message code of the build message.
4034 string Code = "" ,
41- // A file that is relevant to the build event.
4235 string File = "" ,
43- // Message subcategory of the build message.
4436 string Subcategory = "" ,
45- // A project that is relevant to the build event.
4637 string ProjectFile = "" ,
47- // The task that initiated the build message.
4838 string SenderName = "" ,
49- // Start position in a line of the file relevant to the build event.
5039 int ? ColumnNumber = default ,
51- // End position in a line of the file relevant to the build event.
5240 int ? EndColumnNumber = default ,
53- // First line of the file relating to the build event.
5441 int ? LineNumber = default ,
55- // Last line of the file relating to the build event.
5642 int ? EndLineNumber = default ,
57- // Importance of the build event.
5843 DotNetMessageImportance ? Importance = default )
5944{
45+ private readonly Lazy < TestResult ? > _testResult = new ( ( ) =>
46+ ServiceMessage != null && TryGetTestState ( ServiceMessage . Name , out var testState )
47+ ? CreateResult ( CreateKey ( ServiceMessage ) , ServiceMessage , testState )
48+ : default ( TestResult ? ) ) ;
49+
6050 /// <summary>
6151 /// Contains the result of test execution when <see cref="State"/> is set to <see cref="BuildMessageState.TestResult"/>.
6252 /// </summary>
63- public TestResult ? TestResult =>
64- ServiceMessage != null && TryGetTestState ( ServiceMessage . Name , out var testState )
65- ? CreateResult ( CreateKey ( ServiceMessage ) , ServiceMessage , testState )
66- : default ( TestResult ? ) ;
53+ public TestResult ? TestResult => _testResult . Value ;
6754
6855 /// <inheritdoc />
6956 public override string ToString ( ) => Text ;
0 commit comments