Support for derived IInspectable COM interfaces in custom winmds#1459
Merged
AArnott merged 21 commits intomicrosoft:mainfrom Sep 10, 2025
Merged
Support for derived IInspectable COM interfaces in custom winmds#1459AArnott merged 21 commits intomicrosoft:mainfrom
AArnott merged 21 commits intomicrosoft:mainfrom
Conversation
…into custom_iinspectable_interfaces
AArnott
requested changes
Sep 9, 2025
Member
AArnott
left a comment
There was a problem hiding this comment.
A few touch-ups suggested, but the only real blocking issue is the mixing up of MetadataFile objects between generators, as my comments explain.
test/Microsoft.Windows.CsWin32.Tests/ExternalMetadata/NOTICE.md
Outdated
Show resolved
Hide resolved
…evansaks/CsWin32 into custom_iinspectable_interfaces
AArnott
requested changes
Sep 9, 2025
Member
AArnott
left a comment
There was a problem hiding this comment.
Thanks. Much better. Almost there.
I'd fix it up myself but then I wouldn't be able to approve the PR 😒
AArnott
approved these changes
Sep 10, 2025
Member
|
/azp run |
|
No pipelines are associated with this pull request. |
This was referenced Oct 20, 2025
Closed
This was referenced Oct 27, 2025
Closed
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.
We want to use CsWin32 to generate WinRT COM interfaces from header files that are not in the Windows SDK, but they derive from IInspectable. CsWin32 was not correctly handling these, especially in the mode of allowMarshalling=false.
The problem was that we weren't being consistent about which MetadataReader we were using to resolve typedefs, methoddefs, and other things out of the winmd files when we crossed the winmd boundaries. In this PR we try to more clearly formalize how we access these things. Now we make sure to that the Generator we pass a TypeDefinition to (or whatever) has the owning MetadataReader for it.
The biggest source of problems for this was HandleTypeHandleInfo, so I changed this to get its Generator when it's created. This meant I needed to pass the Generator down to the SignatureHandleProvider and make it bound to the Generator instead of a singleton. But now HandleTypeHandleInfo always has the Generator that it can use instead of needing the one from the TypeSyntaxSettings.
This PR adds a test that covers this scenario and we run through marshalling/non-marshalling and net472 and net8 combinations.