-
Notifications
You must be signed in to change notification settings - Fork 198
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
Add handling for [In, Out] attributes. #380
Add handling for [In, Out] attributes. #380
Conversation
…w usage of [In] or [Out] attributes on by reference parameters or on by value parameters where they have no effect.
…nonblittable by value array testing.
DllImportGenerator/DllImportGenerator/Marshalling/MarshallingGenerator.cs
Show resolved
Hide resolved
DllImportGenerator/DllImportGenerator/Marshalling/MarshallingGenerator.cs
Outdated
Show resolved
Hide resolved
DllImportGenerator/DllImportGenerator/Marshalling/MarshallingGenerator.cs
Outdated
Show resolved
Hide resolved
…elab into out-byval-array
This is finally ready for another review pass. |
if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) | ||
if (info.IsManagedReturnPosition | ||
|| (info.IsByRef && info.RefKind != RefKind.In) | ||
|| (info.ByValueContentsMarshalKind & ByValueContentsMarshalKind.Out) != 0) |
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.
Can't we use the HasFlag()
function for all of these checks with ByValueContentsMarshalKind
?
@@ -16,6 +16,35 @@ namespace Microsoft.Interop | |||
CharEncoding CharEncoding | |||
); | |||
|
|||
/// <summary> | |||
/// Describes how to marshal the contents of a value in comparison to the value itself. | |||
/// Only makes sense for array-like types. For example, an "out" array doesn't change the |
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.
Only makes sense for array-like types.
I'm assuming we have a nice assert or even a Diagnostic warning for the user that one is using In
/Out
on a type that we think is silly?
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.
Yes we emit a diagnostic warning or error if someone applies In
or Out
in a case where the attribute has no effect.
…elab into out-byval-array
Implement support for [Out] and [In, Out] on by-value arrays. Disallow usage of [In] or [Out] attributes on by reference parameters or on by value parameters where they have no effect.
Integration tests depend on #379