You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is rather complex and not intuitive for .NET developers, and it gets complicated for NuGets when the same code is supposed to work on multiple platforms, when other platforms use a different library name (it's not possible to compile the code once and share it).
One idea would be to introduce a build step that rewrites the library for DllImports if there's a matching framework included in the build.
Say a DllImport has LibraryName="MyFramework", and a MyFramework.framework/MyFramework is included in the build - then we'd rewrite the DllImport to point to @rpath/MyFramework.framework/MyFramework instead.
Downsides:
It might slow down debug builds (since all the methods in all assemblies would have to be scanned (although we might have a list of assemblies we know we don't have to scan, so it would only be user assemblies).
Currently DllImports to a function in a framework needs to use this as the library:
This is rather complex and not intuitive for .NET developers, and it gets complicated for NuGets when the same code is supposed to work on multiple platforms, when other platforms use a different library name (it's not possible to compile the code once and share it).
One idea would be to introduce a build step that rewrites the library for DllImports if there's a matching framework included in the build.
Say a DllImport has LibraryName="MyFramework", and a
MyFramework.framework/MyFramework
is included in the build - then we'd rewrite the DllImport to point to@rpath/MyFramework.framework/MyFramework
instead.Downsides:
An existing solution is for customers to use the NaiveLibrary API (https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.nativelibrary?view=netcore-3.1), but it's not very discoverable. It also adds runtime cost for something we can do at compile time.
The text was updated successfully, but these errors were encountered: