From 861846b513c94f128fdbb03f5e1da8a879d719dd Mon Sep 17 00:00:00 2001 From: Jan Krivanek Date: Wed, 10 Jan 2024 21:53:48 +0100 Subject: [PATCH] Fix the read global properties backcompat issue --- .../BinaryLogger/BuildEventArgsReader.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/StructuredLogger/BinaryLogger/BuildEventArgsReader.cs b/src/StructuredLogger/BinaryLogger/BuildEventArgsReader.cs index 32462e7b..7c5c4e90 100644 --- a/src/StructuredLogger/BinaryLogger/BuildEventArgsReader.cs +++ b/src/StructuredLogger/BinaryLogger/BuildEventArgsReader.cs @@ -724,7 +724,12 @@ private BuildEventArgs ReadProjectEvaluationFinishedEventArgs() if (_fileFormatVersion >= 12) { IEnumerable globalProperties = null; - if (ReadBoolean()) + // In newer versions, we store the global properties always, as it handles + // null and empty within WriteProperties already. + // This saves a single boolean, but mainly doesn't hide the difference between null and empty + // during write->read roundtrip. + if (_fileFormatVersion >= BinaryLogger.ForwardCompatibilityMinimalVersion || + ReadBoolean()) { globalProperties = ReadStringDictionary(); } @@ -778,12 +783,12 @@ private BuildEventArgs ReadProjectStartedEventArgs() if (_fileFormatVersion > 6) { - if (_fileFormatVersion < BinaryLogger.ForwardCompatibilityMinimalVersion) + // See ReadProjectEvaluationFinishedEventArgs for details on why we always store global properties in newer version. + if (_fileFormatVersion >= BinaryLogger.ForwardCompatibilityMinimalVersion || + ReadBoolean()) { - // Throw away, but need to advance past it - ReadBoolean(); + globalProperties = ReadStringDictionary(); } - globalProperties = ReadStringDictionary(); } var propertyList = ReadPropertyList();