Giter Site home page Giter Site logo

nng.netcore's Introduction

nng.NETCore

.NET Core bindings for NNG.

Usage

Currently only works in projects targetting:

  • .NET Core App 1.0+
  • .NET Standard 1.5+
    • SuppressUnmanagedCodeSecurity is used with .NET Standard 2.0+ for improved PInvoke performance
  • .NET Framework 4.6.1+

After installing the package and building your output folder should have runtimes/ directory containing native binaries.

On .NET Core/Standard you can either use NngLoadContext (or your own AssemblyLoadContext) to load the appropriate native library and use NNG:

var path = Path.GetDirectoryName(typeof(Program).Assembly.Location);
var ctx = new nng.NngLoadContext(path);
var factory = nng.NngLoadContext.Init(ctx);
// Use factory...

.NET Framework 4.6.1

System.Runtime.Loader is not available in .NET Framework, so the correct assembly must be loaded by some other means.

If your application is targetting .Net Framework 4.6+ and you get lots of:

message NETSDK1041: Encountered conflict between 'Reference:XXX\.nuget\packages\subor.nng.netcore\0.0.5\lib\netstandard2.0\Microsoft.Win32.Primitives.dll' and 'Reference:Microsoft.Win32.Primitives'.  NETSDK1034: Choosing 'Reference:XXX\.nuget\packages\subor.nng.netcore\0.0.5\lib\netstandard2.0\Microsoft.Win32.Primitives.dll' because file version '4.6.26419.2' is greater than '4.6.25714.1'.

<snip>

XXX\Properties\AssemblyInfo.cs(8,12,8,25): error CS0246: The type or namespace name 'AssemblyTitleAttribute' could not be found (are you missing a using directive or an assembly reference?)

Try adding the following to your project:

<PropertyGroup>
    <DependsOnNETStandard>false</DependsOnNETStandard>
</PropertyGroup>

Build & Run

  1. Build: dotnet build
  2. Run: dotnet run or dotnet test tests

Updating nng native shared library:

  1. Download/clone nng source
  2. On Windows, create Command Prompt suitable for Visual Studio:
    • Run x64 Visual Studio Developer Command Prompt to create a 64-bit library (or x86 for 32-bit)
    • OR, run vcvars64.bat in cmd.exe (or vcvars32.bat)
  3. Make sure cmake and Ninja are in your PATH
  4. Run:
    mkdir build && cd build
    cmake -G Ninja -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release ..
    ninja
    

Status

Very pre-alpha. Using latest nng release (currently v1.1.0-rc). Once this is a bit farther along will track nng version numbers.

NuGet Build status Build status codecov

Implementation status of various APIs is as follows:

Core Functionality

Feature Pinvoke Wrapper Tests Notes
aio 100% 75% 75% Missing get/set_input/output/iov
ctx 100% 50% 50% Doesn't seem to be ctx-supported options other than nng_duration
dialer 75% 50% 50%
iov 0% 0% 0%
listener 75% 50% 50%
msg 75% 75% 75%
pipe 0% 0% 0%
socket 100% 50% 50% Missing synchronous methods and nng_getopt_string
raw socket 0% 0% 0% Low priority
compat 0% 0% 0% No plans to implement
TLS 0% 0% 0% Low priority
Http 0% 0% 0% No plans to implement
CV/Mtx/thread 0% 0% 0% No plans to implement

Protocols and Transports

Feature Pinvoke Wrapper Tests Notes
bus 75% 50% 25%
inproc 100% 50% 50%
ipc 100% 50% 50%
pair 0% 0% 0% Low priority
pub/sub 100% 50% 50%
push/pull 100% 50% 50%
req/rep 100% 50% 50%
respondent 0% 0% 0% Low priority
surveyor 0% 0% 0% Low priority
tcp 100% 50% 50%
tls 0% 0% 0% Low priority
ws 50% 25% 25%
zerotier 0% 0% 0% Low priority

Background

nng.NETCore is meant to be a completely different approach than zplus/csnng (our fork of csnng). Namely:

  • Async first: using nng_aio and nng_ctx ready for async/await
  • Native layer: P/Invoke in separate files/namespace. Don't like our high-level OO wrapper? Re-use the pinvoke and make your own. Will also make it easier to do cross-platform-friendly pinvoke
  • Tests as Documentation: xUnit unit/integration tests in "plain" C# much like you'd write
  • .NET Core friendly: Using dotnet and targetting .NET Standard from the start
  • Simple class heirarchy (maybe) and minimal exceptions

See also runng. Our like-minded NNG binding/wrapper for Rust.

nng.netcore's People

Contributors

jake-ruyi avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.