Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/StructuredLogger.Tests/BinaryLoggerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ public void TestBinaryLoggerRoundtrip(bool useInMemoryProject)
var xml1 = GetTestFile("1.xml");
var xml2 = GetTestFile("2.xml");

build.Children.Where(c => c.TypeName == "Error").Should().BeEmpty("There should be no errors in the build");

Serialization.Write(build, xml1);

Serialization.Write(build, GetTestFile("1.buildlog"));
Expand Down
6 changes: 5 additions & 1 deletion src/StructuredLogger/BinaryLogger/BinaryLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,18 @@ public sealed class BinaryLogger : ILogger
// - Making ProjectStartedEventArgs, ProjectEvaluationFinishedEventArgs, AssemblyLoadBuildEventArgs equal
// between de/serialization roundtrips.
// - Adding serialized events lengths - to support forward compatible reading
// version 19:
// - GeneratedFileUsedEventArgs exposed for brief period of time (so let's continue with 20)
// version 20:
// - TaskStartedEventArgs: Added TaskAssemblyLocation property

// This should be never changed.
// The minimum version of the binary log reader that can read log of above version.
internal const int ForwardCompatibilityMinimalVersion = 18;

// The current version of the binary log representation.
// Changes with each update of the binary log format.
internal const int FileFormatVersion = 18;
internal const int FileFormatVersion = 20;
// The minimum version of the binary log reader that can read log of above version.
// This should be changed only when the binary log format is changed in a way that would prevent it from being
// read by older readers. (changing of the individual BuildEventArgs or adding new is fine - as reader can
Expand Down
2 changes: 2 additions & 0 deletions src/StructuredLogger/BinaryLogger/BuildEventArgsReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,7 @@ private BuildEventArgs ReadTaskStartedEventArgs()
var taskName = ReadOptionalString();
var projectFile = ReadOptionalString();
var taskFile = ReadOptionalString();
var taskAssemblyLocation = _fileFormatVersion >= 20 ? ReadOptionalString() : null;

string message = fields.Message;
if (_fileFormatVersion >= 13)
Expand All @@ -926,6 +927,7 @@ private BuildEventArgs ReadTaskStartedEventArgs()
fields.Timestamp);
e.LineNumber = fields.LineNumber;
e.ColumnNumber = fields.ColumnNumber;
e.TaskAssemblyLocation = taskAssemblyLocation;
SetCommonFields(e, fields);
return e;
}
Expand Down
5 changes: 4 additions & 1 deletion src/StructuredLogger/BinaryLogger/BuildEventArgsWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,9 @@ private BinaryLogRecordKind Write(TaskStartedEventArgs e)
WriteDeduplicatedString(e.TaskName);
WriteDeduplicatedString(e.ProjectFile);
WriteDeduplicatedString(e.TaskFile);
WriteDeduplicatedString(e is TaskStartedEventArgs2 taskStarted2 ?
taskStarted2.TaskAssemblyLocation :
null);

return BinaryLogRecordKind.TaskStarted;
}
Expand Down Expand Up @@ -792,7 +795,7 @@ private static BuildEventArgsFieldFlags GetBuildEventArgsFieldFlags(BuildEventAr

// We're only going to write the arguments for messages,
// warnings and errors. Only set the flag for these.
if (e is LazyFormattedBuildEventArgs lazy && Reflector.GetArguments(lazy) is { Length: > 0} &&
if (e is LazyFormattedBuildEventArgs lazy && Reflector.GetArguments(lazy) is { Length: > 0 } &&
(e is BuildMessageEventArgs or BuildWarningEventArgs or BuildErrorEventArgs))
{
flags |= BuildEventArgsFieldFlags.Arguments;
Expand Down
3 changes: 2 additions & 1 deletion src/StructuredLogger/BinaryLogger/TaskStartedEventArgs2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ public TaskStartedEventArgs2(
// the properties in the base class have an internal setter
public new int LineNumber { get; set; }
public new int ColumnNumber { get; set; }
public string TaskAssemblyLocation { get; set; }
}
}
}
4 changes: 3 additions & 1 deletion src/StructuredLogger/Construction/Construction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,9 @@ private Task CreateTask(TaskStartedEventArgs taskStartedEventArgs)
{
var taskName = Intern(taskStartedEventArgs.TaskName);

string assembly = GetTaskAssembly(taskName);
string assembly = taskStartedEventArgs is TaskStartedEventArgs2 taskStartedEventArgs2 && !string.IsNullOrEmpty(taskStartedEventArgs2.TaskAssemblyLocation) ?
taskStartedEventArgs2.TaskAssemblyLocation :
GetTaskAssembly(taskName);

var taskId = taskStartedEventArgs.BuildEventContext.TaskId;
var startTime = taskStartedEventArgs.Timestamp;
Expand Down