diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index c701ade8..4bd1da1a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -8,7 +8,7 @@ "ghcr.io/devcontainers/features/docker-in-docker:2": {}, "ghcr.io/devcontainers/features/dotnet:2": { "version": "latest", - "additionalVersions": "9.0.100-preview.3.24204.13" + "additionalVersions": "lts" } }, "customizations": { diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index de24051e..9a0c1d74 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -26,11 +26,7 @@ jobs: - name: Setup .NET SDK uses: actions/setup-dotnet@v4 with: - dotnet-version: | - 6.x - 7.x - 8.x - 9.x + dotnet-version: 9.0.x - name: dotnet info run: dotnet --info - name: build diff --git a/.github/workflows/docfx.yml b/.github/workflows/docfx.yml index d995b6a7..a30cb446 100644 --- a/.github/workflows/docfx.yml +++ b/.github/workflows/docfx.yml @@ -15,11 +15,7 @@ jobs: - name: Setup .NET SDK uses: actions/setup-dotnet@v4 with: - dotnet-version: | - 6.0.x - 7.0.x - 8.0.x - 9.0.x + dotnet-version: 9.0.x - name: install DocFX run: "dotnet tool install -g docfx" - name: Build docs diff --git a/.github/workflows/dotnet-format.yml b/.github/workflows/dotnet-format.yml index a4cfe980..e5284d3b 100644 --- a/.github/workflows/dotnet-format.yml +++ b/.github/workflows/dotnet-format.yml @@ -14,11 +14,7 @@ jobs: - name: Setup .NET SDK uses: actions/setup-dotnet@v4 with: - dotnet-version: | - 6.0.x - 7.0.x - 8.0.x - 9.0.x + dotnet-version: 9.0.x - name: build run: dotnet build - name: format diff --git a/Directory.Packages.props b/Directory.Packages.props index b76325da..e15ba918 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,7 +5,7 @@ 6.0.0 7.0.0 8.0.0 - 9.0.0-rc.2.24473.5 + 9.0.0 @@ -17,7 +17,7 @@ - + @@ -31,11 +31,11 @@ - - - + + + - + diff --git a/build/version.props b/build/version.props index 6ee8eb75..5d41e2bd 100644 --- a/build/version.props +++ b/build/version.props @@ -2,7 +2,7 @@ 1 0 - 71 + 72 $(VersionMajor).$(VersionMinor).$(VersionPatch) diff --git a/perf/WeihanLi.Common.Benchmark/Program.cs b/perf/WeihanLi.Common.Benchmark/Program.cs index d2031867..2ff5f38f 100644 --- a/perf/WeihanLi.Common.Benchmark/Program.cs +++ b/perf/WeihanLi.Common.Benchmark/Program.cs @@ -1,6 +1,4 @@ using BenchmarkDotNet.Running; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; namespace WeihanLi.Common.Benchmark; @@ -8,13 +6,6 @@ public class Program { public static void Main(string[] args) { - var configurationBuilder = new ConfigurationBuilder(); - configurationBuilder.AddJsonFile("appsettings.json"); - - var serviceCollection = new ServiceCollection(); - serviceCollection.AddSingleton(configurationBuilder.Build()); - DependencyResolver.SetDependencyResolver(serviceCollection); - // BenchmarkRunner.Run(); // BenchmarkRunner.Run(); // BenchmarkRunner.Run(); diff --git a/perf/WeihanLi.Common.Benchmark/WeihanLi.Common.Benchmark.csproj b/perf/WeihanLi.Common.Benchmark/WeihanLi.Common.Benchmark.csproj index 65d68f4a..249b7ed5 100644 --- a/perf/WeihanLi.Common.Benchmark/WeihanLi.Common.Benchmark.csproj +++ b/perf/WeihanLi.Common.Benchmark/WeihanLi.Common.Benchmark.csproj @@ -3,7 +3,7 @@ Exe true - net8.0 + net9.0 True disable @@ -15,12 +15,5 @@ - - - - - - Always - \ No newline at end of file diff --git a/perf/WeihanLi.Common.Benchmark/appsettings.json b/perf/WeihanLi.Common.Benchmark/appsettings.json deleted file mode 100644 index 4b7a15e0..00000000 --- a/perf/WeihanLi.Common.Benchmark/appsettings.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "TestSetting": { - "Setting1": "AAA" - }, - "Logging": { - "IncludeScopes": false, - "LogLevel": { - "Default": "Warning" - } - } -} \ No newline at end of file diff --git a/samples/AspNetCoreSample/AspNetCoreSample.csproj b/samples/AspNetCoreSample/AspNetCoreSample.csproj index 8723dd4b..8575608e 100644 --- a/samples/AspNetCoreSample/AspNetCoreSample.csproj +++ b/samples/AspNetCoreSample/AspNetCoreSample.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 diff --git a/samples/DotNetCoreSample/DotNetCoreSample.csproj b/samples/DotNetCoreSample/DotNetCoreSample.csproj index a3094282..3224f196 100644 --- a/samples/DotNetCoreSample/DotNetCoreSample.csproj +++ b/samples/DotNetCoreSample/DotNetCoreSample.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net9.0 diff --git a/src/WeihanLi.Common/Helpers/CommandLineParser.cs b/src/WeihanLi.Common/Helpers/CommandLineParser.cs index 80f13849..f573ed34 100644 --- a/src/WeihanLi.Common/Helpers/CommandLineParser.cs +++ b/src/WeihanLi.Common/Helpers/CommandLineParser.cs @@ -14,6 +14,7 @@ public static IEnumerable ParseLine(string line, LineParseOptions? optio { yield break; } + options ??= new(); var tokenBuilder = new StringBuilder(); @@ -91,9 +92,9 @@ public static IEnumerable ParseLine(string line, LineParseOptions? optio /// /// Get argument value from arguments /// - /// default argument value when not found /// argument name to get value /// arguments + /// default argument value when not found /// argument value [return: NotNullIfNotNull(nameof(defaultValue))] public static string? Val(string optionName, string[]? args = null, string? defaultValue = default) @@ -104,6 +105,19 @@ public static IEnumerable ParseLine(string line, LineParseOptions? optio /// /// Get argument value from arguments /// + /// argument name to get value + /// default argument value when not found + /// arguments + /// argument value + [return: NotNullIfNotNull(nameof(defaultValue))] + public static string? Val(string optionName, string? defaultValue, string[]? args = null) + { + return GetValueInternal(args ?? Environment.GetCommandLineArgs(), optionName) ?? defaultValue; + } + + /// + /// Get argument value from arguments + /// /// arguments /// default argument value when not found /// argument name to get value @@ -113,11 +127,17 @@ public static IEnumerable ParseLine(string line, LineParseOptions? optio { return GetValueInternal(args, optionName) ?? defaultValue; } + public static bool BooleanVal(string optionName, string[]? args = null, bool defaultValue = default) { return GetValueInternal(args ?? Environment.GetCommandLineArgs(), optionName).ToBoolean(defaultValue); } + public static bool BooleanVal(string optionName, bool defaultValue = default, string[]? args = null) + { + return GetValueInternal(args ?? Environment.GetCommandLineArgs(), optionName).ToBoolean(defaultValue); + } + public static bool BooleanVal(string[] args, string optionName, bool defaultValue = default) { return GetValueInternal(args, optionName).ToBoolean(defaultValue); diff --git a/src/WeihanLi.Common/Helpers/ConcurrentSet.cs b/src/WeihanLi.Common/Helpers/ConcurrentSet.cs index f0863dec..03350206 100644 --- a/src/WeihanLi.Common/Helpers/ConcurrentSet.cs +++ b/src/WeihanLi.Common/Helpers/ConcurrentSet.cs @@ -5,7 +5,8 @@ namespace WeihanLi.Common.Helpers; public sealed class ConcurrentSet : IReadOnlyCollection, ICollection where T : notnull { - private readonly ConcurrentDictionary _dictionary = new(); + // https://github.com/dotnet/runtime/issues/39919#issuecomment-954774092 + private readonly ConcurrentDictionary _dictionary = new(); public bool IsEmpty => _dictionary.IsEmpty; @@ -15,7 +16,7 @@ public sealed class ConcurrentSet : IReadOnlyCollection, ICollection wh public bool Contains(T item) => _dictionary.ContainsKey(item); - public bool TryAdd(T t) => _dictionary.TryAdd(t, null); + public bool TryAdd(T t) => _dictionary.TryAdd(t, default); public bool TryRemove(T t) => _dictionary.TryRemove(t, out _); diff --git a/test/WeihanLi.Common.Test/WeihanLi.Common.Test.csproj b/test/WeihanLi.Common.Test/WeihanLi.Common.Test.csproj index 9cfebfd2..b911470a 100644 --- a/test/WeihanLi.Common.Test/WeihanLi.Common.Test.csproj +++ b/test/WeihanLi.Common.Test/WeihanLi.Common.Test.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 true false