Skip to content

Replace Marshal with Unsafe#336

Closed
andreakarasho wants to merge 2 commits into
bytecodealliance:mainfrom
andreakarasho:main
Closed

Replace Marshal with Unsafe#336
andreakarasho wants to merge 2 commits into
bytecodealliance:mainfrom
andreakarasho:main

Conversation

@andreakarasho
Copy link
Copy Markdown

No description provided.

@BasGeertsema
Copy link
Copy Markdown

I noticed the warning in the documentation. It seems to me that we actually want the size of the unmanaged view of the type? In that case we would need to use Marshal.SizeOf, as it is now.

@andreakarasho
Copy link
Copy Markdown
Author

Partially reverted to the Marshalversion but keeping the constraint version.

@jsturtevant
Copy link
Copy Markdown
Contributor

Should we try using the internal structs version before updating this? #332 (comment)

I think using the internal structs would remove the need for this change

@BasGeertsema
Copy link
Copy Markdown

Should we try using the internal structs version before updating this? #332 (comment)

I think using the internal structs would remove the need for this change

I agree, that would be a better solution.

@andreakarasho
Copy link
Copy Markdown
Author

Closing this because seems to be necessary anymore.


Side note:

I noticed the warning in the documentation. It seems to me that we actually want the size of the unmanaged view of the type? In that case we would need to use Marshal.SizeOf, as it is now.

Seems like they updated the documentation and removed that warning (?). MS now suggets to use sizeof (Unsafe.SizeOf is just a wrapper around sizeof) for blittable structs (which this was the case).
https://learn.microsoft.com/en-us/dotnet/standard/native-interop/best-practices#structs

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.

3 participants