Repository navigation
Support binlog format v28: structured RAR diagnostic events (read-only) - #969
Conversation
dotnet/msbuild#14599 and #14601 replaced ResolveAssemblyReference's plain-text diagnostics with three structured record kinds (AssemblyResolutionSearchTrace, AssemblyConflictDependencyDetails, AssemblyConflictWarning), currently reachable via ChangeWave 18.12 / VS Insiders builds. Without this, those records collapse into one generic "Skipped some data unknown to this version of Viewer" warning. Adds reader support only, matching the precedent set for MSBuildServerLifecycle (the last new record kind, added for format v27): no BuildEventArgsWriter path, so these events won't survive a redact/merge round-trip through this project. Local shim classes live in the Microsoft.Build.Framework namespace since this project pins that package well below the version that defines the real types. Rendering reuses existing node types (Parameter/Item for the search trace, Warning/Folder/Item for conflicts - the structured-data counterpart of ItemGroupParser.ParseThereWasAConflict's legacy text parsing) rather than reproducing the old primary/dependency/unified categorization. See KirillOsenkov#968. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…style Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
Thanks for starting this! I'd suggest using an RC2 SDK to get a sample binlog to verify the ability to read, and I'd also strongly consider not eagerly hydrating the messages. The reader is often used in high efficiency scenarios and doing additional work if any kind should be avoided. |
Attempt 2 now reuses attempt 1's SearchPath/ParentAssembly/IsAssemblyFoldersExSearch via the SearchPathUnchanged/ParentAssemblyUnchanged/AssemblyFoldersExUnchanged bits instead of re-writing identical values, matching the real compression this record kind relies on and dropping three now-redundant writes. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…uplicate Microsoft.Build.Shared.BinaryWriterExtensions.WriteOptionalString already writes the exact byte-for-byte format BuildEventArgsReader.ReadOptionalString() expects pre-v10 (presence byte + string). Also switch the search-trace attempt assertions to SatisfyRespectively instead of indexed Should() calls. Co-Authored-By: Claude Sonnet 5 <[email protected]>
- Convert AssemblyConflictDependee/AssemblyConflictReferenceDetails to primary constructors, matching this repo's own precedent (BuildCheckTracingEventArgs, BuildCheckAcquisitionEventArgs). - Drop public setters on the three event-args classes' properties - they're only ever assigned once, from the reader's constructor call. - Fix line endings/BOM on all four new files (LF/no-BOM) to match .editorconfig's end_of_line=crlf and charset=utf-8-bom for *.cs. Co-Authored-By: Claude Sonnet 5 <[email protected]>
None of this fork's existing Read*EventArgs methods cite where their wire format comes from, but we have a concrete source to point at for these three, so add it rather than leave the same gap. Co-Authored-By: Claude Sonnet 5 <[email protected]>
- AssemblyResolutionSearchAttempt, AssemblyConflictWarningEventArgs, and
AssemblyConflictDependencyDetailsMessageEventArgs converted to primary
constructors, dropping their unused parameterless constructors in the
process.
- AssemblyConflictDependee/AssemblyConflictReferenceDetails tightened from
{ get; private set; } to { get; }, consistent with the earlier fix to the
event-args classes' properties.
- BuildEventArgsReader's new Read* methods switched explicit string/bool
locals to var, matching this file's dominant style (int count locals left
explicit, matching that recurring idiom elsewhere in the file).
- Construction.cs: reworded the AssemblyConflictWarningEventArgs branch's
comment to name the specific regex/parser it bypasses (Strings.IsFoundConflicts,
ItemGroupParser.ParseThereWasAConflict) instead of referring to it only as
"rendered text".
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Per KirillOsenkov#969 (comment): this reader is used in high-throughput scenarios, so eagerly formatting Message in the constructor (string interpolation work on every event, even when nobody reads Message) should be avoided. All three event-args classes now compute Message lazily on first access and cache it in RawMessage, matching the existing AssemblyLoadBuildEventArgs precedent in this fork. Also: use raw string literals for the three Message formats (no more \" escapes), and fix a few test literals that used "C:\proj\..." instead of this file's usual @"C:\proj\..." verbatim style. Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
Thanks for the feedback — both addressed. Lazy Verified against a real RC2 binlog: Installed
Fed the resulting binlog through
I didn't commit the binlog itself or turn this into an automated test — this repo doesn't check in sample binlogs anywhere ( One side note on the screenshot/binlog attached to the PR description: |
Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ields/ProjectFile idiom Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
Hey Martin, thanks for doing this! If you like I can take over and finish this, or you can respond to my feedback, whatever you prefer. Basically I just found out that the past couple of version bumps we never incremented the version, so we need to bump the FileFormatVersion to 28 and add comments for 26, 27 and 28. PR #955 forgot this too. Rendering: RAR still logs the “Primary reference ...” and “There was a conflict between ...” headers as plain text in the new change wave, and ProcessRAR still turns those into Parameter nodes under Results. The new nodes are added to the task itself, so each reference and each conflict now shows up twice, detached from each other. Please attach the search trace and the dependency details to the last Parameter in rar.Results, the same way the indented-line path does, so the tree looks like it did before. For the items, use the Framework resource text (“For SearchPath ...”, “Considered ..., but it didn’t exist.”, “References which depend on ...”, “Project file item includes which caused reference ...”) instead of enum names and “Victor”/”Victim” labels. AddConflictReferenceDetails drops most of the data: the loss reason line, FullPath, PrimarySourceItemSpecs, each dependee’s SourceItemSpecs, and UnresolvedPrimaryItemSpec. The legacy text tree showed all of those. Mirroring AssemblyConflictMessageFormatter.AppendReferenceDetails from MSBuild would make it lossless. Nice to have: add the three Write overloads to BuildEventArgsWriter (small, mirrors MSBuild) so redact/merge keeps the data and the tests can round-trip through the real v28 framing instead of version 9. Also the doc comments still say “simple eager summary, computed lazily”. (disclaimer: I used Fable to review) |
…e's Parameter Per Kirill's review on KirillOsenkov#969: the new AssemblyResolutionSearchTrace and AssemblyConflictDependencyDetails nodes were being added directly as children of the RAR task, detached from the legacy "Primary reference"/"Dependency"/ conflict-header Parameter under task.Results that MSBuild still logs unconditionally alongside the new structured events. Each reference/conflict ended up represented by two disconnected nodes instead of one. Now both event kinds attach onto Results' last Parameter (the same one the indented-line legacy path nests onto), matching how the tree looked before format v28. Falls back to a standalone node only if Results doesn't exist yet. Verified against a real binlog produced by an RC2 SDK build (not just the hand-written wire-format tests): search-trace items land correctly under their reference's Parameter with no detached duplicate, and the conflict-details Victor/Victim folders merge onto the same Parameter the legacy conflict-header text created, adding detail that low-importance legacy text didn't carry. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Per Kirill's review on KirillOsenkov#969: AddConflictReferenceDetails only rendered a reference's FusionName and its dependees' full paths, dropping the reference's own FullPath, PrimarySourceItemSpecs/UnresolvedPrimaryItemSpec, and each dependee's SourceItemSpecs - all present on the structured AssemblyConflictReferenceDetails/AssemblyConflictDependee shim classes but never read. LossReason (carried on AssemblyConflictWarningEventArgs itself, not on the reference details) was similarly never surfaced. Mirrors dotnet/msbuild's AssemblyConflictMessageFormatter.AppendReferenceDetails structurally: a reference's own FullPath is rendered the same way as a dependee's FullPath (as an Item), with PrimarySourceItemSpecs nested under it when the reference is a resolved primary, or UnresolvedPrimaryItemSpec as a sibling property when it's an unresolved primary; each dependee's SourceItemSpecs nest under its own FullPath item the same way. LossReason is added as a Property directly on the warning node. Verified against the same real RC2-SDK binlog used for the earlier rendering fix: Shared's MSB3277 warning now shows LossReason = WasNotPrimary, and both Shared's and Other's Victor/Victim folders show the full dependency chain (FullPath + nested source item specs) that was previously dropped. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…6/27 Per Kirill's review on KirillOsenkov#969: FileFormatVersion was stuck at 25 - never bumped when this fork added reader support for v26 (LoggersRegisteredEventArgs) or v27 (MSBuildServerLifecycleEventArgs, PR KirillOsenkov#955), and PR KirillOsenkov#955 made the same omission before this one. BinLogReader.EnsureFileFormatVersionKnown only rejects a file when fileFormatVersion > FileFormatVersion AND minimumReaderVersion > FileFormatVersion, so this was latent rather than immediately visible: every binlog produced so far has kept minimumReaderVersion well below 25, since v26/v27/v28 are all forward-compatible additions. A future binlog that set minimumReaderVersion above 25 for a genuinely non-forward-compatible reason would have been wrongly rejected by this reader even though its Read* support for the relevant record kinds already exists. Comments for versions 26-28 copied verbatim from dotnet/msbuild's own BinaryLogger.cs (fetched directly via its raw GitHub URL to confirm the exact text, not from a prior summary). Left the pre-existing v24/v25 comments untouched - their wording already differs slightly from upstream's, but that's unrelated to this change. Deliberately did not copy upstream's "keep BuildEventArgsWriter and StructuredLogViewer.BuildEventArgsWriter in sync" note: that refers to a writer duplicated between MSBuild's own build engine and its Visual Studio log-viewer feature, which doesn't exist in this fork (exactly one BuildEventArgsWriter class here) - copying it would describe a problem this codebase doesn't have. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…classes Per Kirill's review on KirillOsenkov#969: leftover from before the lazy-formatting fix (commit a1d089f) - "simple eager summary, computed lazily" contradicted itself. Drop "eager". Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
Thanks for the detailed review, and sorry for the delay in getting back to you! I went through all of it and pushed fixes for everything except two pieces that make more sense for you to finish: Fixed:
The PR description is updated to reflect the current state - new screenshot, new binlog zip, and the Rendering section rewritten to match the actual current behavior. Handing the rest over to you:
Taking you up on your offer to take over for those two — thanks again for the thorough review. |
|
Thanks! |
Fixes #968
Summary
dotnet/msbuild#14599 and #14601 replaced ResolveAssemblyReference's (RAR) plain-text diagnostics with three structured record kinds, bumping the binlog format to v28:
AssemblyResolutionSearchTrace,AssemblyConflictDependencyDetails,AssemblyConflictWarning. These are reachable today viaChangeWave 18.12(VS Insiders builds); the MSBuild team confirmed on #968 that the format is frozen for GA.Without support for these, they collapse into one generic
"Skipped some data unknown to this version of Viewer"warning and all their content is lost.AssemblyResolutionSearchTrace- one event per RAR reference, replacing the dozens of per-candidate plain-text messages this aggregates (file tried, search path, parent assembly, result, processor arch).AssemblyConflictDependencyDetails/AssemblyConflictWarning- the structured replacement for the legacy free-text MSB3277 "conflict" diagnostics.Scope: reader-only
This adds read support only - no
BuildEventArgsWriterpath for these three kinds. This follows the precedent set by #955, which added the last new record kind (MSBuildServerLifecycle, for format v27) with reader support only. Known consequence, same as that precedent today: these events won't survive a redact/merge round-trip through this project (e.g. the Viewer's redaction feature, orBinlogToolmerge).The three new event classes are local shims in the
Microsoft.Build.Frameworknamespace (see AssemblyResolutionSearchTraceEventArgs.cs, AssemblyConflictReferenceDetails.cs, AssemblyConflictDependencyDetailsMessageEventArgs.cs, AssemblyConflictWarningEventArgs.cs), again mirroringMSBuildServerLifecycleEventArgs.cs- this project pinsMicrosoft.Build.Frameworkto17.5.0, well below the version that will eventually define the real types, so it can't reference them yet. They're trimmed to the fields actually read off the wire; this fork doesn't implement the real types' localizedMessageformatting -Messageis a simple invariant summary, computed lazily on first access likeAssemblyLoadBuildEventArgs's does.Rendering
Reuses existing node types rather than inventing new ones or reproducing the legacy text layout exactly:
AssemblyResolutionSearchTrace→ oneItemchild per search attempt, appended directly onto theParameternode that RAR's own "Primary reference"/"Dependency" header message already created under the task'sResultsfolder. MSBuild logs that header unconditionally alongside the new structured event, so attaching there - rather than creating a new standalone node - keeps each reference's search trace attached to that same reference instead of floating detached on the task.AssemblyConflictDependencyDetailsgets the same attach-point treatment, merging itsVictor/Victimdetail onto that sameResultsParameter.AssemblyConflictWarning→ aWarningnode via the same pathConstruction.WarningRaisedalready uses for RAR conflicts, but building the child tree directly from the structuredVictor/Victimfields instead of regex-matching rendered text.ItemGroupParser.AddConflictReferenceDetails- shared by both conflict event kinds - mirrors MSBuild's ownAssemblyConflictMessageFormatter.AppendReferenceDetails: besidesFusionNameand each dependee's path, it also surfaces the reference's ownFullPath,PrimarySourceItemSpecs/UnresolvedPrimaryItemSpec, and each dependee'sSourceItemSpecs;LossReasonis rendered as a property on the warning node. It's the structured-data counterpart ofItemGroupParser.ParseThereWasAConflict, which does the same from legacy free text.Known simplification: the legacy text distinguished "primary reference" vs "dependency" vs "unified" via separate regexes; the new structured events don't carry that categorization in the same shape, so this PR doesn't attempt to reproduce that distinction.
conflict.zip
See this comment for details on how the binlog above was produced (including a side note on why
Other/mscorlib/System.*don't appear underOutputItemsin the screenshot).Testing
Added three tests in
BinaryLoggerTests.csthat hand-construct the exact wire bytes (field order taken fromdotnet/msbuild's own writer) and feed them directly intoBuildEventArgsReader, since there's no productionWrite(...)path to round-trip through. To keep the hand-written framing simple, these construct the reader withfileFormatVersion: 9(pre-dedup, pre-length-framing) - see the comment block above the tests for why that's safe and doesn't affect the new record kinds' field layout.Also verified against a real binlog: installed a .NET 11 RC2 SDK and reproduced all three record kinds with an actual build (that's what the screenshot above is from). Fed the resulting binlog through
BuildEventArgsReaderdirectly and through the full tree-building pipeline (Serialization.Read→MessageProcessor/Construction), and confirmed all three decode and render correctly, including the realMSB3277warning with itsVictor/Victimfolders shown above. Repro steps are in this comment.dotnet test src/StructuredLogger.Testspasses (105 tests, including the 3 new ones)dotnet build MSBuildStructuredLog.sln), including the Viewer apps🤖 Generated with Claude Code