Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMatthewLayton committed Nov 16, 2024
2 parents bbd3a8f + ef5a401 commit a33bbf1
Show file tree
Hide file tree
Showing 148 changed files with 790 additions and 704 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
14 changes: 11 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
<Project>
<PropertyGroup>
<Version>9.5.1</Version>
<PackageVersion>9.5.1</PackageVersion>
<AssemblyVersion>9.5.1</AssemblyVersion>
<TargetFramework>net9.0</TargetFramework>
<LangVersion>13</LangVersion>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>ONIXLabs</Authors>
<NeutralLanguage>en</NeutralLanguage>
<Copyright>Copyright © ONIXLabs 2020</Copyright>
<RepositoryUrl>https://github.com/onix-labs/onixlabs-dotnet</RepositoryUrl>
<Version>10.0.0</Version>
<PackageVersion>10.0.0</PackageVersion>
<AssemblyVersion>10.0.0</AssemblyVersion>
</PropertyGroup>
</Project>
2 changes: 2 additions & 0 deletions OnixLabs.Core.UnitTests.Data/BufferSegment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Buffers;
using System.Linq;

namespace OnixLabs.Core.UnitTests.Data;

Expand Down
3 changes: 3 additions & 0 deletions OnixLabs.Core.UnitTests.Data/Disposable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Threading.Tasks;

namespace OnixLabs.Core.UnitTests.Data;

public sealed class Disposable : IDisposable, IAsyncDisposable
Expand Down
2 changes: 2 additions & 0 deletions OnixLabs.Core.UnitTests.Data/InvalidFormatProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;

namespace OnixLabs.Core.UnitTests.Data;

public sealed class InvalidFormatProvider : IFormatProvider
Expand Down
1 change: 1 addition & 0 deletions OnixLabs.Core.UnitTests.Data/Numeric.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Numerics;

namespace OnixLabs.Core.UnitTests.Data;
Expand Down
14 changes: 5 additions & 9 deletions OnixLabs.Core.UnitTests.Data/OnixLabs.Core.UnitTests.Data.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<LangVersion>12</LangVersion>
<IsTestProject>false</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand All @@ -20,9 +16,9 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OnixLabs.Core\OnixLabs.Core.csproj"/>
<ProjectReference Include="..\OnixLabs.Core\OnixLabs.Core.csproj" />
</ItemGroup>
<ItemGroup>
<Using Include="OnixLabs.Core.Preconditions" Static="True"/>
<Using Include="OnixLabs.Core.Preconditions" Static="True" />
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions OnixLabs.Core.UnitTests.Data/Record.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System.Collections.Generic;

namespace OnixLabs.Core.UnitTests.Data;

public sealed record Record<T>(string Text, int Number, T Value, IEnumerable<T>? Values = null);
72 changes: 32 additions & 40 deletions OnixLabs.Core.UnitTests/Collections/CollectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,11 @@ namespace OnixLabs.Core.UnitTests.Collections;

public sealed class CollectionTests
{
private static readonly object[] EnumerableInitializers = [true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23];

private static readonly int[] NumericInitializers = [123, 456, 789, 0, 1, -1, -987, 123, 456, 789, 0, 1, -1, -987];

private static readonly KeyValuePair<object, object?>[] DictionaryInitializers =
[
new KeyValuePair<object, object?>(123, true),
new KeyValuePair<object, object?>("abc", null),
new KeyValuePair<object, object?>(123.45f, "value")
];
[new(123, true), new("abc", null), new(123.45f, "value")];

private static readonly KeyValuePair<string, object>[] SortedDictionaryInitializers =
[
new KeyValuePair<string, object>("key1", 123),
new KeyValuePair<string, object>("key2", false),
new KeyValuePair<string, object>("key3", "abc")
];
[new("key1", 123), new("key2", false), new("key3", "abc")];

[Fact(DisplayName = "Collections.EmptyEnumerable should produce the expected result")]
public void CollectionsEmptyEnumerableShouldProduceTheExpectedResult()
Expand Down Expand Up @@ -231,8 +219,8 @@ public void CollectionsEmptyImmutableQueueShouldProduceTheExpectedResult()
public void CollectionsEnumerableOfShouldReturnTheExpectedResult()
{
// Given
IEnumerable<object> expected = EnumerableInitializers;
IEnumerable<object> actual = EnumerableOf(EnumerableInitializers);
IEnumerable<object> expected = [true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23];
IEnumerable<object> actual = EnumerableOf<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);

// Then
Assert.True(expected.SequenceEqual(actual));
Expand All @@ -242,8 +230,8 @@ public void CollectionsEnumerableOfShouldReturnTheExpectedResult()
public void CollectionsArrayOfShouldReturnTheExpectedResult()
{
// Given
object[] expected = EnumerableInitializers.ToArray();
object[] actual = ArrayOf(EnumerableInitializers);
object[] expected = [true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23];
object[] actual = ArrayOf<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);

// Then
Assert.True(expected.SequenceEqual(actual));
Expand All @@ -253,8 +241,8 @@ public void CollectionsArrayOfShouldReturnTheExpectedResult()
public void CollectionsImmutableArrayOfShouldReturnTheExpectedResult()
{
// Given
ImmutableArray<object> expected = [..EnumerableInitializers];
ImmutableArray<object> actual = ImmutableArrayOf(EnumerableInitializers);
ImmutableArray<object> expected = [true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23];
ImmutableArray<object> actual = ImmutableArrayOf<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);

// Then
Assert.True(expected.SequenceEqual(actual));
Expand All @@ -264,8 +252,8 @@ public void CollectionsImmutableArrayOfShouldReturnTheExpectedResult()
public void CollectionsListOfShouldReturnTheExpectedResult()
{
// Given
List<object> expected = [..EnumerableInitializers];
List<object> actual = ListOf(EnumerableInitializers);
List<object> expected = [true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23];
List<object> actual = ListOf<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);

// Then
Assert.True(expected.SequenceEqual(actual));
Expand All @@ -275,8 +263,8 @@ public void CollectionsListOfShouldReturnTheExpectedResult()
public void CollectionsImmutableListOfShouldReturnTheExpectedResult()
{
// Given
ImmutableList<object> expected = ImmutableList.Create(EnumerableInitializers);
ImmutableList<object> actual = ImmutableListOf(EnumerableInitializers);
ImmutableList<object> expected = ImmutableList.Create<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);
ImmutableList<object> actual = ImmutableListOf<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);

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

// Then
// ReSharper disable once UsageOfDefaultStructEquality
Assert.True(expected.SequenceEqual(actual));
}

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

// Then
// ReSharper disable once UsageOfDefaultStructEquality
Assert.True(expected.SequenceEqual(actual));
}

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

// Then
// ReSharper disable once UsageOfDefaultStructEquality
Assert.True(expected.SequenceEqual(actual));
}

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

// Then
// ReSharper disable once UsageOfDefaultStructEquality
Assert.True(expected.SequenceEqual(actual));
}

[Fact(DisplayName = "Collections.HashSetOf should return the expected result")]
public void CollectionsHashSetOfShouldReturnTheExpectedResult()
{
// Given
HashSet<object> expected = [..EnumerableInitializers];
HashSet<object> actual = HashSetOf(EnumerableInitializers);
HashSet<object> expected = [true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23];
HashSet<object> actual = HashSetOf<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);

// Then
Assert.True(expected.SequenceEqual(actual));
Expand All @@ -342,8 +334,8 @@ public void CollectionsHashSetOfShouldReturnTheExpectedResult()
public void CollectionsImmutableHashSetOfShouldReturnTheExpectedResult()
{
// Given
ImmutableHashSet<object> expected = ImmutableHashSet.Create(EnumerableInitializers);
ImmutableHashSet<object> actual = ImmutableHashSetOf(EnumerableInitializers);
ImmutableHashSet<object> expected = ImmutableHashSet.Create<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);
ImmutableHashSet<object> actual = ImmutableHashSetOf<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);

// Then
Assert.True(expected.SequenceEqual(actual));
Expand All @@ -353,8 +345,8 @@ public void CollectionsImmutableHashSetOfShouldReturnTheExpectedResult()
public void CollectionsSortedSetOfShouldReturnTheExpectedResult()
{
// Given
SortedSet<int> expected = new(NumericInitializers);
SortedSet<int> actual = SortedSetOf(NumericInitializers);
SortedSet<int> expected = new([123, 456, 789, 0, 1, -1, -987, 123, 456, 789, 0, 1, -1, -987]);
SortedSet<int> actual = SortedSetOf(123, 456, 789, 0, 1, -1, -987, 123, 456, 789, 0, 1, -1, -987);

// Then
Assert.True(expected.SequenceEqual(actual));
Expand All @@ -364,8 +356,8 @@ public void CollectionsSortedSetOfShouldReturnTheExpectedResult()
public void CollectionsImmutableSortedSetOfShouldReturnTheExpectedResult()
{
// Given
ImmutableSortedSet<int> expected = ImmutableSortedSet.Create(NumericInitializers);
ImmutableSortedSet<int> actual = ImmutableSortedSetOf(NumericInitializers);
ImmutableSortedSet<int> expected = ImmutableSortedSet.Create(123, 456, 789, 0, 1, -1, -987, 123, 456, 789, 0, 1, -1, -987);
ImmutableSortedSet<int> actual = ImmutableSortedSetOf(123, 456, 789, 0, 1, -1, -987, 123, 456, 789, 0, 1, -1, -987);

// Then
Assert.True(expected.SequenceEqual(actual));
Expand All @@ -375,8 +367,8 @@ public void CollectionsImmutableSortedSetOfShouldReturnTheExpectedResult()
public void CollectionsStackOfShouldReturnTheExpectedResult()
{
// Given
Stack<object> expected = new(EnumerableInitializers);
Stack<object> actual = StackOf(EnumerableInitializers);
Stack<object> expected = new([true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23]);
Stack<object> actual = StackOf<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);

// Then
Assert.True(expected.SequenceEqual(actual));
Expand All @@ -386,8 +378,8 @@ public void CollectionsStackOfShouldReturnTheExpectedResult()
public void CollectionsImmutableStackOfShouldReturnTheExpectedResult()
{
// Given
ImmutableStack<object> expected = ImmutableStack.Create(EnumerableInitializers);
ImmutableStack<object> actual = ImmutableStackOf(EnumerableInitializers);
ImmutableStack<object> expected = ImmutableStack.Create<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);
ImmutableStack<object> actual = ImmutableStackOf<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);

// Then
Assert.True(expected.SequenceEqual(actual));
Expand All @@ -397,8 +389,8 @@ public void CollectionsImmutableStackOfShouldReturnTheExpectedResult()
public void CollectionsQueueOfShouldReturnTheExpectedResult()
{
// Given
Queue<object> expected = new(EnumerableInitializers);
Queue<object> actual = QueueOf(EnumerableInitializers);
Queue<object> expected = new([true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23]);
Queue<object> actual = QueueOf<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);

// Then
Assert.True(expected.SequenceEqual(actual));
Expand All @@ -408,8 +400,8 @@ public void CollectionsQueueOfShouldReturnTheExpectedResult()
public void CollectionsImmutableQueueOfShouldReturnTheExpectedResult()
{
// Given
ImmutableQueue<object> expected = ImmutableQueue.Create(EnumerableInitializers);
ImmutableQueue<object> actual = ImmutableQueueOf(EnumerableInitializers);
ImmutableQueue<object> expected = ImmutableQueue.Create<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);
ImmutableQueue<object> actual = ImmutableQueueOf<object>(true, false, 123, "abc", 1.23, true, false, 123, "abc", 1.23);

// Then
Assert.True(expected.SequenceEqual(actual));
Expand Down
16 changes: 7 additions & 9 deletions OnixLabs.Core.UnitTests/OnixLabs.Core.UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<LangVersion>12</LangVersion>
<Nullable>enable</Nullable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand All @@ -18,10 +16,10 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OnixLabs.Core.UnitTests.Data\OnixLabs.Core.UnitTests.Data.csproj"/>
<ProjectReference Include="..\OnixLabs.Core\OnixLabs.Core.csproj"/>
<ProjectReference Include="..\OnixLabs.Core.UnitTests.Data\OnixLabs.Core.UnitTests.Data.csproj" />
<ProjectReference Include="..\OnixLabs.Core\OnixLabs.Core.csproj" />
</ItemGroup>
<ItemGroup>
<Using Include="OnixLabs.Core.Preconditions" Static="True"/>
<Using Include="OnixLabs.Core.Preconditions" Static="True" />
</ItemGroup>
</Project>
25 changes: 0 additions & 25 deletions OnixLabs.Core.UnitTests/Reflection/TypeExtensionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,6 @@ namespace OnixLabs.Core.UnitTests.Reflection;

public sealed class TypeExtensionTests
{
#pragma warning disable CS0618 // Type or member is obsolete
[Theory(DisplayName = "Type.GetName should produce the expected result")]
[InlineData(typeof(object), TypeNameFlags.None, "Object")]
[InlineData(typeof(List<>), TypeNameFlags.None, "List")]
[InlineData(typeof(Dictionary<,>), TypeNameFlags.None, "Dictionary")]
[InlineData(typeof(object), TypeNameFlags.UseFullNames, "System.Object")]
[InlineData(typeof(List<>), TypeNameFlags.UseFullNames, "System.Collections.Generic.List")]
[InlineData(typeof(Dictionary<,>), TypeNameFlags.UseFullNames, "System.Collections.Generic.Dictionary")]
[InlineData(typeof(object), TypeNameFlags.UseGenericTypeArguments, "Object")]
[InlineData(typeof(List<>), TypeNameFlags.UseGenericTypeArguments, "List<>")]
[InlineData(typeof(Dictionary<,>), TypeNameFlags.UseGenericTypeArguments, "Dictionary<>")]
[InlineData(typeof(List<Action<int>>), TypeNameFlags.UseGenericTypeArguments, "List<Action<Int32>>")]
[InlineData(typeof(Dictionary<string, ISet<Guid>>), TypeNameFlags.UseGenericTypeArguments, "Dictionary<String, ISet<Guid>>")]
[InlineData(typeof(List<Action<int>>), TypeNameFlags.All, "System.Collections.Generic.List<System.Action<System.Int32>>")]
[InlineData(typeof(Dictionary<string, ISet<Guid>>), TypeNameFlags.All, "System.Collections.Generic.Dictionary<System.String, System.Collections.Generic.ISet<System.Guid>>")]
public void TypeGetNameShouldProduceExpectedResult(Type type, TypeNameFlags flags, string expected)
{
// When
string actual = type.GetName(flags);

// Then
Assert.Equal(expected, actual);
}
#pragma warning restore CS0618 // Type or member is obsolete

[Theory(DisplayName = "Type.GetCSharpTypeDeclaration should produce the expected result")]
[InlineData(typeof(byte), TypeDeclarationFlags.None, "Byte")]
[InlineData(typeof(byte), TypeDeclarationFlags.UseNamespaceQualifiedTypeNames, "System.Byte")]
Expand Down
Loading

0 comments on commit a33bbf1

Please sign in to comment.