Repository navigation
Fix COM interface classification across metadata assemblies - #1870
Draft
Jevan Saks (jevansaks) wants to merge 5 commits into
Draft
Jevan Saks (jevansaks) wants to merge 5 commits into
Jevan Saks (jevansaks) wants to merge 5 commits into
Conversation
Resolve interface definitions and COM ancestry with their owning generator and metadata reader. Add reciprocal metadata fixtures covering native pointers, marshaled arrays, and non-COM ancestry. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This was referenced Oct 30, 2026
Run the SDK COM source generator on GUID-bearing reciprocal fixtures and compile its output. Fix inherited CCW property inspection to use the method-owning metadata reader. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Verify the SDK-generated compilation emits successfully, then normalize only third-party generated trees for the existing cross-platform test formatting assertions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
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.
Summary
Resolve interface references through the existing qualified metadata resolver, using the defining generator and reader for both interface classification and COM ancestry. This preserves native interface pointers when a field's COM interface moves to another input WinMD.
For example,
DML_BUFFER_BINDING.Buffermust remainID3D12Resource*withallowMarshaling: falsewhen Direct3D 12 interfaces are supplied by SDK-owned metadata instead of Windows metadata. Previously the external reference was classified as a non-interface and projected by value, failing a pointer assignment with CS0029.The reader-ownership correction also covers marshaled interface arrays, transitive external non-COM ancestry, and inherited method inspection for COM callable wrappers. It does not change public APIs or production metadata inputs.
Regression coverage
Two small authored IL/WinMD fixtures use reciprocal assembly references. They cover local and external COM fields, marshaled COM arrays, native double pointers, and transitive external non-COM ancestry.
All three modes are exercised: native pointers (
allowMarshaling: false), runtime marshaling, and AOT-compatible COM source generation. GUID-bearing interfaces allow the tests to run the .NET SDK's actual COM source generators on the projected code, check generator diagnostics, and compile/emit the completed output. Source-generated binding fields accept the nativeIExternalCom_unmanaged*projection; runtime-marshaled fields accept the managed interface.Validation
COMTestsandMultiMetadataTestspass, including six reciprocal-fixture cases across the three modes.DML_BUFFER_BINDINGconsumer passes with baseline Windows metadata using CsWin32 0.3.367, and fails with CS0029 using the reciprocal Windows/D3D metadata pair.DML_BUFFER_BINDINGandDMLCreateDevicebuilds with zero warnings/errors in native, runtime-marshaled, and COM source-generated modes using the rebuilt build task. The source-generated case runs the SDK COM generator withIsAotCompatibleandDisableRuntimeMarshallingenabled;BufferacceptsID3D12Resource_unmanaged*.This fixes a projection prerequisite for moving Direct3D 12 metadata ownership. Enabling Windows metadata removal still requires published fixed CsWin32 and WinmdGenerator releases and the coordinated SDK/package updates; this PR does not enable that removal.