Skip to content

Add custom exception handlers to generated COM wrappers #114828

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

Merged
merged 15 commits into from
May 15, 2025

Conversation

dongle-the-gadget
Copy link
Contributor

Fixes #109522

This is an initial iteration to add custom exception handlers to
generated COM wrappers, through a new ExceptionToUnmanagedMarshaller
property in GeneratedComWrappersAttribute

Fix dotnet#109522
@ghost
Copy link

ghost commented Apr 19, 2025

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

1 similar comment
@ghost
Copy link

ghost commented Apr 19, 2025

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Apr 19, 2025
Copy link
Contributor

Tagging subscribers to this area: @dotnet/interop-contrib
See info in area-owners.md if you want to be subscribed.

@dongle-the-gadget
Copy link
Contributor Author

@dotnet-policy-service agree

@dongle-the-gadget dongle-the-gadget changed the title Add ExceptionToUnmanagedMarshaller to GeneratedComInterfaceAttribute Add custom exception handlers to generated COM wrappers Apr 19, 2025
Resolves an issue with previous implementation, highlighted by Jeremy.
The previous implementation is overcomplicated and hooks into the
default exception logic, which is not ideal. This commit copies the
existing custom exception marshalling logic from the VTable stub
generator.
Copy link
Member

@jkoritzinsky jkoritzinsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few nits, but looking much better!

dongle-the-gadget and others added 2 commits April 19, 2025 11:25
Co-authored-by: Aaron Robinson <[email protected]>
Copy link
Member

@jkoritzinsky jkoritzinsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good. Mark this as non-draft and we can do a final review. (Also get the new test passing everywhere, looks like there's failures).

@dongle-the-gadget dongle-the-gadget marked this pull request as ready for review May 9, 2025 00:13
Copy link
Member

@jkoritzinsky jkoritzinsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thank you!

dongle-the-gadget and others added 2 commits May 10, 2025 01:09
This is to match the common scenario.

Co-authored-by: Aaron Robinson <[email protected]>
@AaronRobinsonMSFT
Copy link
Member

Thanks!

@AaronRobinsonMSFT AaronRobinsonMSFT merged commit 3197765 into dotnet:main May 15, 2025
90 of 93 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jun 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposal: allow exception marshallers via '[return: MarshalUsing]' on generated COM interfaces methods without '[PreserveSig]'
3 participants