[cdac] Generalize LayoutPair to LayoutSet and move IData.md in-tree#128716
Conversation
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
There was a problem hiding this comment.
Pull request overview
Follow-up rename/refactor of the cDAC IData<T> source generator's layout helper. The fixed two-field LayoutPair(nativeType, managedType) is replaced with a LayoutSet backed by a Target.TypeInfo?[] array, allowing future layout sources (e.g. symbols) to be added without structural changes. The IData.md design doc that previously lived in docs/design/datacontracts/ is relocated next to the generator since it is implementation guidance, not a data contract spec.
Changes:
- Rename
LayoutPairSource→LayoutSetSource(file, type, emitted struct, hint name, fully qualified name) and change storage to aTypeInfo?[]withInstanceSize/TrySelectiterating all slots. - Update generator emit sites (
Emitter.cs,CdacGenerator.cs) and comments to referenceLayoutSetinstead ofLayoutPair. - Move
IData.mdin-tree and updateLayoutPair→LayoutSetreferences throughout.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.DataGenerator/LayoutSetSource.cs |
Renamed from LayoutPairSource.cs; struct now backed by TypeInfo?[] with loop-based InstanceSize/TrySelect; Resolve still aggregates a native + managed slot into the array. |
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.DataGenerator/Emitter.cs |
Updates emitted source and comments from LayoutPair to LayoutSet. |
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.DataGenerator/CdacGenerator.cs |
Renames helper-gating flag and references (EmitLayoutPair → EmitLayoutSet, LayoutPairSource → LayoutSetSource). |
src/native/managed/cdac/IData.md |
Moved in-tree (was under docs/design/datacontracts/); updates LayoutPair → LayoutSet in prose and code examples. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Address review comments from PR #128356: 1. Generalize LayoutPair to LayoutSet (arbitrary N layout sources) instead of the fixed native+managed pair. The struct is now backed by a TypeInfo?[] array, making it extensible for future sources (e.g. symbols) without structural changes. 2. Move IData.md from docs/design/datacontracts/ to src/native/managed/cdac/ -- it is implementation guidance for the generator, not a data contract spec. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Defer the expensive managed-type-metadata lookup in LayoutSet so it only runs when no higher-priority source (the native cdac descriptor) satisfies the requested field. Field lookups against types fully covered by native descriptors now avoid touching managed metadata entirely. Wraps each layout source in a memoized LazyLayout box. The native source is constructed pre-resolved (the lookup is a cheap dictionary hit); the managed source is constructed with a factory invoked on first access. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
5c5ad02 to
9ea0873
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
src/native/managed/cdac/IData.md:375
- This section says the ctor throws if
LayoutSet.Resolvefinds neither source, but the currentLayoutSet.Resolveimplementation can return an empty set / unresolved managed layout and the ctor will instead fail later on the first field lookup (with a different exception/message). Either updateLayoutSet.Resolveto preserve the old fail-fast behavior (preferred), or adjust this doc to match the new behavior.
(Separate doc issue: after moving this file, the ManagedTypeSource.md relative link near the top appears to be broken.)
Update CdacAttributes.FieldAttribute doc comment: 'LayoutPair cascade' -> 'LayoutSet cascade'. The type was renamed but the comment lagged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/ba-g cDAC only change, CI passed before comments only change. |
|
Note This review was generated by Copilot. 🤖 Copilot Code Review — PR #128716Holistic AssessmentMotivation: Justified refactor addressing reviewer feedback from a prior PR. Generalizing Approach: Reasonable — replaces fixed two-field struct with an array-backed lazy-resolution pattern. The rename is consistently applied across code, comments, and docs. Summary: Detailed Findings
|
Follow-up to #128356 addressing review feedback from @noahfalk:
Changes
Generalize
LayoutPairtoLayoutSet(review comment)LayoutPairSource.cs->LayoutSetSource.csTypeInfo?[]array instead of fixed native+managed fieldsSelect/TrySelect/InstanceSizeiterate all slotsMove
IData.mdtosrc/native/managed/cdac/(review comment)LayoutPair->LayoutSetreferences in the doc