Skip to content

Warn in CustomMarshallerAnalyzer if the MarshaMode is not valid #87198

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 8 commits into from
Jun 12, 2023

Conversation

jtschuster
Copy link
Member

@jtschuster jtschuster commented Jun 6, 2023

I ran into an issue when making some tests where I tried to use MarshalMode as a flags enum, which lead to the generated code not being correct, but no warning was showing up. This PR creates a warning if you try to do an operation on the MarshalMode argument or if a casted int value is not defined in the MarshalMode enum.

Fixes #87139

@ghost
Copy link

ghost commented Jun 6, 2023

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

Issue Details

I ran into an issue when making some tests where I tried to use MarshalMode as a flags enum, which lead to the generated code not being correct, but no warning was showing up. This PR creates a warning if you try to do an operation on the MarshalMode argument or if a casted int value is not defined in the MarshalMode enum.

Author: jtschuster
Assignees: jtschuster
Labels:

area-System.Runtime.InteropServices

Milestone: -

@jtschuster jtschuster changed the title Warn on CustomMarshallerAnalyzer if the MarshaMode is not valid Warn in CustomMarshallerAnalyzer if the MarshaMode is not valid Jun 9, 2023
@jtschuster jtschuster merged commit 873b008 into dotnet:main Jun 12, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Jul 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Interop analyzers don't warn if CustomMarshallerAttribute has invalid MarshalMode value
3 participants