Skip to content
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

[ComInterfaceGenerator] Recommend [In] and [Out] attributes on array parameters #91231

Conversation

jtschuster
Copy link
Member

@jtschuster jtschuster commented Aug 28, 2023

Backport of #91094

Provide an info diagnostic to recommend that source-generated interop methods with array parameters use [In] or [Out] attributes if there are none already and the parameter is not in, ref, or out. Remove the "unnecessary info" diagnostics when the default behavior [In] and [Out] attributes are added.

There are no changes to code generation, and much of the diff is test refactoring and resource files.

Customer Impact:

Arrays are the most complicated parameter type to understand as a user and is the main subject of many bugs filed against the generator. To ensure writers and readers of code understand the expected behavior and direction of marshalling for the elements of the array, we want to encourage using the [In] and [Out] attributes.

Customers who had to silence "Unnecessary Marshalling Info" diagnostics will have unnecessary suppressions.
Customers who don't use [In] or [Out] on arrays will get new info diagnostics.

Testing:

More unit testing was added to ensure the behavior was correctly updated, and it has been confirmed to work in Visual Studio.

Risk:

Very low, since there is no change to generated code, only to info diagnostics for array parameters in LibraryImport and GeneratedComInterface.

…parameters (dotnet#91094)

Recommend that methods with array parameters use [In] or [Out] attributes if there are none already, and the parameter is not in, ref, or out.
@ghost
Copy link

ghost commented Aug 28, 2023

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

Issue Details

Backport of #91094

Provide an info diagnostic to recommend that source-generated interop methods with array parameters use [In] or [Out] attributes if there are none already and the parameter is not in, ref, or out. Remove the "unnecessary info" diagnostics when the default behavior [In] and [Out] attributes are added.

There are no changes to code generation, and much of the diff is test refactoring and resource files.

Author: jtschuster
Assignees: -
Labels:

area-System.Runtime.InteropServices

Milestone: 8.0.0

@jtschuster jtschuster marked this pull request as ready for review August 28, 2023 20:20
Copy link
Member

@jeffschwMSFT jeffschwMSFT left a comment

Choose a reason for hiding this comment

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

approved. please get a code review. once ready this pr can be merged.

@carlossanlop
Copy link
Member

@AaronRobinsonMSFT / @jkoritzinsky can you please give a code review sign-off?

@carlossanlop carlossanlop merged commit 22a50ac into dotnet:release/8.0 Aug 28, 2023
113 of 120 checks passed
@radical radical mentioned this pull request Sep 26, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Sep 28, 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.

4 participants