Skip to content

Adopt new API in .NET Core 3.0 - System.Runtime.InteropServices.NativeLibrary #13

@JanVargovsky

Description

@JanVargovsky

I've encountered similar issue as #2. Since that time, native API has been merged in the .NET Core 3.0, see docs.

The library may adopt these changes quite easy:

class NetCoreLibraryLoader : LibraryLoader
{
    protected override void CoreFreeNativeLibrary(IntPtr handle)
    {
        System.Runtime.InteropServices.NativeLibrary.Free(handle);
    }

    protected override IntPtr CoreLoadFunctionPointer(IntPtr handle, string functionName)
    {
        return System.Runtime.InteropServices.NativeLibrary.GetExport(handle, functionName);

    }

    protected override IntPtr CoreLoadNativeLibrary(string name)
    {
        return System.Runtime.InteropServices.NativeLibrary.Load(name);
    }
}

We would have to target .NET Core 3.0 instead of .NET Standard 2.0.

What is your opinion about changing/adding the target framework to Core 3.0? Or maybe publish both NS and Core versions? Not sure whether it works - from the consumer perspective. I've seen a few libraries dropped out NS support and target Core but I'm aware that this library is commonly used in Mono/Xamarin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions