RAR node: Refactor LogMessagePacketBase to remove Microsoft.Build dep… #12526
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
LogMessagePacketBase
provides a type-safe way to wrapBuildEventArgs
into a node packet for IPC serialization.For the RAR node to replay log events, it makes sense to reuse existing serialization wrappers instead of introducing another shim & reimplementing serialization for each event type.
However, right now
LogMesssagePacketBase
has a bit of a complex dependency chain - depending on preprocessor directives, certain events will either use a cached delegate of the base serialize methods, add additional properties to be serialized, or fully ignore the base implementation and provide a custom serializer. Another point is that many types in this path only exist inMicrosoft.Build.dll
(ArrayDictionary
,ItemDictionary
,PropertyDictionary
, ect.).One key here is that this additional logic is only relevant for
Microsoft.Build.dll
. SinceMSBuild.dll
,MSBuildTaskHost.dll
, and (next)Microsoft.Build.Tasks.dll
all use the default serialization, this custom logic can be refactored out, which removes the need for any conditional compilation.Changes made
LogMessagePacketBase
.Microsoft.Build.dll
into itsLogMessagePacket
implementation.EventCanSerializeItself
to mimic compile directive logic.WriteEventToStream
andReadEventFromStream
to allow hooking in custom serializers.TargetFinishedTranslator
delegate with virtualTranslateAdditionalProperties
to allow serializing additional properties to the defaults.LogMessagePacketBase
, as other assemblies only need the default implementation.Note that this doesn't touch any of the actual serialization logic or build event types, just the packet wrapper - so this shouldn't require a version rev or introduce compatibility breaks.