diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index fbb6ccfd0..6c6cab6e6 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -4,19 +4,33 @@ on: [push, pull_request] jobs: ununtu: runs-on: ubuntu-latest + env: + DOTNET_NOLOGO: true steps: - uses: actions/checkout@v2 + - uses: actions/setup-dotnet@v1 + with: + dotnet-version: | + 3.1.x + 6.0.x - run: dotnet restore src/NetMQ.sln - name: build run: dotnet build src/NetMQ.sln /p:Configuration=Release /verbosity:minimal - name: test netcoreapp3.1 run: dotnet test -v n -p:ParallelizeTestCollections=false --configuration Release --no-build -f netcoreapp3.1 src/NetMQ.Tests/NetMQ.Tests.csproj - - name: test netcoreapp2.1 - run: dotnet test -v n -p:ParallelizeTestCollections=false --configuration Release --no-build -f netcoreapp2.1 src/NetMQ.Tests/NetMQ.Tests.csproj + - name: test net6.0 + run: dotnet test -v n -p:ParallelizeTestCollections=false --configuration Release --no-build -f net6.0 src/NetMQ.Tests/NetMQ.Tests.csproj windows: runs-on: windows-latest + env: + DOTNET_NOLOGO: true steps: - uses: actions/checkout@v2 + - uses: actions/setup-dotnet@v1 + with: + dotnet-version: | + 3.1.x + 6.0.x - name: Install codecov run: | choco install opencover.portable @@ -24,16 +38,13 @@ jobs: - run: dotnet restore src/NetMQ.sln - name: build run: dotnet build src/NetMQ.sln /p:Configuration=Release /verbosity:minimal - - name: test netcoreapp2.1 - run: dotnet test -v n -p:ParallelizeTestCollections=false --configuration Release --no-build -f netcoreapp2.1 src\NetMQ.Tests\NetMQ.Tests.csproj + - name: test net6.0 + run: dotnet test -v n -p:ParallelizeTestCollections=false --configuration Release --no-build -f net6.0 src\NetMQ.Tests\NetMQ.Tests.csproj - name: test netcoreapp3.1 run: dotnet test -v n -p:ParallelizeTestCollections=false --configuration Release --no-build -f netcoreapp3.1 src\NetMQ.Tests\NetMQ.Tests.csproj - name: test net47 run: dotnet test -v n -p:ParallelizeTestCollections=false --configuration Release --no-build -f net47 src\NetMQ.Tests\NetMQ.Tests.csproj - name: coverage run: | - OpenCover.Console.exe -register:user -target:"C:\Program Files\dotnet\dotnet.exe" -targetargs:"test --no-build --configuration Release -f netcoreapp2.1 --logger:trx;LogFileName=results.trx /p:DebugType=full src\NetMQ.Tests\NetMQ.Tests.csproj" -filter:"+[NetMQ*]* -[NetMQ.Tests*]*" -output:".\NetMQ_coverage.xml" -oldStyle + OpenCover.Console.exe -register:user -target:"C:\Program Files\dotnet\dotnet.exe" -targetargs:"test --no-build --configuration Release -f net6.0 --logger:trx;LogFileName=results.trx /p:DebugType=full src\NetMQ.Tests\NetMQ.Tests.csproj" -filter:"+[NetMQ*]* -[NetMQ.Tests*]*" -output:".\NetMQ_coverage.xml" -oldStyle codecov -f "NetMQ_coverage.xml" - - - diff --git a/README.md b/README.md index c0a5c3dbc..5bee9b20d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ +[![GitHub Actions CI](https://github.com/zeromq/netmq/actions/workflows/CI.yml/badge.svg)](https://github.com/zeromq/netmq/actions/workflows/CI.yml) [![NetMQ AppVeyor Build](https://ci.appveyor.com/api/projects/status/as5fiw8a3suw53iu/branch/master?svg=true)](https://ci.appveyor.com/project/somdoron/netmq-2bhss) [![codecov](https://codecov.io/gh/zeromq/netmq/branch/master/graph/badge.svg)](https://codecov.io/gh/zeromq/netmq) [![NetMQ NuGet version](https://img.shields.io/nuget/v/NetMQ.svg)](https://www.nuget.org/packages/NetMQ/) [![NetMQ NuGet prerelease version](https://img.shields.io/nuget/vpre/NetMQ.svg)](https://www.nuget.org/packages/NetMQ/) NetMQ is a 100% native C# port of the lightweight messaging library ZeroMQ. diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 21a2bec4f..abaddb940 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -6,7 +6,7 @@ - + diff --git a/src/NetMQ.Tests/ExceptionTests.cs b/src/NetMQ.Tests/ExceptionTests.cs index 0abe9a748..536e06d4c 100644 --- a/src/NetMQ.Tests/ExceptionTests.cs +++ b/src/NetMQ.Tests/ExceptionTests.cs @@ -108,6 +108,7 @@ private static T Clone(T source) where T : class return Deserialise(Serialise(source)); } +#pragma warning disable SYSLIB0011 // BinaryFormatter is obsolete private static Stream Serialise(object source) { var formatter = new BinaryFormatter(); @@ -122,6 +123,7 @@ private static T Deserialise(Stream stream) stream.Position = 0; return (T)formatter.Deserialize(stream); } +#pragma warning restore SYSLIB0011 // BinaryFormatter is obsolete #endregion } diff --git a/src/NetMQ.Tests/NetMQ.Tests.csproj b/src/NetMQ.Tests/NetMQ.Tests.csproj index 674d14886..c5b2668c8 100644 --- a/src/NetMQ.Tests/NetMQ.Tests.csproj +++ b/src/NetMQ.Tests/NetMQ.Tests.csproj @@ -6,9 +6,8 @@ true true true - $(PackageTargetFallback);netcoreapp1.0;portable-net45+win8 true - netcoreapp3.1;netcoreapp2.1;net47 + net6.0;netcoreapp3.1;net47 @@ -42,8 +41,8 @@ - - + + diff --git a/src/NetMQ.Tests/NetMQCertificateTest.cs b/src/NetMQ.Tests/NetMQCertificateTest.cs index 40cc12543..dc078f738 100644 --- a/src/NetMQ.Tests/NetMQCertificateTest.cs +++ b/src/NetMQ.Tests/NetMQCertificateTest.cs @@ -13,7 +13,7 @@ public void X85() for (int i = 0; i < 1000; i++) { var key = new NetMQCertificate(); - var copy = new NetMQCertificate(key.SecretKeyZ85, key.PublicKeyZ85); + var copy = new NetMQCertificate(key.SecretKeyZ85!, key.PublicKeyZ85); Assert.Equal(key.SecretKeyZ85, copy.SecretKeyZ85); Assert.Equal(key.PublicKeyZ85, copy.PublicKeyZ85); @@ -40,7 +40,7 @@ public void FromPublicKey() public void FromSecretKey() { var key = new NetMQCertificate(); - var copy = new NetMQCertificate().FromSecretKey(key.SecretKeyZ85); + var copy = new NetMQCertificate().FromSecretKey(key.SecretKeyZ85!); Assert.Equal(key.SecretKeyZ85, copy.SecretKeyZ85); Assert.Equal(key.PublicKeyZ85, copy.PublicKeyZ85); diff --git a/src/NetMQ.Tests/OutgoingSocketExtensionsTests.cs b/src/NetMQ.Tests/OutgoingSocketExtensionsTests.cs index cc43f72b6..96cc7b1c6 100644 --- a/src/NetMQ.Tests/OutgoingSocketExtensionsTests.cs +++ b/src/NetMQ.Tests/OutgoingSocketExtensionsTests.cs @@ -213,6 +213,7 @@ public void SendFrameEmpty() var socket = new MockOutgoingSocket((ref Msg msg, TimeSpan timeout, bool more) => { Assert.Equal(SendReceiveConstants.InfiniteTimeout, timeout); + Assert.NotNull(msg.UnsafeData); Assert.Empty(msg.UnsafeData); Assert.False(more); return true; @@ -227,6 +228,7 @@ public void SendMoreFrameEmpty() var socket = new MockOutgoingSocket((ref Msg msg, TimeSpan timeout, bool more) => { Assert.Equal(SendReceiveConstants.InfiniteTimeout, timeout); + Assert.NotNull(msg.UnsafeData); Assert.Empty(msg.UnsafeData); Assert.True(more); return true; @@ -242,6 +244,7 @@ public void TrySendFrameEmpty() var socket = new MockOutgoingSocket((ref Msg msg, TimeSpan timeout, bool more) => { Assert.Equal(TimeSpan.Zero, timeout); + Assert.NotNull(msg.UnsafeData); Assert.Empty(msg.UnsafeData); Assert.False(more); return true; @@ -257,6 +260,7 @@ public void TrySendFrameEmptyFailed() var socket = new MockOutgoingSocket((ref Msg msg, TimeSpan timeout, bool more) => { Assert.Equal(TimeSpan.Zero, timeout); + Assert.NotNull(msg.UnsafeData); Assert.Empty(msg.UnsafeData); Assert.False(more); return false; diff --git a/src/NetMQ.Tests/PgmTests.cs b/src/NetMQ.Tests/PgmTests.cs index 464e1b565..1dcc857ee 100644 --- a/src/NetMQ.Tests/PgmTests.cs +++ b/src/NetMQ.Tests/PgmTests.cs @@ -82,7 +82,7 @@ public void UseInterface() { var hostEntry = Dns.GetHostEntry(Dns.GetHostName()); - string ip = hostEntry.AddressList + string? ip = hostEntry.AddressList .Where(addr => addr.AddressFamily == AddressFamily.InterNetwork) .Select(addr => addr.ToString()) .FirstOrDefault(); diff --git a/src/NetMQ.Tests/ThrowingTraceListener.cs b/src/NetMQ.Tests/ThrowingTraceListener.cs index 9a7ef0620..91030810a 100644 --- a/src/NetMQ.Tests/ThrowingTraceListener.cs +++ b/src/NetMQ.Tests/ThrowingTraceListener.cs @@ -6,16 +6,16 @@ namespace NetMQ.Tests { public sealed class ThrowingTraceListener : TraceListener { - public override void Fail(string message, string detailMessage) + public override void Fail(string? message, string? detailMessage) { throw new DebugAssertFailureException((message + Environment.NewLine + detailMessage).Trim()); } - public override void Write(string message) + public override void Write(string? message) { } - public override void WriteLine(string message) + public override void WriteLine(string? message) { } diff --git a/src/NetMQ/NetMQ.csproj b/src/NetMQ/NetMQ.csproj index f65a6d064..71422794f 100644 --- a/src/NetMQ/NetMQ.csproj +++ b/src/NetMQ/NetMQ.csproj @@ -35,23 +35,23 @@ - + - + - + - + diff --git a/src/NetMQ/NetMQActor.cs b/src/NetMQ/NetMQActor.cs index 980c94fcc..60e9159f0 100644 --- a/src/NetMQ/NetMQActor.cs +++ b/src/NetMQ/NetMQActor.cs @@ -149,8 +149,10 @@ private NetMQActor(PairSocket self, PairSocket shim, IShimHandler shimHandler) m_self = self; m_shim = shim; - void OnReceive(object sender, NetMQSocketEventArgs e) => m_receiveEvent.Fire(this, new NetMQActorEventArgs(this)); - void OnSend (object sender, NetMQSocketEventArgs e) => m_sendEvent .Fire(this, new NetMQActorEventArgs(this)); + var args = new NetMQActorEventArgs(this); + + void OnReceive(object sender, NetMQSocketEventArgs e) => m_receiveEvent!.Fire(this, args); + void OnSend (object sender, NetMQSocketEventArgs e) => m_sendEvent !.Fire(this, args); m_receiveEvent = new EventDelegator( () => m_self.ReceiveReady += OnReceive, diff --git a/src/NetMQ/NetMQBeacon.cs b/src/NetMQ/NetMQBeacon.cs index 0a7195d05..94908de7d 100644 --- a/src/NetMQ/NetMQBeacon.cs +++ b/src/NetMQ/NetMQBeacon.cs @@ -1,10 +1,11 @@ using System; +using System.Diagnostics.CodeAnalysis; using System.Net; using System.Net.Sockets; +using System.Runtime.InteropServices; using System.Text; using System.Threading; using NetMQ.Sockets; -using System.Runtime.InteropServices; namespace NetMQ { @@ -199,7 +200,7 @@ private void OnUdpReady(Socket socket) { Assumes.NotNull(m_pipe); - if (!TryReceiveUdpFrame(out NetMQFrame frame, out string peerName)) + if (!TryReceiveUdpFrame(out NetMQFrame? frame, out string? peerName)) return; // If filter is set, check that beacon matches it @@ -279,7 +280,7 @@ private void SendUdpFrame(NetMQFrame frame) } } - private bool TryReceiveUdpFrame(out NetMQFrame frame, out string peerName) + private bool TryReceiveUdpFrame([NotNullWhen(returnValue: true)] out NetMQFrame? frame, [NotNullWhen(returnValue: true)] out string? peerName) { Assumes.NotNull(m_udpSocket); @@ -321,7 +322,7 @@ public NetMQBeacon() { m_actor = NetMQActor.Create(new Shim()); - void OnReceive(object sender, NetMQActorEventArgs e) => m_receiveEvent.Fire(this, new NetMQBeaconEventArgs(this)); + void OnReceive(object sender, NetMQActorEventArgs e) => m_receiveEvent!.Fire(this, new NetMQBeaconEventArgs(this)); m_receiveEvent = new EventDelegator( () => m_actor.ReceiveReady += OnReceive, diff --git a/src/NetMQ/NetMQCertificate.cs b/src/NetMQ/NetMQCertificate.cs index 1cb17f0b1..6c028bac9 100644 --- a/src/NetMQ/NetMQCertificate.cs +++ b/src/NetMQ/NetMQCertificate.cs @@ -36,7 +36,7 @@ private string Z85Encode(byte[] data) { byte byte_nbr = 0; UInt32 value = 0; - string dest = null; + string? dest = null; while (byte_nbr @@ -61,9 +61,8 @@ private string Z85Encode(byte[] data) /// /// key in Z85 format /// If key in invalid - byte[] Z85Decode(string key) + private byte[] Z85Decode(string key) { - UInt32 byte_nbr = 0; UInt32 char_nbr = 0; UInt32 value = 0; var dest_ = new List(); @@ -253,9 +252,9 @@ public static NetMQCertificate FromPublicKey(string publicKey) /// - /// Curve Public key + /// Curve Secret key, encoded. /// - public string SecretKeyZ85 => SecretKey != null ? Z85Encode(SecretKey) : null; + public string? SecretKeyZ85 => SecretKey != null ? Z85Encode(SecretKey) : null; /// @@ -264,16 +263,13 @@ public static NetMQCertificate FromPublicKey(string publicKey) public bool HasSecretKey => SecretKey != null; /// - /// Curve Public key + /// Curve Public key. /// public byte[] PublicKey { get; private set; } /// - /// Curve Public key + /// Curve Public key, encoded. /// - public string PublicKeyZ85 - { - get => Z85Encode(PublicKey); - } + public string PublicKeyZ85 => Z85Encode(PublicKey); } } \ No newline at end of file diff --git a/src/NetMQ/OutgoingSocketExtensions.cs b/src/NetMQ/OutgoingSocketExtensions.cs index 33bbd4237..3e2260f77 100644 --- a/src/NetMQ/OutgoingSocketExtensions.cs +++ b/src/NetMQ/OutgoingSocketExtensions.cs @@ -695,12 +695,13 @@ public static bool TrySendFrame(this IOutgoingSocket socket, TimeSpan timeout, R public static IOutgoingSocket SendEmptyRoutingKeys(this IOutgoingSocket socket) { return socket.SendMoreFrameEmpty(); - } + } /// /// Send a single routing key over , append an empty message afterwards. /// /// the IOutgoingSocket to transmit on + /// the routing keys to send public static IOutgoingSocket SendRoutingKeys(this IOutgoingSocket socket, params RoutingKey[] routingKeys) { foreach(var routingKey in routingKeys) diff --git a/src/Performance/NetMQ.SimpleTests/NetMQ.SimpleTests.csproj b/src/Performance/NetMQ.SimpleTests/NetMQ.SimpleTests.csproj index b25890560..5b436fe47 100644 --- a/src/Performance/NetMQ.SimpleTests/NetMQ.SimpleTests.csproj +++ b/src/Performance/NetMQ.SimpleTests/NetMQ.SimpleTests.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1 + net6.0 Exe diff --git a/src/Performance/local_lat/local_lat.csproj b/src/Performance/local_lat/local_lat.csproj index b25890560..5b436fe47 100644 --- a/src/Performance/local_lat/local_lat.csproj +++ b/src/Performance/local_lat/local_lat.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1 + net6.0 Exe diff --git a/src/Performance/local_thr/local_thr.csproj b/src/Performance/local_thr/local_thr.csproj index b25890560..5b436fe47 100644 --- a/src/Performance/local_thr/local_thr.csproj +++ b/src/Performance/local_thr/local_thr.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1 + net6.0 Exe diff --git a/src/Performance/remote_lat/remote_lat.csproj b/src/Performance/remote_lat/remote_lat.csproj index 3b73936a9..9f459061a 100644 --- a/src/Performance/remote_lat/remote_lat.csproj +++ b/src/Performance/remote_lat/remote_lat.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1 + net6.0 Exe diff --git a/src/Performance/remote_thr/remote_thr.csproj b/src/Performance/remote_thr/remote_thr.csproj index b25890560..5b436fe47 100644 --- a/src/Performance/remote_thr/remote_thr.csproj +++ b/src/Performance/remote_thr/remote_thr.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1 + net6.0 Exe