Karma.CoreInvoke
1.1.0
See the version list below for details.
dotnet add package Karma.CoreInvoke --version 1.1.0
NuGet\Install-Package Karma.CoreInvoke -Version 1.1.0
<PackageReference Include="Karma.CoreInvoke" Version="1.1.0" />
paket add Karma.CoreInvoke --version 1.1.0
#r "nuget: Karma.CoreInvoke, 1.1.0"
// Install Karma.CoreInvoke as a Cake Addin #addin nuget:?package=Karma.CoreInvoke&version=1.1.0 // Install Karma.CoreInvoke as a Cake Tool #tool nuget:?package=Karma.CoreInvoke&version=1.1.0
CoreInvoke is a lightweight, blazing fast replacement for P/Invoke for C# 10+.
It does this by utilizing CALLI instructions through the unmanaged pointer syntax over
regular external function bindings.
This also allows for defining functions which do not block the garbage collector.
Example
Using CoreInvoke is almost as easy as using P/Invoke:
internal static class ExampleLib {
// Define a module name used to refer to the library.
private const string _ModuleName = "libc";
// Define a native library which takes care of loading the functions we want to use.
// Using SystemInfo can help make standardized APIs platform-agnostic with a few extra lines of code.
private static readonly NativeLibrary _Lib = new(_ModuleName, () => {
if (SystemInfo.IsWindows) return new[] {"msvcrt.dll", "msvcrt140.dll"};
return SystemInfo.IsOSX ? new[] {"libSystem.dylib"} : new[] {"libc.so.6", "libc.so"};
});
// Load all functions within this class once it's type is being initialized
static ExampleLib() => _Lib.LoadFunctionsFor(typeof(ExampleLib));
// Define a callable pointer field which get's populated with an
// unmanaged pointer to the malloc function from libc.
[Import(_ModuleName, "malloc")]
public static readonly delegate* unmanaged<nuint, void*> Malloc = null!;
// Do the same thing for the free function.
[Import(_ModuleName, "free")]
public static readonly delegate* unmanaged<void*, void> Free = null!;
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Karma.Kommons (>= 1.0.2)
- Microsoft.Extensions.Logging (>= 6.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.0)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Karma.CoreInvoke:
Package | Downloads |
---|---|
Karma.CoreGPU
Typesafe, low-level bindings for wgpu_native based on CoreInvoke. |
|
Karma.CoreOBJ
Typesafe, low-level bindings for fast_obj based on CoreInvoke. |
|
Karma.MediaCore
Typesafe, low-level bindings for SDL2 based on CoreInvoke. |
|
Karma.LayoutCore
Typesafe, low-level bindings for Yoga based on CoreInvoke. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.4.3 | 1,220 | 2/24/2022 |
1.4.2 | 481 | 2/23/2022 |
1.4.1 | 360 | 2/22/2022 |
1.4.0 | 574 | 2/22/2022 |
1.3.1 | 270 | 2/21/2022 |
1.3.0 | 144 | 2/21/2022 |
1.2.1 | 275 | 2/18/2022 |
1.2.0 | 429 | 2/18/2022 |
1.1.1 | 1,070 | 2/18/2022 |
1.1.0 | 576 | 12/19/2021 |
1.0.3 | 269 | 12/19/2021 |
1.0.2 | 274 | 12/19/2021 |
1.0.1 | 286 | 12/19/2021 |
1.0.0 | 270 | 12/19/2021 |