Skip to content
Delegate-based C# P/Invoke alternative - compatible with all platforms and runtimes.
C# C CMake Other
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Create FUNDING.yml Jun 6, 2019
AdvancedDLSupport.AOT.Tests Update altcover and remove reference to MS's test SDK. Sep 22, 2019
AdvancedDLSupport.AOT Remove annotations from source control. Dec 26, 2018
AdvancedDLSupport.Benchmark
AdvancedDLSupport.Tests Span Parameters (#91) Sep 23, 2019
AdvancedDLSupport Merge branch 'master' of github.com:Firwood-Software/AdvancedDLSupport Sep 27, 2019
Mono.DllMap.Tests Update altcover and remove reference to MS's test SDK. Sep 22, 2019
Mono.DllMap Remove annotations from source control. Dec 26, 2018
docs Fix typo in documentation file. (#92) Sep 21, 2019
props Testfix (#85) Jun 29, 2019
scripts Correct CI scripts (#56) Sep 24, 2018
.gitignore Remove annotations from source control. Dec 26, 2018
.travis.yml Span Parameters (#91) Sep 23, 2019
AdvanceDLSupport.sln Testfix (#85) Jun 29, 2019
AdvanceDLSupport.sln.DotSettings Move to Humanizer.Core to reduce dependency footprint. Dec 24, 2018
CONTRIBUTING.md Add issue template, pull request template, and contribution guidelines. Mar 19, 2018
LICENSE Relicense the project under the LGPLv3. Apr 17, 2018
README.md Update README.md Jun 30, 2019
StrictEmit-LICENSE.md Update StrictEmit-LICENSE.md Oct 9, 2019
appveyor.yml Codecov early out (#86) Jul 2, 2019
stylecop.json Implement our own calli emission (#90) Jul 7, 2019
stylecop.ruleset Enable alt-rule for not prefixing local calls with `this`. Ouch. Feb 4, 2018

README.md

AdvancedDLSupport

Alternative approach to your usual P/Invoke!

Join the chat at https://discord.gg/fDy5Vhb

Use C# interfaces to bind to native code - quick and easy usage of C API in C# code, on any platform. Gone are the days of broken DllImport and annoying workarounds for the different runtimes.

Fully compatible with Mono, .NET Framework, .NET Core, and .NET Standard. Compatible with Mono DLL mapping on all platforms and runtimes. Configurable and adaptible.

Why use ADL?

  1. Modern API - no more static classes, no more extern. Use your native API as if it were first-class objects.
  2. Flexibility - Inject your native API into your classes, change the library scanning logic, mix your managed and native code.
  3. Speed - ADL is blazing fast, and gives your native interop an edge. See performance increases that are at least 2 and up to 8 times faster than other, existing solutions.
  4. Easy to use - Not only is ADL simple to set up and get working, it's a breeze to maintain, and reduces clutter in your codebase.

Build & Test status

Travis (Linux - Mono & .NET Core) Travis (OSX - Mono & .NET Core) AppVeyor (Windows - .NET & .NET Core) MyGet (Development)
x64 (Debug) Build Status Build Status Build status
x64 (Release Build Status Build Status Build status
x86 (Debug) Build Status Build Status Build status
x86 (Release) Build Status Build Status Build status
Any CPU (Debug) Build Status Build Status Build status Build Status
Any CPU (Release) Build Status Build Status Build status

Total project coverage: Codecov.io

Read the Docs, or get the MyGet development packages and get started.

Features

  • Supports all the typical P/Invoke patterns and constructs
  • Seamlessly mix native functions and managed code
  • Use more complex types, such as Nullable<T> and string without any extra code
  • Select library architectures at runtime
  • Select library names at runtime
  • Swappable native library search algorithms
  • Import global variables
  • Optional lazy loaded symbols
  • Optional Mono DllMap support

Basic Usage

  1. Declare your interface

    public interface IMyNativeLibrary
    {
    	long MyNativeGlobal { get; set; }
    	int MyNativeMultiply(int a, int b);
    	void MyOtherNativeFunction(MyStruct strct, ref MyStruct? maybeStruct);
    }
  2. Activate it

    const string MyLibraryName = "MyLibrary";
    
    var activator = new NativeLibraryBuilder();
    var library = activator.ActivateInterface<IMyNativeLibrary>(MyLibraryName);
  3. Use it

    library.MyNativeGlobal = 10;
    
    var result = library.MyNativeMultiply(5, 5);
    
    var myStruct = new MyStruct();
    MyStruct? myOtherStruct = null;
    
    library.MyOtherNativeFunction(myStruct, ref myOtherStruct);

See the Quickstart for more information.

Installation

Via your favourite Nuget UI, or

NuGet

Install-Package AdvancedDLSupport -ProjectName MyProject

MyGet

nuget sources Add -Name AdvancedDLSupport-develop -Source https://www.myget.org/F/advancedlsupport/api/v3/index.json
Install-Package AdvancedDLSupport -ProjectName MyProject

Support us

Become a Patron Buy Me a Coffee at ko-fi.com

License

If the library's license doesn't fit your project or product, please contact us. Custom licensing options are available, and we are always open to working something out that fits you - be it modified, commercial, or otherwise.

AdvancedDLSupport's public release is licensed under the GNU Lesser General Public License, Version 3 (LGPLv3). See the LICENSE for details. Without the support of the open-source movement, it would never have existed.

You can’t perform that action at this time.