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

Make [In, Optional] managed struct parameters actually optional in friendly overloads #579

Merged
merged 2 commits into from
Jun 5, 2022

Conversation

AArnott
Copy link
Member

@AArnott AArnott commented Jun 5, 2022

Fixes #578

@AArnott AArnott enabled auto-merge June 5, 2022 03:23
@AArnott
Copy link
Member Author

AArnott commented Jun 5, 2022

@AaronRobinsonMSFT .NET Framework interop can handle Unsafe.AsRef<MINIDUMP_CALLBACK_INFORMATION>(null) as an argument to an in MINIDUMP_CALLBACK_INFORMATION parameter of an extern method in order to pass in a null pointer, right? It compiles. I just want to verify that it runs.

@AArnott AArnott disabled auto-merge June 5, 2022 03:24
@AaronRobinsonMSFT
Copy link
Member

.NET Framework interop can handle Unsafe.AsRef<MINIDUMP_CALLBACK_INFORMATION>(null) as an argument to an in MINIDUMP_CALLBACK_INFORMATION parameter of an extern method in order to pass in a null pointer, right?

@AArnott Yes. This will translate into a nullptr/NULL on the native side.

For .NET 5+ we recommend using Unsafe.NullRef<T>, but I assume you don't have that on a .NET Standard 2.1 platform.

@AArnott
Copy link
Member Author

AArnott commented Jun 5, 2022

Thanks. The source generator already caters to various TFMs and C# LangVersions, so we can certainly emit Unsafe.NullRef<T> wherever that API is defined.

@AArnott AArnott enabled auto-merge June 5, 2022 13:20
@AArnott AArnott merged commit 6ea3f44 into main Jun 5, 2022
@AArnott AArnott deleted the fix578 branch June 5, 2022 13:50
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.

[Optional, In] parameter shouldn't use in modifier in extern method for managed structs
2 participants