Skip to content

Commit a33bbf1

Browse files
Merge branch 'main' into release
2 parents bbd3a8f + ef5a401 commit a33bbf1

File tree

148 files changed

+790
-704
lines changed

Some content is hidden

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

148 files changed

+790
-704
lines changed

Diff for: .github/workflows/dotnet.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Setup .NET
2323
uses: actions/setup-dotnet@v1
2424
with:
25-
dotnet-version: 8.0.x
25+
dotnet-version: 9.0.x
2626
- name: Restore dependencies
2727
run: dotnet restore
2828
- name: Build

Diff for: Directory.Build.props

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>9.5.1</Version>
4-
<PackageVersion>9.5.1</PackageVersion>
5-
<AssemblyVersion>9.5.1</AssemblyVersion>
3+
<TargetFramework>net9.0</TargetFramework>
4+
<LangVersion>13</LangVersion>
5+
<Nullable>enable</Nullable>
6+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
7+
<Authors>ONIXLabs</Authors>
8+
<NeutralLanguage>en</NeutralLanguage>
9+
<Copyright>Copyright © ONIXLabs 2020</Copyright>
10+
<RepositoryUrl>https://github.com/onix-labs/onixlabs-dotnet</RepositoryUrl>
11+
<Version>10.0.0</Version>
12+
<PackageVersion>10.0.0</PackageVersion>
13+
<AssemblyVersion>10.0.0</AssemblyVersion>
614
</PropertyGroup>
715
</Project>

Diff for: OnixLabs.Core.UnitTests.Data/BufferSegment.cs

+2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
using System;
1516
using System.Buffers;
17+
using System.Linq;
1618

1719
namespace OnixLabs.Core.UnitTests.Data;
1820

Diff for: OnixLabs.Core.UnitTests.Data/Disposable.cs

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
using System;
16+
using System.Threading.Tasks;
17+
1518
namespace OnixLabs.Core.UnitTests.Data;
1619

1720
public sealed class Disposable : IDisposable, IAsyncDisposable

Diff for: OnixLabs.Core.UnitTests.Data/InvalidFormatProvider.cs

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
using System;
16+
1517
namespace OnixLabs.Core.UnitTests.Data;
1618

1719
public sealed class InvalidFormatProvider : IFormatProvider

Diff for: OnixLabs.Core.UnitTests.Data/Numeric.cs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
using System;
1516
using System.Numerics;
1617

1718
namespace OnixLabs.Core.UnitTests.Data;
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net8.0</TargetFramework>
4-
<ImplicitUsings>enable</ImplicitUsings>
5-
<Nullable>enable</Nullable>
63
<IsPackable>false</IsPackable>
7-
<LangVersion>12</LangVersion>
84
<IsTestProject>false</IsTestProject>
95
</PropertyGroup>
106
<ItemGroup>
11-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
12-
<PackageReference Include="xunit" Version="2.8.1" />
13-
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
7+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
8+
<PackageReference Include="xunit" Version="2.9.2" />
9+
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
1410
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1511
<PrivateAssets>all</PrivateAssets>
1612
</PackageReference>
@@ -20,9 +16,9 @@
2016
</PackageReference>
2117
</ItemGroup>
2218
<ItemGroup>
23-
<ProjectReference Include="..\OnixLabs.Core\OnixLabs.Core.csproj"/>
19+
<ProjectReference Include="..\OnixLabs.Core\OnixLabs.Core.csproj" />
2420
</ItemGroup>
2521
<ItemGroup>
26-
<Using Include="OnixLabs.Core.Preconditions" Static="True"/>
22+
<Using Include="OnixLabs.Core.Preconditions" Static="True" />
2723
</ItemGroup>
2824
</Project>

Diff for: OnixLabs.Core.UnitTests.Data/Record.cs

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
using System.Collections.Generic;
16+
1517
namespace OnixLabs.Core.UnitTests.Data;
1618

1719
public sealed record Record<T>(string Text, int Number, T Value, IEnumerable<T>? Values = null);

Diff for: OnixLabs.Core.UnitTests/Collections/CollectionTests.cs

+32-40
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,11 @@ namespace OnixLabs.Core.UnitTests.Collections;
2222

2323
public sealed class CollectionTests
2424
{
25-
private static readonly object[] EnumerableInitializers = [true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23];
26-
27-
private static readonly int[] NumericInitializers = [123, 456, 789, 0, 1, -1, -987, 123, 456, 789, 0, 1, -1, -987];
28-
2925
private static readonly KeyValuePair<object, object?>[] DictionaryInitializers =
30-
[
31-
new KeyValuePair<object, object?>(123, true),
32-
new KeyValuePair<object, object?>("abc", null),
33-
new KeyValuePair<object, object?>(123.45f, "value")
34-
];
26+
[new(123, true), new("abc", null), new(123.45f, "value")];
3527

3628
private static readonly KeyValuePair<string, object>[] SortedDictionaryInitializers =
37-
[
38-
new KeyValuePair<string, object>("key1", 123),
39-
new KeyValuePair<string, object>("key2", false),
40-
new KeyValuePair<string, object>("key3", "abc")
41-
];
29+
[new("key1", 123), new("key2", false), new("key3", "abc")];
4230

4331
[Fact(DisplayName = "Collections.EmptyEnumerable should produce the expected result")]
4432
public void CollectionsEmptyEnumerableShouldProduceTheExpectedResult()
@@ -231,8 +219,8 @@ public void CollectionsEmptyImmutableQueueShouldProduceTheExpectedResult()
231219
public void CollectionsEnumerableOfShouldReturnTheExpectedResult()
232220
{
233221
// Given
234-
IEnumerable<object> expected = EnumerableInitializers;
235-
IEnumerable<object> actual = EnumerableOf(EnumerableInitializers);
222+
IEnumerable<object> expected = [true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23];
223+
IEnumerable<object> actual = EnumerableOf<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);
236224

237225
// Then
238226
Assert.True(expected.SequenceEqual(actual));
@@ -242,8 +230,8 @@ public void CollectionsEnumerableOfShouldReturnTheExpectedResult()
242230
public void CollectionsArrayOfShouldReturnTheExpectedResult()
243231
{
244232
// Given
245-
object[] expected = EnumerableInitializers.ToArray();
246-
object[] actual = ArrayOf(EnumerableInitializers);
233+
object[] expected = [true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23];
234+
object[] actual = ArrayOf<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);
247235

248236
// Then
249237
Assert.True(expected.SequenceEqual(actual));
@@ -253,8 +241,8 @@ public void CollectionsArrayOfShouldReturnTheExpectedResult()
253241
public void CollectionsImmutableArrayOfShouldReturnTheExpectedResult()
254242
{
255243
// Given
256-
ImmutableArray<object> expected = [..EnumerableInitializers];
257-
ImmutableArray<object> actual = ImmutableArrayOf(EnumerableInitializers);
244+
ImmutableArray<object> expected = [true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23];
245+
ImmutableArray<object> actual = ImmutableArrayOf<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);
258246

259247
// Then
260248
Assert.True(expected.SequenceEqual(actual));
@@ -264,8 +252,8 @@ public void CollectionsImmutableArrayOfShouldReturnTheExpectedResult()
264252
public void CollectionsListOfShouldReturnTheExpectedResult()
265253
{
266254
// Given
267-
List<object> expected = [..EnumerableInitializers];
268-
List<object> actual = ListOf(EnumerableInitializers);
255+
List<object> expected = [true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23];
256+
List<object> actual = ListOf<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);
269257

270258
// Then
271259
Assert.True(expected.SequenceEqual(actual));
@@ -275,8 +263,8 @@ public void CollectionsListOfShouldReturnTheExpectedResult()
275263
public void CollectionsImmutableListOfShouldReturnTheExpectedResult()
276264
{
277265
// Given
278-
ImmutableList<object> expected = ImmutableList.Create(EnumerableInitializers);
279-
ImmutableList<object> actual = ImmutableListOf(EnumerableInitializers);
266+
ImmutableList<object> expected = ImmutableList.Create<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);
267+
ImmutableList<object> actual = ImmutableListOf<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);
280268

281269
// Then
282270
Assert.True(expected.SequenceEqual(actual));
@@ -290,6 +278,7 @@ public void CollectionsDictionaryOfShouldReturnTheExpectedResult()
290278
Dictionary<object, object?> actual = DictionaryOf(DictionaryInitializers);
291279

292280
// Then
281+
// ReSharper disable once UsageOfDefaultStructEquality
293282
Assert.True(expected.SequenceEqual(actual));
294283
}
295284

@@ -301,6 +290,7 @@ public void CollectionsImmutableDictionaryOfShouldReturnTheExpectedResult()
301290
ImmutableDictionary<object, object?> actual = ImmutableDictionaryOf(DictionaryInitializers);
302291

303292
// Then
293+
// ReSharper disable once UsageOfDefaultStructEquality
304294
Assert.True(expected.SequenceEqual(actual));
305295
}
306296

@@ -312,6 +302,7 @@ public void CollectionsSortedDictionaryOfShouldReturnTheExpectedResult()
312302
SortedDictionary<string, object> actual = SortedDictionaryOf(SortedDictionaryInitializers);
313303

314304
// Then
305+
// ReSharper disable once UsageOfDefaultStructEquality
315306
Assert.True(expected.SequenceEqual(actual));
316307
}
317308

@@ -324,15 +315,16 @@ public void CollectionsImmutableSortedDictionaryOfShouldReturnTheExpectedResult(
324315
ImmutableSortedDictionary<string, object> actual = ImmutableSortedDictionaryOf(SortedDictionaryInitializers);
325316

326317
// Then
318+
// ReSharper disable once UsageOfDefaultStructEquality
327319
Assert.True(expected.SequenceEqual(actual));
328320
}
329321

330322
[Fact(DisplayName = "Collections.HashSetOf should return the expected result")]
331323
public void CollectionsHashSetOfShouldReturnTheExpectedResult()
332324
{
333325
// Given
334-
HashSet<object> expected = [..EnumerableInitializers];
335-
HashSet<object> actual = HashSetOf(EnumerableInitializers);
326+
HashSet<object> expected = [true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23];
327+
HashSet<object> actual = HashSetOf<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);
336328

337329
// Then
338330
Assert.True(expected.SequenceEqual(actual));
@@ -342,8 +334,8 @@ public void CollectionsHashSetOfShouldReturnTheExpectedResult()
342334
public void CollectionsImmutableHashSetOfShouldReturnTheExpectedResult()
343335
{
344336
// Given
345-
ImmutableHashSet<object> expected = ImmutableHashSet.Create(EnumerableInitializers);
346-
ImmutableHashSet<object> actual = ImmutableHashSetOf(EnumerableInitializers);
337+
ImmutableHashSet<object> expected = ImmutableHashSet.Create<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);
338+
ImmutableHashSet<object> actual = ImmutableHashSetOf<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);
347339

348340
// Then
349341
Assert.True(expected.SequenceEqual(actual));
@@ -353,8 +345,8 @@ public void CollectionsImmutableHashSetOfShouldReturnTheExpectedResult()
353345
public void CollectionsSortedSetOfShouldReturnTheExpectedResult()
354346
{
355347
// Given
356-
SortedSet<int> expected = new(NumericInitializers);
357-
SortedSet<int> actual = SortedSetOf(NumericInitializers);
348+
SortedSet<int> expected = new([123, 456, 789, 0, 1, -1, -987, 123, 456, 789, 0, 1, -1, -987]);
349+
SortedSet<int> actual = SortedSetOf(123, 456, 789, 0, 1, -1, -987, 123, 456, 789, 0, 1, -1, -987);
358350

359351
// Then
360352
Assert.True(expected.SequenceEqual(actual));
@@ -364,8 +356,8 @@ public void CollectionsSortedSetOfShouldReturnTheExpectedResult()
364356
public void CollectionsImmutableSortedSetOfShouldReturnTheExpectedResult()
365357
{
366358
// Given
367-
ImmutableSortedSet<int> expected = ImmutableSortedSet.Create(NumericInitializers);
368-
ImmutableSortedSet<int> actual = ImmutableSortedSetOf(NumericInitializers);
359+
ImmutableSortedSet<int> expected = ImmutableSortedSet.Create(123, 456, 789, 0, 1, -1, -987, 123, 456, 789, 0, 1, -1, -987);
360+
ImmutableSortedSet<int> actual = ImmutableSortedSetOf(123, 456, 789, 0, 1, -1, -987, 123, 456, 789, 0, 1, -1, -987);
369361

370362
// Then
371363
Assert.True(expected.SequenceEqual(actual));
@@ -375,8 +367,8 @@ public void CollectionsImmutableSortedSetOfShouldReturnTheExpectedResult()
375367
public void CollectionsStackOfShouldReturnTheExpectedResult()
376368
{
377369
// Given
378-
Stack<object> expected = new(EnumerableInitializers);
379-
Stack<object> actual = StackOf(EnumerableInitializers);
370+
Stack<object> expected = new([true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23]);
371+
Stack<object> actual = StackOf<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);
380372

381373
// Then
382374
Assert.True(expected.SequenceEqual(actual));
@@ -386,8 +378,8 @@ public void CollectionsStackOfShouldReturnTheExpectedResult()
386378
public void CollectionsImmutableStackOfShouldReturnTheExpectedResult()
387379
{
388380
// Given
389-
ImmutableStack<object> expected = ImmutableStack.Create(EnumerableInitializers);
390-
ImmutableStack<object> actual = ImmutableStackOf(EnumerableInitializers);
381+
ImmutableStack<object> expected = ImmutableStack.Create<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);
382+
ImmutableStack<object> actual = ImmutableStackOf<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);
391383

392384
// Then
393385
Assert.True(expected.SequenceEqual(actual));
@@ -397,8 +389,8 @@ public void CollectionsImmutableStackOfShouldReturnTheExpectedResult()
397389
public void CollectionsQueueOfShouldReturnTheExpectedResult()
398390
{
399391
// Given
400-
Queue<object> expected = new(EnumerableInitializers);
401-
Queue<object> actual = QueueOf(EnumerableInitializers);
392+
Queue<object> expected = new([true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23]);
393+
Queue<object> actual = QueueOf<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);
402394

403395
// Then
404396
Assert.True(expected.SequenceEqual(actual));
@@ -408,8 +400,8 @@ public void CollectionsQueueOfShouldReturnTheExpectedResult()
408400
public void CollectionsImmutableQueueOfShouldReturnTheExpectedResult()
409401
{
410402
// Given
411-
ImmutableQueue<object> expected = ImmutableQueue.Create(EnumerableInitializers);
412-
ImmutableQueue<object> actual = ImmutableQueueOf(EnumerableInitializers);
403+
ImmutableQueue<object> expected = ImmutableQueue.Create<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);
404+
ImmutableQueue<object> actual = ImmutableQueueOf<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);
413405

414406
// Then
415407
Assert.True(expected.SequenceEqual(actual));
+7-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net8.0</TargetFramework>
43
<IsPackable>false</IsPackable>
5-
<LangVersion>12</LangVersion>
6-
<Nullable>enable</Nullable>
4+
<IsTestProject>true</IsTestProject>
75
</PropertyGroup>
86
<ItemGroup>
9-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
10-
<PackageReference Include="xunit" Version="2.8.1" />
11-
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
7+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
8+
<PackageReference Include="xunit" Version="2.9.2" />
9+
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
1210
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1311
<PrivateAssets>all</PrivateAssets>
1412
</PackageReference>
@@ -18,10 +16,10 @@
1816
</PackageReference>
1917
</ItemGroup>
2018
<ItemGroup>
21-
<ProjectReference Include="..\OnixLabs.Core.UnitTests.Data\OnixLabs.Core.UnitTests.Data.csproj"/>
22-
<ProjectReference Include="..\OnixLabs.Core\OnixLabs.Core.csproj"/>
19+
<ProjectReference Include="..\OnixLabs.Core.UnitTests.Data\OnixLabs.Core.UnitTests.Data.csproj" />
20+
<ProjectReference Include="..\OnixLabs.Core\OnixLabs.Core.csproj" />
2321
</ItemGroup>
2422
<ItemGroup>
25-
<Using Include="OnixLabs.Core.Preconditions" Static="True"/>
23+
<Using Include="OnixLabs.Core.Preconditions" Static="True" />
2624
</ItemGroup>
2725
</Project>

Diff for: OnixLabs.Core.UnitTests/Reflection/TypeExtensionTests.cs

-25
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,6 @@ namespace OnixLabs.Core.UnitTests.Reflection;
2121

2222
public sealed class TypeExtensionTests
2323
{
24-
#pragma warning disable CS0618 // Type or member is obsolete
25-
[Theory(DisplayName = "Type.GetName should produce the expected result")]
26-
[InlineData(typeof(object), TypeNameFlags.None, "Object")]
27-
[InlineData(typeof(List<>), TypeNameFlags.None, "List")]
28-
[InlineData(typeof(Dictionary<,>), TypeNameFlags.None, "Dictionary")]
29-
[InlineData(typeof(object), TypeNameFlags.UseFullNames, "System.Object")]
30-
[InlineData(typeof(List<>), TypeNameFlags.UseFullNames, "System.Collections.Generic.List")]
31-
[InlineData(typeof(Dictionary<,>), TypeNameFlags.UseFullNames, "System.Collections.Generic.Dictionary")]
32-
[InlineData(typeof(object), TypeNameFlags.UseGenericTypeArguments, "Object")]
33-
[InlineData(typeof(List<>), TypeNameFlags.UseGenericTypeArguments, "List<>")]
34-
[InlineData(typeof(Dictionary<,>), TypeNameFlags.UseGenericTypeArguments, "Dictionary<>")]
35-
[InlineData(typeof(List<Action<int>>), TypeNameFlags.UseGenericTypeArguments, "List<Action<Int32>>")]
36-
[InlineData(typeof(Dictionary<string, ISet<Guid>>), TypeNameFlags.UseGenericTypeArguments, "Dictionary<String, ISet<Guid>>")]
37-
[InlineData(typeof(List<Action<int>>), TypeNameFlags.All, "System.Collections.Generic.List<System.Action<System.Int32>>")]
38-
[InlineData(typeof(Dictionary<string, ISet<Guid>>), TypeNameFlags.All, "System.Collections.Generic.Dictionary<System.String, System.Collections.Generic.ISet<System.Guid>>")]
39-
public void TypeGetNameShouldProduceExpectedResult(Type type, TypeNameFlags flags, string expected)
40-
{
41-
// When
42-
string actual = type.GetName(flags);
43-
44-
// Then
45-
Assert.Equal(expected, actual);
46-
}
47-
#pragma warning restore CS0618 // Type or member is obsolete
48-
4924
[Theory(DisplayName = "Type.GetCSharpTypeDeclaration should produce the expected result")]
5025
[InlineData(typeof(byte), TypeDeclarationFlags.None, "Byte")]
5126
[InlineData(typeof(byte), TypeDeclarationFlags.UseNamespaceQualifiedTypeNames, "System.Byte")]

0 commit comments

Comments
 (0)