Skip to content

Smdn.Net.MuninNode version 1.0.0-beta5

Pre-release
Pre-release
Compare
Choose a tag to compare
@smdn smdn released this 10 Mar 14:04
· 110 commits to main since this release
595c8c9

Released package

Release notes

The full release notes are available at gist.

Change log

Change log in this release:

API changes

API changes in this release:
diff --git a/doc/api-list/Smdn.Net.MuninNode/Smdn.Net.MuninNode-net5.0.apilist.cs b/doc/api-list/Smdn.Net.MuninNode/Smdn.Net.MuninNode-net5.0.apilist.cs
deleted file mode 100644
index 1b9ef3b..0000000
--- a/doc/api-list/Smdn.Net.MuninNode/Smdn.Net.MuninNode-net5.0.apilist.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-// Smdn.Net.MuninNode.dll (Smdn.Net.MuninNode-1.0.0-beta4)
-//   Name: Smdn.Net.MuninNode
-//   AssemblyVersion: 1.0.0.0
-//   InformationalVersion: 1.0.0-beta4+74ac45a2d17aefc7af0d7f2108fee3bf66ef7192
-//   TargetFramework: .NETCoreApp,Version=v5.0
-//   Configuration: Release
-
-using System;
-using System.Collections.Generic;
-using System.Net;
-using System.Threading.Tasks;
-using Smdn.Net.MuninPlugin;
-
-namespace Smdn.Net.MuninNode {
-  public class LocalNode : IDisposable {
-    public LocalNode(IReadOnlyList<Plugin> plugins, string hostName, TimeSpan timeout, int portNumber, Version nodeVersion = null, IServiceProvider serviceProvider = null) {}
-
-    public string HostName { get; }
-    public IPEndPoint LocalEndPoint { get; }
-    public IReadOnlyList<Plugin> Plugins { get; }
-    public TimeSpan Timeout { get; }
-
-    [AsyncStateMachine]
-    public Task AcceptClientAsync() {}
-    public void Close() {}
-    protected virtual void Dispose(bool disposing) {}
-    public void Dispose() {}
-    public void Start() {}
-  }
-}
-
-namespace Smdn.Net.MuninPlugin {
-  public class Plugin {
-    public Plugin(string name, PluginGraphConfiguration graphConfiguration, PluginFieldConfiguration fieldConfiguration) {}
-
-    public PluginFieldConfiguration FieldConfiguration { get; }
-    public PluginGraphConfiguration GraphConfiguration { get; }
-    public string Name { get; }
-  }
-
-  public abstract class PluginFieldConfiguration {
-    protected PluginFieldConfiguration(string defaultGraphStyle, Range? warningValueRange = null, Range? criticalValueRange = null) {}
-
-    public Range? CriticalValueRange { get; }
-    public string DefaultGraphStyle { get; }
-    public Range? WarningValueRange { get; }
-
-    public abstract IEnumerable<PluginField> FetchFields();
-  }
-
-  public class PluginGraphConfiguration {
-    public PluginGraphConfiguration(string title, string category, string verticalLabel, bool scale, string arguments, TimeSpan updateRate, int? width = null, int? height = null) {}
-
-    public string Arguments { get; }
-    public string Category { get; }
-    public int? Height { get; }
-    public bool Scale { get; }
-    public string Title { get; }
-    public TimeSpan UpdateRate { get; }
-    public string VerticalLabel { get; }
-    public int? Width { get; }
-  }
-
-  public readonly struct PluginField {
-    public PluginField(string label, double @value, string graphStyle = null) {}
-    public PluginField(string name, string label, double @value, string graphStyle = null) {}
-
-    public string GraphStyle { get; }
-    public string Label { get; }
-    public string Name { get; }
-    public double? Value { get; }
-
-    public static PluginField CreateUnknownValueField(string label, string graphStyle = null) {}
-    public static PluginField CreateUnknownValueField(string name, string label, string graphStyle = null) {}
-  }
-}
-
diff --git a/doc/api-list/Smdn.Net.MuninNode/Smdn.Net.MuninNode-net6.0.apilist.cs b/doc/api-list/Smdn.Net.MuninNode/Smdn.Net.MuninNode-net6.0.apilist.cs
index 3b7dc7e..000c131 100644
--- a/doc/api-list/Smdn.Net.MuninNode/Smdn.Net.MuninNode-net6.0.apilist.cs
+++ b/doc/api-list/Smdn.Net.MuninNode/Smdn.Net.MuninNode-net6.0.apilist.cs
@@ -1,90 +1,91 @@
-// Smdn.Net.MuninNode.dll (Smdn.Net.MuninNode-1.0.0-beta4)
+// Smdn.Net.MuninNode.dll (Smdn.Net.MuninNode-1.0.0-beta5)
 //   Name: Smdn.Net.MuninNode
 //   AssemblyVersion: 1.0.0.0
-//   InformationalVersion: 1.0.0-beta4+74ac45a2d17aefc7af0d7f2108fee3bf66ef7192
+//   InformationalVersion: 1.0.0-beta5+9c35db93d2d4c37becbd2bed7ecdb74bc254a9ad
 //   TargetFramework: .NETCoreApp,Version=v6.0
 //   Configuration: Release
 //   Referenced assemblies:
 //     Microsoft.Extensions.DependencyInjection.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
 //     Microsoft.Extensions.Logging.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
 //     Smdn.Fundamental.Exception, Version=3.0.0.0, Culture=neutral
 //     System.Collections, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
 //     System.ComponentModel, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
 //     System.IO.Pipelines, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
 //     System.Linq, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
 //     System.Memory, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
 //     System.Net.Primitives, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
 //     System.Net.Sockets, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
 //     System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
 //     System.Text.RegularExpressions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+#nullable enable annotations
 
 using System;
 using System.Collections.Generic;
 using System.Net;
 using System.Threading.Tasks;
 using Smdn.Net.MuninPlugin;
 
 namespace Smdn.Net.MuninNode {
   public class LocalNode : IDisposable {
-    public LocalNode(IReadOnlyList<Plugin> plugins, string hostName, TimeSpan timeout, int portNumber, Version nodeVersion = null, IServiceProvider serviceProvider = null) {}
+    public LocalNode(IReadOnlyList<Plugin> plugins, string hostName, TimeSpan timeout, int portNumber, Version? nodeVersion = null, IServiceProvider? serviceProvider = null) {}
 
     public string HostName { get; }
     public IPEndPoint LocalEndPoint { get; }
     public IReadOnlyList<Plugin> Plugins { get; }
     public TimeSpan Timeout { get; }
 
     public async Task AcceptClientAsync() {}
     public void Close() {}
     protected virtual void Dispose(bool disposing) {}
     public void Dispose() {}
     public void Start() {}
   }
 }
 
 namespace Smdn.Net.MuninPlugin {
   public class Plugin {
     public Plugin(string name, PluginGraphConfiguration graphConfiguration, PluginFieldConfiguration fieldConfiguration) {}
 
     public PluginFieldConfiguration FieldConfiguration { get; }
     public PluginGraphConfiguration GraphConfiguration { get; }
     public string Name { get; }
   }
 
   public abstract class PluginFieldConfiguration {
     protected PluginFieldConfiguration(string defaultGraphStyle, Range? warningValueRange = null, Range? criticalValueRange = null) {}
 
     public Range? CriticalValueRange { get; }
     public string DefaultGraphStyle { get; }
     public Range? WarningValueRange { get; }
 
     public abstract IEnumerable<PluginField> FetchFields();
   }
 
   public class PluginGraphConfiguration {
     public PluginGraphConfiguration(string title, string category, string verticalLabel, bool scale, string arguments, TimeSpan updateRate, int? width = null, int? height = null) {}
 
     public string Arguments { get; }
     public string Category { get; }
     public int? Height { get; }
     public bool Scale { get; }
     public string Title { get; }
     public TimeSpan UpdateRate { get; }
     public string VerticalLabel { get; }
     public int? Width { get; }
   }
 
   public readonly struct PluginField {
-    public static PluginField CreateUnknownValueField(string label, string graphStyle = null) {}
-    public static PluginField CreateUnknownValueField(string name, string label, string graphStyle = null) {}
+    public static PluginField CreateUnknownValueField(string label, string? graphStyle = null) {}
+    public static PluginField CreateUnknownValueField(string name, string label, string? graphStyle = null) {}
 
-    public PluginField(string label, double @value, string graphStyle = null) {}
-    public PluginField(string name, string label, double @value, string graphStyle = null) {}
+    public PluginField(string label, double @value, string? graphStyle = null) {}
+    public PluginField(string name, string label, double @value, string? graphStyle = null) {}
 
-    public string GraphStyle { get; }
+    public string? GraphStyle { get; }
     public string Label { get; }
     public string Name { get; }
     public double? Value { get; }
   }
 }
 // API list generated by Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks v1.2.1.0.
 // Smdn.Reflection.ReverseGenerating.ListApi.Core v1.2.0.0 (https://github.com/smdn/Smdn.Reflection.ReverseGenerating)
diff --git a/doc/api-list/Smdn.Net.MuninNode/Smdn.Net.MuninNode-netstandard2.1.apilist.cs b/doc/api-list/Smdn.Net.MuninNode/Smdn.Net.MuninNode-netstandard2.1.apilist.cs
index a1ab77a..e960842 100644
--- a/doc/api-list/Smdn.Net.MuninNode/Smdn.Net.MuninNode-netstandard2.1.apilist.cs
+++ b/doc/api-list/Smdn.Net.MuninNode/Smdn.Net.MuninNode-netstandard2.1.apilist.cs
@@ -1,84 +1,85 @@
-// Smdn.Net.MuninNode.dll (Smdn.Net.MuninNode-1.0.0-beta4)
+// Smdn.Net.MuninNode.dll (Smdn.Net.MuninNode-1.0.0-beta5)
 //   Name: Smdn.Net.MuninNode
 //   AssemblyVersion: 1.0.0.0
-//   InformationalVersion: 1.0.0-beta4+74ac45a2d17aefc7af0d7f2108fee3bf66ef7192
+//   InformationalVersion: 1.0.0-beta5+9c35db93d2d4c37becbd2bed7ecdb74bc254a9ad
 //   TargetFramework: .NETStandard,Version=v2.1
 //   Configuration: Release
 //   Referenced assemblies:
 //     Microsoft.Extensions.DependencyInjection.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
 //     Microsoft.Extensions.Logging.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
 //     Smdn.Fundamental.Encoding.Buffer, Version=3.0.0.0, Culture=neutral
 //     Smdn.Fundamental.Exception, Version=3.0.0.0, Culture=neutral
 //     System.IO.Pipelines, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
 //     netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
+#nullable enable annotations
 
 using System;
 using System.Collections.Generic;
 using System.Net;
 using System.Threading.Tasks;
 using Smdn.Net.MuninPlugin;
 
 namespace Smdn.Net.MuninNode {
   public class LocalNode : IDisposable {
-    public LocalNode(IReadOnlyList<Plugin> plugins, string hostName, TimeSpan timeout, int portNumber, Version nodeVersion = null, IServiceProvider serviceProvider = null) {}
+    public LocalNode(IReadOnlyList<Plugin> plugins, string hostName, TimeSpan timeout, int portNumber, Version? nodeVersion = null, IServiceProvider? serviceProvider = null) {}
 
     public string HostName { get; }
     public IPEndPoint LocalEndPoint { get; }
     public IReadOnlyList<Plugin> Plugins { get; }
     public TimeSpan Timeout { get; }
 
     public async Task AcceptClientAsync() {}
     public void Close() {}
     protected virtual void Dispose(bool disposing) {}
     public void Dispose() {}
     public void Start() {}
   }
 }
 
 namespace Smdn.Net.MuninPlugin {
   public class Plugin {
     public Plugin(string name, PluginGraphConfiguration graphConfiguration, PluginFieldConfiguration fieldConfiguration) {}
 
     public PluginFieldConfiguration FieldConfiguration { get; }
     public PluginGraphConfiguration GraphConfiguration { get; }
     public string Name { get; }
   }
 
   public abstract class PluginFieldConfiguration {
     protected PluginFieldConfiguration(string defaultGraphStyle, Range? warningValueRange = null, Range? criticalValueRange = null) {}
 
     public Range? CriticalValueRange { get; }
     public string DefaultGraphStyle { get; }
     public Range? WarningValueRange { get; }
 
     public abstract IEnumerable<PluginField> FetchFields();
   }
 
   public class PluginGraphConfiguration {
     public PluginGraphConfiguration(string title, string category, string verticalLabel, bool scale, string arguments, TimeSpan updateRate, int? width = null, int? height = null) {}
 
     public string Arguments { get; }
     public string Category { get; }
     public int? Height { get; }
     public bool Scale { get; }
     public string Title { get; }
     public TimeSpan UpdateRate { get; }
     public string VerticalLabel { get; }
     public int? Width { get; }
   }
 
   public readonly struct PluginField {
-    public static PluginField CreateUnknownValueField(string label, string graphStyle = null) {}
-    public static PluginField CreateUnknownValueField(string name, string label, string graphStyle = null) {}
+    public static PluginField CreateUnknownValueField(string label, string? graphStyle = null) {}
+    public static PluginField CreateUnknownValueField(string name, string label, string? graphStyle = null) {}
 
-    public PluginField(string label, double @value, string graphStyle = null) {}
-    public PluginField(string name, string label, double @value, string graphStyle = null) {}
+    public PluginField(string label, double @value, string? graphStyle = null) {}
+    public PluginField(string name, string label, double @value, string? graphStyle = null) {}
 
-    public string GraphStyle { get; }
+    public string? GraphStyle { get; }
     public string Label { get; }
     public string Name { get; }
     public double? Value { get; }
   }
 }
 // API list generated by Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks v1.2.1.0.
 // Smdn.Reflection.ReverseGenerating.ListApi.Core v1.2.0.0 (https://github.com/smdn/Smdn.Reflection.ReverseGenerating)

Full changes

Full changes in this release:
diff --git a/src/Smdn.Net.MuninNode/Smdn.Net.MuninNode.csproj b/src/Smdn.Net.MuninNode/Smdn.Net.MuninNode.csproj
index 8a246f6..3eb82bc 100644
--- a/src/Smdn.Net.MuninNode/Smdn.Net.MuninNode.csproj
+++ b/src/Smdn.Net.MuninNode/Smdn.Net.MuninNode.csproj
@@ -4,10 +4,11 @@ SPDX-License-Identifier: MIT
 -->
 <Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
-    <TargetFrameworks>netstandard2.1;net5.0;net6.0</TargetFrameworks>
+    <TargetFrameworks>netstandard2.1;net6.0</TargetFrameworks>
     <VersionPrefix>1.0.0</VersionPrefix>
-    <VersionSuffix>beta4</VersionSuffix>
+    <VersionSuffix>beta5</VersionSuffix>
     <!-- <PackageValidationBaselineVersion>1.0.0</PackageValidationBaselineVersion> -->
+    <Nullable>enable</Nullable>
   </PropertyGroup>
 
   <PropertyGroup Condition=" '$(Configuration)' == 'Release' " Label="Required properties to generate API list">
diff --git a/src/Smdn.Net.MuninNode/Smdn.Net.MuninNode/LocalNode.cs b/src/Smdn.Net.MuninNode/Smdn.Net.MuninNode/LocalNode.cs
index ff0e474..2df9ac2 100644
--- a/src/Smdn.Net.MuninNode/Smdn.Net.MuninNode/LocalNode.cs
+++ b/src/Smdn.Net.MuninNode/Smdn.Net.MuninNode/LocalNode.cs
@@ -8,10 +8,6 @@
 #define ENABLE_IPv6
 #undef ENABLE_IPv6
 
-#if NET5_0_OR_GREATER
-#define SYSTEM_TEXT_ENCODINGEXTENSIONS
-#endif
-
 using System;
 using System.Buffers;
 using System.Collections.Generic;
@@ -42,7 +38,7 @@ public class LocalNode : IDisposable {
   public IPEndPoint LocalEndPoint { get; }
 
   private readonly Version nodeVersion;
-  private readonly ILogger logger;
+  private readonly ILogger? logger;
   private Socket server;
   private readonly Encoding encoding = Encoding.Default;
 
@@ -51,8 +47,8 @@ public class LocalNode : IDisposable {
     string hostName,
     TimeSpan timeout,
     int portNumber,
-    Version nodeVersion = null,
-    IServiceProvider serviceProvider = null
+    Version? nodeVersion = null,
+    IServiceProvider? serviceProvider = null
   )
   {
     Plugins = plugins ?? throw new ArgumentNullException(nameof(plugins));
@@ -106,7 +102,7 @@ public class LocalNode : IDisposable {
 
     server?.Disconnect(true);
     server?.Dispose();
-    server = null;
+    server = null!;
   }
 
   public void Close() => (this as IDisposable).Dispose();
@@ -130,7 +126,7 @@ public class LocalNode : IDisposable {
 
     try {
       if (client.RemoteEndPoint is not IPEndPoint remoteEndPoint) {
-        logger?.LogWarning($"cannot accept: {client.RemoteEndPoint.AddressFamily}");
+        logger?.LogWarning($"cannot accept: {client.RemoteEndPoint?.AddressFamily}");
         return;
       }
 
@@ -181,11 +177,20 @@ public class LocalNode : IDisposable {
 
           writer.Advance(bytesRead);
         }
-        catch (SocketException ex) when (ex.ErrorCode == 125) {
-          break; // expected exception (125: Operation canceled)
+        catch (SocketException ex) when (
+          ex.SocketErrorCode is
+            SocketError.OperationAborted or // ECANCELED (125)
+            SocketError.ConnectionReset // ECONNRESET (104)
+        ) {
+          logger?.LogWarning($"socket exception ({(int)ex.SocketErrorCode} {ex.SocketErrorCode})");
+          break; // expected exception
+        }
+        catch (ObjectDisposedException) {
+          logger?.LogWarning("socket has been disposed");
+          break; // expected exception
         }
         catch (Exception ex) {
-          logger?.LogCritical(ex, "unexpected exception");
+          logger?.LogCritical(ex, "unexpected exception while receiving");
           break;
         }
 
@@ -212,7 +217,7 @@ public class LocalNode : IDisposable {
         catch (Exception ex) {
           if (socket.Connected)
             socket.Close();
-          logger?.LogCritical(ex, "unexpected exception");
+          logger?.LogCritical(ex, "unexpected exception while processing command");
           break;
         }
 
@@ -236,7 +241,7 @@ public class LocalNode : IDisposable {
         return false;
       }
 
-#if NET5_0_OR_GREATER
+#if SYSTEM_BUFFERS_SEQUENCEREADER_UNREADSEQUENCE
       buffer = reader.UnreadSequence;
 #else
       buffer = reader.Sequence.Slice(reader.Position);
@@ -270,7 +275,7 @@ public class LocalNode : IDisposable {
     }
     else if (reader.IsNext(SP, advancePast: true)) {
       // <command> <SP> <arguments> <EOL>
-#if NET5_0_OR_GREATER
+#if SYSTEM_BUFFERS_SEQUENCEREADER_UNREADSEQUENCE
       arguments = reader.UnreadSequence;
 #else
       arguments = reader.Sequence.Slice(reader.Position);
@@ -309,7 +314,7 @@ public class LocalNode : IDisposable {
       (commandLine.Length == 1 && commandLine.FirstSpan[0] == commandQuitShort)
     ) {
       client.Close();
-#if NET5_0_OR_GREATER
+#if SYSTEM_THREADING_TASKS_VALUETASK_COMPLETEDTASK
       return ValueTask.CompletedTask;
 #else
       return default;
diff --git a/src/Smdn.Net.MuninNode/Smdn.Net.MuninPlugin/PluginField.cs b/src/Smdn.Net.MuninNode/Smdn.Net.MuninPlugin/PluginField.cs
index c4c8f04..3b949c3 100644
--- a/src/Smdn.Net.MuninNode/Smdn.Net.MuninPlugin/PluginField.cs
+++ b/src/Smdn.Net.MuninNode/Smdn.Net.MuninPlugin/PluginField.cs
@@ -13,7 +13,7 @@ public readonly struct PluginField {
   /// <summary>Gets a value for plugin field.</summary>
   /// <remarks>Reports 'UNKNOWN' as a plugin field value if <see cref="Value"/> is <see langword="null"/>.</remarks>
   public double? Value { get; }
-  public string GraphStyle { get; }
+  public string? GraphStyle { get; }
 
   internal string FormattedValueString => Value.HasValue
     ? Value.Value.ToString(provider: null) // TODO: format specifier
@@ -21,7 +21,7 @@ public readonly struct PluginField {
 
   public static PluginField CreateUnknownValueField(
     string label,
-    string graphStyle = null
+    string? graphStyle = null
   )
     => new(
       name: GetDefaultNameFromLabel(label),
@@ -33,7 +33,7 @@ public readonly struct PluginField {
   public static PluginField CreateUnknownValueField(
     string name,
     string label,
-    string graphStyle = null
+    string? graphStyle = null
   )
     => new(
       name: name,
@@ -45,7 +45,7 @@ public readonly struct PluginField {
   public PluginField(
     string label,
     double value,
-    string graphStyle = null
+    string? graphStyle = null
   )
     : this(GetDefaultNameFromLabel(label), label, (double?)value, graphStyle)
   {
@@ -55,7 +55,7 @@ public readonly struct PluginField {
     string name,
     string label,
     double value,
-    string graphStyle = null
+    string? graphStyle = null
   )
     : this(name, label, (double?)value, graphStyle)
   {
@@ -65,7 +65,7 @@ public readonly struct PluginField {
     string name,
     string label,
     double? value,
-    string graphStyle = null
+    string? graphStyle = null
   )
   {
     if (name == null)

Notes

Full Changelog: releases/Smdn.Net.MuninNode-1.0.0-beta4...releases/Smdn.Net.MuninNode-1.0.0-beta5