Skip to content

Commit 9002808

Browse files
committed
v0.7.3
1 parent 1ade205 commit 9002808

117 files changed

Lines changed: 21857 additions & 21972 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

benchmarks/EnumParserBenchmark.cs

Lines changed: 74 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -2,102 +2,101 @@
22
using BenchmarkDotNet.Order;
33
#pragma warning disable CA1822
44

5-
namespace NuExt.System.Benchmarks
5+
namespace NuExt.System.Benchmarks;
6+
7+
[Config(typeof(MultipleRuntimesConfig))]
8+
[MemoryDiagnoser]
9+
[Orderer(SummaryOrderPolicy.Declared)]
10+
[RankColumn]
11+
public class EnumParserBenchmark
612
{
7-
[Config(typeof(MultipleRuntimesConfig))]
8-
[MemoryDiagnoser]
9-
[Orderer(SummaryOrderPolicy.Declared)]
10-
[RankColumn]
11-
public class EnumParserBenchmark
12-
{
13-
private const string ValidKey = nameof(ConsoleKey.Applications);
14-
private const ConsoleKey ValidKeyValue = ConsoleKey.Applications;
15-
private const string InvalidKey = "App";
13+
private const string ValidKey = nameof(ConsoleKey.Applications);
14+
private const ConsoleKey ValidKeyValue = ConsoleKey.Applications;
15+
private const string InvalidKey = "App";
1616

17-
//GetValue/Parse Valid
17+
//GetValue/Parse Valid
1818

19-
[Benchmark]
20-
public void EnumHelper_GetValue_Valid()
21-
{
22-
var key = EnumHelper<ConsoleKey>.GetValue(ValidKey);
23-
ValidateResult(key, ValidKeyValue);
24-
}
19+
[Benchmark]
20+
public void EnumHelper_GetValue_Valid()
21+
{
22+
var key = EnumHelper<ConsoleKey>.GetValue(ValidKey);
23+
ValidateResult(key, ValidKeyValue);
24+
}
2525

26-
[Benchmark(Baseline = true)]
27-
public void Enum_Parse_Valid()
28-
{
29-
var key = (ConsoleKey)Enum.Parse(typeof(ConsoleKey), ValidKey);
30-
ValidateResult(key, ValidKeyValue);
31-
}
26+
[Benchmark(Baseline = true)]
27+
public void Enum_Parse_Valid()
28+
{
29+
var key = (ConsoleKey)Enum.Parse(typeof(ConsoleKey), ValidKey);
30+
ValidateResult(key, ValidKeyValue);
31+
}
3232

33-
//TryGetValue/TryParse Valid
33+
//TryGetValue/TryParse Valid
3434

35-
[Benchmark]
36-
public void EnumHelper_TryGetValue_Valid()
37-
{
38-
EnumHelper<ConsoleKey>.TryGetValue(ValidKey, out var key);
39-
ValidateResult(key, ValidKeyValue);
40-
}
35+
[Benchmark]
36+
public void EnumHelper_TryGetValue_Valid()
37+
{
38+
EnumHelper<ConsoleKey>.TryGetValue(ValidKey, out var key);
39+
ValidateResult(key, ValidKeyValue);
40+
}
4141

42-
[Benchmark]
43-
public void Enum_TryParse_Valid()
44-
{
45-
Enum.TryParse<ConsoleKey>(ValidKey, true, out var key);
46-
ValidateResult(key, ValidKeyValue);
47-
}
42+
[Benchmark]
43+
public void Enum_TryParse_Valid()
44+
{
45+
Enum.TryParse<ConsoleKey>(ValidKey, true, out var key);
46+
ValidateResult(key, ValidKeyValue);
47+
}
4848

49-
//GetValue/Parse Invalid
49+
//GetValue/Parse Invalid
5050

51-
[Benchmark]
52-
public void EnumHelper_GetValue_Invalid()
51+
[Benchmark]
52+
public void EnumHelper_GetValue_Invalid()
53+
{
54+
try
5355
{
54-
try
55-
{
56-
var key = EnumHelper<ConsoleKey>.GetValue(InvalidKey);
57-
ValidateResult(key, default);
58-
}
59-
catch (Exception)
60-
{
61-
// Expecting an exception as the key is invalid
62-
}
56+
var key = EnumHelper<ConsoleKey>.GetValue(InvalidKey);
57+
ValidateResult(key, default);
6358
}
64-
65-
[Benchmark]
66-
public void Enum_Parse_Invalid()
59+
catch (Exception)
6760
{
68-
try
69-
{
70-
var key = (ConsoleKey)Enum.Parse(typeof(ConsoleKey), InvalidKey, true);
71-
ValidateResult(key, default);
72-
}
73-
catch (Exception)
74-
{
75-
// Expecting an exception as the key is invalid
76-
}
61+
// Expecting an exception as the key is invalid
7762
}
63+
}
7864

79-
//TryGetValue/TryParse Invalid
80-
81-
[Benchmark]
82-
public void EnumHelper_TryGetValue_Invalid()
65+
[Benchmark]
66+
public void Enum_Parse_Invalid()
67+
{
68+
try
8369
{
84-
EnumHelper<ConsoleKey>.TryGetValue(InvalidKey, out var key);
70+
var key = (ConsoleKey)Enum.Parse(typeof(ConsoleKey), InvalidKey, true);
8571
ValidateResult(key, default);
8672
}
87-
88-
[Benchmark]
89-
public void Enum_TryParse_Invalid()
73+
catch (Exception)
9074
{
91-
Enum.TryParse<ConsoleKey>(InvalidKey, true, out var key);
92-
ValidateResult(key, default);
75+
// Expecting an exception as the key is invalid
9376
}
77+
}
9478

95-
private static void ValidateResult<TEnum>(TEnum actual, TEnum expected) where TEnum : struct, Enum
79+
//TryGetValue/TryParse Invalid
80+
81+
[Benchmark]
82+
public void EnumHelper_TryGetValue_Invalid()
83+
{
84+
EnumHelper<ConsoleKey>.TryGetValue(InvalidKey, out var key);
85+
ValidateResult(key, default);
86+
}
87+
88+
[Benchmark]
89+
public void Enum_TryParse_Invalid()
90+
{
91+
Enum.TryParse<ConsoleKey>(InvalidKey, true, out var key);
92+
ValidateResult(key, default);
93+
}
94+
95+
private static void ValidateResult<TEnum>(TEnum actual, TEnum expected) where TEnum : struct, Enum
96+
{
97+
if (!EqualityComparer<TEnum>.Default.Equals(actual, expected))
9698
{
97-
if (!EqualityComparer<TEnum>.Default.Equals(actual, expected))
98-
{
99-
throw new InvalidOperationException($"Expected {expected}, but got {actual}");
100-
}
99+
throw new InvalidOperationException($"Expected {expected}, but got {actual}");
101100
}
102101
}
103102
}

benchmarks/MultipleRuntimesConfig.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22
using BenchmarkDotNet.Environments;
33
using BenchmarkDotNet.Jobs;
44

5-
namespace NuExt.System.Benchmarks
5+
namespace NuExt.System.Benchmarks;
6+
7+
public class MultipleRuntimesConfig : ManualConfig
68
{
7-
public class MultipleRuntimesConfig : ManualConfig
9+
public MultipleRuntimesConfig()
810
{
9-
public MultipleRuntimesConfig()
10-
{
11-
AddJob(Job.Default.WithRuntime(ClrRuntime.Net462));
12-
AddJob(Job.Default.WithRuntime(CoreRuntime.Core80));
13-
AddJob(Job.Default.WithRuntime(CoreRuntime.Core90));
14-
AddJob(Job.Default.WithRuntime(CoreRuntime.Core10_0));
15-
}
11+
AddJob(Job.Default.WithRuntime(ClrRuntime.Net462));
12+
AddJob(Job.Default.WithRuntime(CoreRuntime.Core80));
13+
AddJob(Job.Default.WithRuntime(CoreRuntime.Core90));
14+
AddJob(Job.Default.WithRuntime(CoreRuntime.Core10_0));
1615
}
1716
}

benchmarks/NuExt.System.Benchmarks.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
<ItemGroup>
1212
<PackageReference Include="BenchmarkDotNet" Version="0.15.8" />
13-
<PackageReference Include="System.Collections.Immutable" Version="10.0.3" />
14-
<PackageReference Include="System.Reflection.Metadata" Version="10.0.3" />
13+
<PackageReference Include="System.Collections.Immutable" Version="10.0.5" />
14+
<PackageReference Include="System.Reflection.Metadata" Version="10.0.5" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

benchmarks/Program.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
using BenchmarkDotNet.Running;
22

3-
namespace NuExt.System.Benchmarks
3+
namespace NuExt.System.Benchmarks;
4+
5+
internal class Program
46
{
5-
internal class Program
7+
static void Main(string[] args)
68
{
7-
static void Main(string[] args)
8-
{
9-
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
10-
Console.ReadKey();
11-
}
9+
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
10+
Console.ReadKey();
1211
}
1312
}

src/NuExt.System.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<GeneratePackageOnBuild Condition="'$(Configuration)' == 'Release'">true</GeneratePackageOnBuild>
88
<PackageTags>nuext;extensions;async;asynclazy;asynceventhandler;asynclock;lockpool;asyncwaithandle;reentrantasynclock;disposable;asyncdisposable;lifetime;asynclifetime;valuestringbuilder;pathbuilder;valuepathbuilder;task;valuetask;observabledictionary;span;polyfills</PackageTags>
99
<Description>High‑performance foundational utilities for .NET, providing async/threading primitives, lifetime management tools, Span/Memory polyfills, fast path builders, diagnostics helpers, and essential collection utilities. Designed for correctness, speed, and consistent behavior across modern .NET and .NET Framework.</Description>
10-
<Version>0.7.2</Version>
10+
<Version>0.7.3</Version>
1111
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
1212
<RootNamespace />
1313
<GenerateDocumentationFile>True</GenerateDocumentationFile>
@@ -26,7 +26,7 @@
2626
</ItemGroup>
2727

2828
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1' or '$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'net462' or '$(TargetFramework)' == 'net471'">
29-
<PackageReference Include="System.Text.Json" Version="10.0.3" />
29+
<PackageReference Include="System.Text.Json" Version="10.0.5" />
3030
</ItemGroup>
3131

3232
<ItemGroup>

0 commit comments

Comments
 (0)