Smdn.Fundamental.SIPrefix version 3.0.2
smdn
released this
20 Feb 14:10
·
1969 commits
to main
since this release
Packages
Changes in this release
Change log
- 2022-02-20 update assembly version
- 2022-02-07 use .NET SDK API symbols instead
- 2022-02-05 use int.TryParse(ReadOnlySpan) instead
- 2022-02-04 refactor
- 2022-02-04 specify NumberFormatInfo explicitly
- 2022-02-04 use invariant format provider
- 2022-02-04 fix warning CA1305; specify string format provider
- 2022-02-04 fix warning CA1305; use string interpolation instead
- 2022-01-02 define PackageTags
- 2022-01-02 refactor assembly attributes and package properties
API diff
API diff in this release
diff --git a/doc/api-list/Smdn.Fundamental.SIPrefix/Smdn.Fundamental.SIPrefix-net45.apilist.cs b/doc/api-list/Smdn.Fundamental.SIPrefix/Smdn.Fundamental.SIPrefix-net45.apilist.cs
index 066bd7a5..065bb0d0 100644
--- a/doc/api-list/Smdn.Fundamental.SIPrefix/Smdn.Fundamental.SIPrefix-net45.apilist.cs
+++ b/doc/api-list/Smdn.Fundamental.SIPrefix/Smdn.Fundamental.SIPrefix-net45.apilist.cs
@@ -1,34 +1,34 @@
-// Smdn.Fundamental.SIPrefix.dll (Smdn.Fundamental.SIPrefix-3.0.1 (net45))
+// Smdn.Fundamental.SIPrefix.dll (Smdn.Fundamental.SIPrefix-3.0.2)
// Name: Smdn.Fundamental.SIPrefix
-// AssemblyVersion: 3.0.1.0
-// InformationalVersion: 3.0.1 (net45)
+// AssemblyVersion: 3.0.2.0
+// InformationalVersion: 3.0.2+cad54ee930add3f092e48bc1f76c04e0d3e20f1b
// TargetFramework: .NETFramework,Version=v4.5
// Configuration: Release
using System;
using System.Globalization;
using Smdn.Formats;
namespace Smdn.Formats {
[TypeForwardedFrom("Smdn, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null")]
public class SIPrefixNumberFormatter :
ICustomFormatter,
IFormatProvider
{
protected SIPrefixNumberFormatter(CultureInfo cultureInfo, bool isReadOnly) {}
public SIPrefixNumberFormatter() {}
public SIPrefixNumberFormatter(CultureInfo cultureInfo) {}
public string ByteUnit { get; set; }
public string ByteUnitAbbreviation { get; set; }
public static SIPrefixNumberFormatter CurrentInfo { get; }
public static SIPrefixNumberFormatter InvaliantInfo { get; }
public bool IsReadOnly { get; }
public string PrefixUnitDelimiter { get; set; }
public string ValuePrefixDelimiter { get; set; }
public string Format(string format, object arg, IFormatProvider formatProvider) {}
public object GetFormat(Type formatType) {}
}
}
diff --git a/doc/api-list/Smdn.Fundamental.SIPrefix/Smdn.Fundamental.SIPrefix-netstandard1.6.apilist.cs b/doc/api-list/Smdn.Fundamental.SIPrefix/Smdn.Fundamental.SIPrefix-netstandard1.6.apilist.cs
index 81b7194f..84f2ac04 100644
--- a/doc/api-list/Smdn.Fundamental.SIPrefix/Smdn.Fundamental.SIPrefix-netstandard1.6.apilist.cs
+++ b/doc/api-list/Smdn.Fundamental.SIPrefix/Smdn.Fundamental.SIPrefix-netstandard1.6.apilist.cs
@@ -1,34 +1,34 @@
-// Smdn.Fundamental.SIPrefix.dll (Smdn.Fundamental.SIPrefix-3.0.1 (netstandard1.6))
+// Smdn.Fundamental.SIPrefix.dll (Smdn.Fundamental.SIPrefix-3.0.2)
// Name: Smdn.Fundamental.SIPrefix
-// AssemblyVersion: 3.0.1.0
-// InformationalVersion: 3.0.1 (netstandard1.6)
+// AssemblyVersion: 3.0.2.0
+// InformationalVersion: 3.0.2+cad54ee930add3f092e48bc1f76c04e0d3e20f1b
// TargetFramework: .NETStandard,Version=v1.6
// Configuration: Release
using System;
using System.Globalization;
using Smdn.Formats;
namespace Smdn.Formats {
[TypeForwardedFrom("Smdn, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null")]
public class SIPrefixNumberFormatter :
ICustomFormatter,
IFormatProvider
{
protected SIPrefixNumberFormatter(CultureInfo cultureInfo, bool isReadOnly) {}
public SIPrefixNumberFormatter() {}
public SIPrefixNumberFormatter(CultureInfo cultureInfo) {}
public string ByteUnit { get; set; }
public string ByteUnitAbbreviation { get; set; }
public static SIPrefixNumberFormatter CurrentInfo { get; }
public static SIPrefixNumberFormatter InvaliantInfo { get; }
public bool IsReadOnly { get; }
public string PrefixUnitDelimiter { get; set; }
public string ValuePrefixDelimiter { get; set; }
public string Format(string format, object arg, IFormatProvider formatProvider) {}
public object GetFormat(Type formatType) {}
}
}
diff --git a/doc/api-list/Smdn.Fundamental.SIPrefix/Smdn.Fundamental.SIPrefix-netstandard2.1.apilist.cs b/doc/api-list/Smdn.Fundamental.SIPrefix/Smdn.Fundamental.SIPrefix-netstandard2.1.apilist.cs
index 8419946f..02ade243 100644
--- a/doc/api-list/Smdn.Fundamental.SIPrefix/Smdn.Fundamental.SIPrefix-netstandard2.1.apilist.cs
+++ b/doc/api-list/Smdn.Fundamental.SIPrefix/Smdn.Fundamental.SIPrefix-netstandard2.1.apilist.cs
@@ -1,34 +1,34 @@
-// Smdn.Fundamental.SIPrefix.dll (Smdn.Fundamental.SIPrefix-3.0.1 (netstandard2.1))
+// Smdn.Fundamental.SIPrefix.dll (Smdn.Fundamental.SIPrefix-3.0.2)
// Name: Smdn.Fundamental.SIPrefix
-// AssemblyVersion: 3.0.1.0
-// InformationalVersion: 3.0.1 (netstandard2.1)
+// AssemblyVersion: 3.0.2.0
+// InformationalVersion: 3.0.2+cad54ee930add3f092e48bc1f76c04e0d3e20f1b
// TargetFramework: .NETStandard,Version=v2.1
// Configuration: Release
using System;
using System.Globalization;
using Smdn.Formats;
namespace Smdn.Formats {
[TypeForwardedFrom("Smdn, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null")]
public class SIPrefixNumberFormatter :
ICustomFormatter,
IFormatProvider
{
protected SIPrefixNumberFormatter(CultureInfo cultureInfo, bool isReadOnly) {}
public SIPrefixNumberFormatter() {}
public SIPrefixNumberFormatter(CultureInfo cultureInfo) {}
public string ByteUnit { get; set; }
public string ByteUnitAbbreviation { get; set; }
public static SIPrefixNumberFormatter CurrentInfo { get; }
public static SIPrefixNumberFormatter InvaliantInfo { get; }
public bool IsReadOnly { get; }
public string PrefixUnitDelimiter { get; set; }
public string ValuePrefixDelimiter { get; set; }
public string Format(string format, object arg, IFormatProvider formatProvider) {}
public object GetFormat(Type formatType) {}
}
}
Changes
Changes in this release
diff --git a/src/Smdn.Fundamental.SIPrefix/Smdn.Formats/SIPrefixNumberFormatter.cs b/src/Smdn.Fundamental.SIPrefix/Smdn.Formats/SIPrefixNumberFormatter.cs
index 4ead405e..815aff81 100644
--- a/src/Smdn.Fundamental.SIPrefix/Smdn.Formats/SIPrefixNumberFormatter.cs
+++ b/src/Smdn.Fundamental.SIPrefix/Smdn.Formats/SIPrefixNumberFormatter.cs
@@ -24,6 +24,8 @@ public class SIPrefixNumberFormatter : IFormatProvider, ICustomFormatter {
*/
public bool IsReadOnly { get; }
+ private readonly NumberFormatInfo numberFormatInfo;
+
private string byteUnit;
public string ByteUnit {
@@ -71,12 +73,12 @@ public class SIPrefixNumberFormatter : IFormatProvider, ICustomFormatter {
throw new ArgumentNullException(nameof(cultureInfo));
this.IsReadOnly = isReadOnly;
- // this.cultureInfo = cultureInfo;
const string singleSpace = " ";
switch (cultureInfo.TwoLetterISOLanguageName) {
case "ja":
+ numberFormatInfo = cultureInfo.NumberFormat;
byteUnit = "バイト";
valuePrefixDelimiter = singleSpace;
prefixUnitDelimiter = string.Empty;
@@ -85,6 +87,7 @@ public class SIPrefixNumberFormatter : IFormatProvider, ICustomFormatter {
break;
default:
+ numberFormatInfo = NumberFormatInfo.InvariantInfo;
byteUnit = "Bytes";
valuePrefixDelimiter = singleSpace;
prefixUnitDelimiter = singleSpace;
@@ -140,8 +143,12 @@ public class SIPrefixNumberFormatter : IFormatProvider, ICustomFormatter {
if (format.Length == 1)
digits = 0;
+#if SYSTEM_INUMBER_TRYPARSE_READONLYSPAN_OF_CHAR
+ else if (!int.TryParse(format.AsSpan(1), out digits) || digits < 0)
+#else
else if (!int.TryParse(format.Substring(1), out digits) || digits < 0)
- throw new FormatException(string.Format("The specified format '{0}' is invalid", format));
+#endif
+ throw new FormatException($"The specified format '{format}' is invalid");
decimal sign;
@@ -165,18 +172,25 @@ public class SIPrefixNumberFormatter : IFormatProvider, ICustomFormatter {
string unitString = null;
if (fileSizeFormat) {
- if (aux == 0)
- ret.Append(val.ToString("F0"));
- else
- ret.Append(val.ToString("F1"));
+ ret.Append(
+ val.ToString(
+ aux == 0 ? "F0" : "F1",
+ numberFormatInfo
+ )
+ );
unitString = abbreviate ? byteUnitAbbreviation : byteUnit;
}
else {
- if (digits == 0)
- ret.Append(((long)val).ToString("D"));
- else
- ret.Append(val.ToString("F" + digits.ToString()));
+ ret.Append(
+ digits switch {
+ 0 => ((long)val).ToString("D", numberFormatInfo),
+ _ => val.ToString(
+ "F" + digits.ToString("D", provider: NumberFormatInfo.InvariantInfo),
+ numberFormatInfo
+ ),
+ }
+ );
}
if (!abbreviate && 0 < prefixes[aux].Length)
diff --git a/src/Smdn.Fundamental.SIPrefix/Smdn.Fundamental.SIPrefix.csproj b/src/Smdn.Fundamental.SIPrefix/Smdn.Fundamental.SIPrefix.csproj
index c54d64fd..181e80ef 100644
--- a/src/Smdn.Fundamental.SIPrefix/Smdn.Fundamental.SIPrefix.csproj
+++ b/src/Smdn.Fundamental.SIPrefix/Smdn.Fundamental.SIPrefix.csproj
@@ -5,15 +5,16 @@ SPDX-License-Identifier: MIT
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net45;netstandard2.1;netstandard1.6</TargetFrameworks>
- <VersionPrefix>3.0.1</VersionPrefix>
+ <VersionPrefix>3.0.2</VersionPrefix>
<VersionSuffix></VersionSuffix>
<PackageValidationBaselineVersion>3.0.0</PackageValidationBaselineVersion>
</PropertyGroup>
- <PropertyGroup Label="metadata">
+ <PropertyGroup Label="assembly attributes">
<CopyrightYear>2021</CopyrightYear>
+ </PropertyGroup>
- <!-- NuGet -->
- <!--<PackageTags></PackageTags>-->
+ <PropertyGroup Label="package properties">
+ <PackageTags>SI-prefixes;binary-prefix;unit-prefix;number-formatter;ICustomFormatter</PackageTags>
</PropertyGroup>
</Project>
What's Changed
Full Changelog: releases/Smdn.Fundamental.PrintableEncoding.MimeEncoding-3.0.2...releases/Smdn.Fundamental.SIPrefix-3.0.2