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

Fix marshaling of NativeArrayInfo parameters #357

Merged
merged 1 commit into from
Aug 18, 2021
Merged

Fix marshaling of NativeArrayInfo parameters #357

merged 1 commit into from
Aug 18, 2021

Conversation

pziezio
Copy link
Contributor

@pziezio pziezio commented Aug 12, 2021

Fixes #269 and many other problems with DirectX2D/11/12 etc.

When parameters with NativeArrayInfo are marshaled MarshalAsAttribute is sometimes missing.

https://github.com/microsoft/CsWin32/blob/main/src/Microsoft.Windows.CsWin32/PointerTypeHandleInfo.cs#L32
In this case marshalAs variable corresponds to element type of the array.
When there is no need for setting specific ArraySubType the MarshalAsAttribute is dropped altogether.
It should be set to just MarshalAs(UnmanagedType.LPArray) without specifying ArraySubType.

https://github.com/microsoft/CsWin32/blob/main/src/Microsoft.Windows.CsWin32/PointerTypeHandleInfo.cs#L57
There is exactly the same code in case of marshaling structs as array. Maybe that caused some confusion.
But in that case dropping MarshalAs is correct.

@ghost
Copy link

ghost commented Aug 12, 2021

CLA assistant check
All CLA requirements met.

Copy link
Member

@AArnott AArnott left a comment

Choose a reason for hiding this comment

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

Thanks!

@AArnott AArnott merged commit 9e72d1b into microsoft:main Aug 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Calling ID2D1Factory.CreateGeometryGroup causes Access violation
2 participants