Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Support targetting .Net Standard 1.5
- SuppressUnmanagedCodeSecurityAttribute requires .net standard 2.0
  • Loading branch information
jake-ruyi committed Nov 8, 2018
1 parent 60e883b commit d9c9f7a
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 9 deletions.
2 changes: 2 additions & 0 deletions nng.NETCore/Native/Aio.cs
Expand Up @@ -6,7 +6,9 @@ namespace nng.Native.Aio
{
using static Globals;

#if NETSTANDARD2_0
[System.Security.SuppressUnmanagedCodeSecurity]
#endif
public sealed class UnsafeNativeMethods
{
public delegate void AioCallback(IntPtr arg);
Expand Down
4 changes: 3 additions & 1 deletion nng.NETCore/Native/Ctx.cs
Expand Up @@ -5,8 +5,10 @@
namespace nng.Native.Ctx
{
using static Globals;


#if NETSTANDARD2_0
[System.Security.SuppressUnmanagedCodeSecurity]
#endif
public sealed class UnsafeNativeMethods
{
[DllImport(NngDll, CallingConvention = CallingConvention.Cdecl)]
Expand Down
2 changes: 2 additions & 0 deletions nng.NETCore/Native/Dialer.cs
Expand Up @@ -6,7 +6,9 @@ namespace nng.Native.Dialer
{
using static Globals;

#if NETSTANDARD2_0
[System.Security.SuppressUnmanagedCodeSecurity]
#endif
public sealed class UnsafeNativeMethods
{
[DllImport(NngDll, CallingConvention = CallingConvention.Cdecl)]
Expand Down
2 changes: 2 additions & 0 deletions nng.NETCore/Native/Listener.cs
Expand Up @@ -6,7 +6,9 @@ namespace nng.Native.Listener
{
using static Globals;

#if NETSTANDARD2_0
[System.Security.SuppressUnmanagedCodeSecurity]
#endif
public sealed class UnsafeNativeMethods
{
[DllImport(NngDll, CallingConvention = CallingConvention.Cdecl)]
Expand Down
4 changes: 3 additions & 1 deletion nng.NETCore/Native/Msg.cs
Expand Up @@ -5,8 +5,10 @@
namespace nng.Native.Msg
{
using static Globals;


#if NETSTANDARD2_0
[System.Security.SuppressUnmanagedCodeSecurity]
#endif
public sealed class UnsafeNativeMethods
{
[DllImport(NngDll, CallingConvention = CallingConvention.Cdecl)]
Expand Down
4 changes: 3 additions & 1 deletion nng.NETCore/Native/Pinvoke.cs
Expand Up @@ -5,8 +5,10 @@
namespace nng.Native.Basic
{
using static Globals;


#if NETSTANDARD2_0
[System.Security.SuppressUnmanagedCodeSecurity]
#endif
public sealed class UnsafeNativeMethods
{
[DllImport(NngDll, CallingConvention = CallingConvention.Cdecl)]
Expand Down
4 changes: 3 additions & 1 deletion nng.NETCore/Native/Protocols.cs
Expand Up @@ -5,8 +5,10 @@
namespace nng.Native.Protocols
{
using static Globals;


#if NETSTANDARD2_0
[System.Security.SuppressUnmanagedCodeSecurity]
#endif
public sealed class UnsafeNativeMethods
{
[DllImport(NngDll, CallingConvention = CallingConvention.Cdecl)]
Expand Down
4 changes: 3 additions & 1 deletion nng.NETCore/Native/Socket.cs
Expand Up @@ -5,8 +5,10 @@
namespace nng.Native.Socket
{
using static Globals;


#if NETSTANDARD2_0
[System.Security.SuppressUnmanagedCodeSecurity]
#endif
public sealed class UnsafeNativeMethods
{
// [DllImport(NngDll, CallingConvention = CallingConvention.Cdecl)]
Expand Down
4 changes: 3 additions & 1 deletion nng.NETCore/Native/Transports.cs
Expand Up @@ -5,8 +5,10 @@
namespace nng.Native.Transports
{
using static Globals;


#if NETSTANDARD2_0
[System.Security.SuppressUnmanagedCodeSecurity]
#endif
public sealed class UnsafeNativeMethods
{
[DllImport(NngDll, CallingConvention = CallingConvention.Cdecl)]
Expand Down
4 changes: 2 additions & 2 deletions nng.NETCore/nng.NETCore.csproj
Expand Up @@ -11,15 +11,15 @@

<PropertyGroup>
<PackageId>Subor.nng.NETCore</PackageId>
<PackageVersion>0.0.4</PackageVersion>
<PackageVersion>0.0.5</PackageVersion>
<Authors>Subor</Authors>
<PackageLicenseUrl>https://github.com/subor/nng.NETCore/blob/master/LICENSE</PackageLicenseUrl>
<Owners>Subor</Owners>
<PackageProjectUrl>https://github.com/subor/nng.NETCore</PackageProjectUrl>
<Summary>.NET Core bindings to nng</Summary>
<PackageTags>subor nng csnng</PackageTags>
<Description>.NET Core bindings to nng (https://github.com/nanomsg/nng)</Description>
<Version>0.0.4</Version>
<Version>0.0.5</Version>
<RepositoryUrl>https://github.com/subor/nng.NETCore</RepositoryUrl>
</PropertyGroup>

Expand Down
7 changes: 6 additions & 1 deletion nng.Shared/AssemblyLoadContext.cs
Expand Up @@ -46,7 +46,12 @@ protected override IntPtr LoadUnmanagedDll(string unmanagedDllName)
{
if (unmanagedDllName == "nng")
{
string arch = Environment.Is64BitProcess ? "-x64" : "-x86";
#if NETSTANDARD2_0
bool is64bit = Environment.Is64BitProcess;
#else
bool is64bit = (IntPtr.Size == 8);
#endif
string arch = is64bit ? "-x64" : "-x86";
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
var fullPath = Path.Combine(assemblyPath, "runtimes", "osx" + arch, "native", "libnng.dylib");
Expand Down

0 comments on commit d9c9f7a

Please sign in to comment.