-
I've been experimenting changing some p-invoke DllImport statements to use LibraryImport. For example a simple one:
changes to (I know these SuppressUnmanagedCodeSecurity, SecuritySafeCritical are null-ops in .NET core)
I'm surprised to see that the generated code still uses DllImport
Is this correct/expected? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yes. The goal isn't to avoid |
Beta Was this translation helpful? Give feedback.
Yes. The goal isn't to avoid
DllImport
, it's to avoid runtime marshaling of parameters and return values. The generatedDllImport
-decorated method will only use blittable types, while the wrapper does marshaling through source generation before/after calling it.