[cdac] Move DataType from Abstractions to Contracts#128119
Open
max-charlamb wants to merge 1 commit into
Open
Conversation
Moves the DataType enum out of the Abstractions assembly and into Contracts, since it is part of the descriptor schema rather than the abstract target API. Target.GetTypeInfo(DataType) is replaced with a string-based abstract Target.GetTypeInfo(string) plus an extension method DataTypeTargetExtensions.GetTypeInfo(this Target, DataType) that calls .ToString(). Target.FieldInfo.Type is removed; TypeName is the sole identifier. TestPlaceholderTarget storage is now string-keyed internally. Builder.AddTypes(Dictionary<DataType,...>) is kept for caller convenience. Also removes the unused TargetTestHelpers.SizeOfTypeInfo helper. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR restructures cDAC type metadata handling by moving the DataType enum into the Contracts assembly and switching Target.GetTypeInfo from a DataType-based API to a string-based API, with corresponding updates across ContractDescriptorTarget and the unit tests.
Changes:
- Replaces
Target.GetTypeInfo(DataType)withTarget.GetTypeInfo(string typeName)and updates implementations/call sites accordingly. - Moves type identity from an enum-keyed cache to a string-keyed dictionary in targets and test infrastructure (builder helpers, descriptor parsing, and test setup).
- Introduces a
DataType→ string forwarding extension method (DataTypeTargetExtensions.GetTypeInfo(this Target, DataType)).
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/native/managed/cdac/tests/TestPlaceholderTarget.cs | Switches placeholder target type cache to Dictionary<string, TypeInfo>, adds builder overload to accept Dictionary<DataType, …> and convert to strings, updates GetTypeInfo override. |
| src/native/managed/cdac/tests/TargetTestHelpers.cs | Removes SizeOfTypeInfo helper and updates field layout helpers to populate FieldInfo.TypeName instead of FieldInfo.Type. |
| src/native/managed/cdac/tests/MethodDescTests.cs | Updates test type-info construction to no longer set FieldInfo.Type for AsyncMethodData.Flags. |
| src/native/managed/cdac/tests/GCMemoryRegionTests.cs | Updates test field dictionaries to set TypeName from DataType.ToString(). |
| src/native/managed/cdac/tests/ExecutionManager/HashMapTests.cs | Refactors target construction to use TestPlaceholderTarget.Builder and its string-keyed type/global setup. |
| src/native/managed/cdac/tests/DebuggerTests.cs | Adjusts AddTypes call to disambiguate the new overload set. |
| src/native/managed/cdac/tests/ContractDescriptor/TargetTests.SubDescriptors.cs | Removes FieldInfo.Type initialization and leaves TypeName as the identifier. |
| src/native/managed/cdac/tests/ContractDescriptor/TargetTests.cs | Removes FieldInfo.Type initialization and leaves TypeName as the identifier. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader/ContractDescriptorTarget.cs | Collapses type storage to Dictionary<string, TypeInfo>, populates pointer size via "pointer" key, removes enum-parse path, and uses the new DataType extension for CodePointer lookups. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/DataType.cs | Adds DataTypeTargetExtensions.GetTypeInfo(Target, DataType) convenience extension. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Target.cs | Changes the abstract GetTypeInfo contract to accept a string and removes FieldInfo.Type from the public surface. |
Comments suppressed due to low confidence (1)
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/DataType.cs:199
- This introduces a new public API (DataTypeTargetExtensions.GetTypeInfo(Target, DataType)) in the Contracts assembly. dotnet/runtime generally requires new public surface area to have an approved API proposal (api-approved issue) before merge; if that’s not available, consider making this helper internal (and using the string overload from other assemblies) until API review is completed.
Contributor
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
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.
Moves the
DataTypeenum out of the Abstractions assembly into Contracts, since it represents descriptor schema rather than the abstract Target API. Each user of the DataContractReader.Abstractions can define their own DataType schema.Changes
DataType.csmoved fromMicrosoft.Diagnostics.DataContractReader.AbstractionstoMicrosoft.Diagnostics.DataContractReader.Contracts.Target.GetTypeInfo(DataType)replaced with abstractTarget.GetTypeInfo(string typeName).DataTypeTargetExtensions.GetTypeInfo(this Target, DataType)inDataType.csfor ergonomics; it forwards to the string overload via.ToString().Target.FieldInfo.Type(theDataTypefield);TypeName(string) is now the sole identifier and is what consumers already used in practice.ContractDescriptorTargetnow stores types in a singleDictionary<string, Target.TypeInfo>.TestPlaceholderTargetstorage is string-keyed internally;Builder.AddTypes(Dictionary<DataType, ...>)is kept for caller convenience and converts to strings.TargetTestHelpers.SizeOfTypeInfo.Verification
Microsoft.Diagnostics.DataContractReader.Tests).Note
This PR description and the underlying changes were drafted with the assistance of GitHub Copilot.