dahall / Vanara

A set of .NET libraries for Windows implementing PInvoke calls to many native Windows APIs with supporting wrappers.
MIT License
1.79k stars 193 forks source link

Usage of `LibraryImport` instead of `DllImport` #420

Closed deeprobin closed 1 year ago

deeprobin commented 1 year ago

It might be useful to use the LibraryImport-Generator instead of the DllImportAttribute.

See https://learn.microsoft.com/en-US/dotnet/standard/native-interop/pinvoke-source-generation

dahall commented 1 year ago

I think you'll notice in the final section the differences with DllImport. This is a Windows-only interop library and regularly uses the "A and W" conversions supported by DllImport. For some exported methods, there may be value in debugging, but I think it deserves some testing to even see if dropping into unmanaged DLLs that don't have debugging files tied to them is even possible.