RAR node: Refactor LogMessagePacketBase to remove Microsoft.Build dep…#12526
Merged
YuliiaKovalova merged 2 commits intoOct 24, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This refactoring removes Microsoft.Build.dll dependency from LogMessagePacketBase by eliminating preprocessor directives and moving custom serialization logic to the derived LogMessagePacket class. The change enables sharing the base serialization wrappers across assemblies (MSBuild.exe, MSBuildTaskHost.exe, and Microsoft.Build.Tasks.dll) while maintaining assembly-specific customizations.
Key changes:
- Replaced compile-time directives with virtual methods for runtime customization
- Moved Microsoft.Build.dll-specific serialization logic to
LogMessagePacketclass - Made
LogMessagePacketBaseconcrete instead of abstract for default usage
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Shared/LogMessagePacketBase.cs | Removed preprocessor directives and made class concrete with virtual methods for customization |
| src/Build/BackEnd/Components/Communications/LogMessagePacket.cs | Added Microsoft.Build.dll-specific serialization logic moved from base class |
| src/MSBuild/OutOfProcTaskHostNode.cs | Updated to use base class directly instead of derived LogMessagePacket |
| src/MSBuild/MSBuild.csproj | Removed LogMessagePacket.cs from compilation |
| src/MSBuildTaskHost/MSBuildTaskHost.csproj | Removed LogMessagePacket.cs link |
This was referenced Sep 18, 2025
This was referenced Oct 24, 2025
This was referenced Nov 19, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
LogMessagePacketBaseprovides a type-safe way to wrapBuildEventArgsinto 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
LogMesssagePacketBasehas 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.dllall use the default serialization, this custom logic can be refactored out, which removes the need for any conditional compilation.Changes made
LogMessagePacketBase.Microsoft.Build.dllinto itsLogMessagePacketimplementation.EventCanSerializeItselfto mimic compile directive logic.WriteEventToStreamandReadEventFromStreamto allow hooking in custom serializers.TargetFinishedTranslatordelegate with virtualTranslateAdditionalPropertiesto 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.