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

Use LibraryImportAttribute instead of DllImportAttribute #1687

Open
jasoncouture opened this issue Oct 6, 2022 · 2 comments
Open

Use LibraryImportAttribute instead of DllImportAttribute #1687

jasoncouture opened this issue Oct 6, 2022 · 2 comments
Assignees

Comments

@jasoncouture
Copy link

jasoncouture commented Oct 6, 2022

Brief Description

When code generation is targeting .NET 7, LibraryImport should be used in place of DllImport as this will pre-generate marshalling operations normally performed at runtime.

When framework target is lower than .NET 7, DllImport should continue to be used.

More information about LibraryImportAttribute can be found here: https://devblogs.microsoft.com/dotnet/announcing-dotnet-7-preview-7/#libraryimport-p-invoke-source-generator

(Non os specific, code generation)

OS: N/A

@tritao
Copy link
Collaborator

tritao commented Oct 6, 2022

Thanks for the heads up.

@caihongxu
Copy link

+1. Having the option to generate LibraryImport would be really useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants