- 
                Notifications
    You must be signed in to change notification settings 
- Fork 114
Support for derived IInspectable COM interfaces in custom winmds #1459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for derived IInspectable COM interfaces in custom winmds #1459
Conversation
…into custom_iinspectable_interfaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Much better. Almost there.
I'd fix it up myself but then I wouldn't be able to approve the PR 😒
| /azp run | 
| No pipelines are associated with this pull request. | 
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.