Skip to content

Commit 55da736

Browse files
Merge branch 'main' into release
# Conflicts: # build.sh
2 parents c7a905a + 18f6977 commit 55da736

File tree

128 files changed

+331
-542
lines changed

Some content is hidden

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

128 files changed

+331
-542
lines changed

Directory.Build.props

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<Project>
2+
3+
<!--GLOBAL-->
24
<PropertyGroup>
3-
<Version>12.1.1</Version>
4-
<PackageVersion>12.1.1</PackageVersion>
5-
<AssemblyVersion>12.1.1</AssemblyVersion>
5+
<Version>12.2.0</Version>
6+
<PackageVersion>12.2.0</PackageVersion>
7+
<AssemblyVersion>12.2.0</AssemblyVersion>
68
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
79
<LangVersion>13</LangVersion>
810
<Nullable>enable</Nullable>
@@ -11,5 +13,64 @@
1113
<NeutralLanguage>en</NeutralLanguage>
1214
<Copyright>Copyright © ONIXLabs 2020</Copyright>
1315
<RepositoryUrl>https://github.com/onix-labs/onixlabs-dotnet</RepositoryUrl>
16+
<ContinuousIntegrationBuild Condition="'$(CI)' == 'true'">true</ContinuousIntegrationBuild>
1417
</PropertyGroup>
18+
19+
<!--NUGET PACKAGES-->
20+
<PropertyGroup Condition="!$([System.String]::Copy('$(MSBuildProjectName)').EndsWith('.UnitTests')) and !$([System.String]::Copy('$(MSBuildProjectName)').EndsWith('.UnitTests.Data'))">
21+
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
22+
<DebugType>embedded</DebugType>
23+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
24+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
25+
<IncludeSymbols>true</IncludeSymbols>
26+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
27+
<PackageProjectUrl>https://github.com/onix-labs/onixlabs-dotnet</PackageProjectUrl>
28+
<PackageReadmeFile>README.md</PackageReadmeFile>
29+
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
30+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
31+
<RepositoryType>git</RepositoryType>
32+
</PropertyGroup>
33+
34+
<ItemGroup Condition="!$([System.String]::Copy('$(MSBuildProjectName)').EndsWith('.UnitTests')) and !$([System.String]::Copy('$(MSBuildProjectName)').EndsWith('.UnitTests.Data'))">
35+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
36+
<PrivateAssets>all</PrivateAssets>
37+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
38+
</PackageReference>
39+
<None Include="..\README.md" Pack="true" PackagePath="\"/>
40+
</ItemGroup>
41+
42+
<!--UNIT TESTS-->
43+
<PropertyGroup Condition="$([System.String]::Copy('$(MSBuildProjectName)').EndsWith('.UnitTests'))">
44+
<IsTestProject>true</IsTestProject>
45+
<IsPackable>false</IsPackable>
46+
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
47+
</PropertyGroup>
48+
49+
<ItemGroup Condition="$([System.String]::Copy('$(MSBuildProjectName)').EndsWith('.UnitTests'))">
50+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1"/>
51+
<PackageReference Include="xunit" Version="2.9.3"/>
52+
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2"/>
53+
<PackageReference Include="coverlet.collector" Version="6.0.4"/>
54+
<Using Include="Xunit"/>
55+
</ItemGroup>
56+
57+
<!--UNIT TEST DATA-->
58+
<PropertyGroup Condition="$([System.String]::Copy('$(MSBuildProjectName)').EndsWith('.UnitTests.Data'))">
59+
<IsTestProject>false</IsTestProject>
60+
<IsPackable>false</IsPackable>
61+
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
62+
</PropertyGroup>
63+
64+
<ItemGroup Condition="$([System.String]::Copy('$(MSBuildProjectName)').EndsWith('.UnitTests.Data'))">
65+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1"/>
66+
<PackageReference Include="xunit" Version="2.9.3"/>
67+
<Using Include="Xunit"/>
68+
</ItemGroup>
69+
70+
<!--PLAYGROUND-->
71+
<PropertyGroup Condition="'$(OutputType)' == 'Exe'">
72+
<IsPackable>false</IsPackable>
73+
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
74+
</PropertyGroup>
75+
1576
</Project>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2020-2025 ONIXLabs
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
namespace OnixLabs.Core.UnitTests.Data;
16+
17+
public sealed class Mutable
18+
{
19+
public required int Value { get; set; }
20+
}
Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<IsPackable>false</IsPackable>
43
<IsTestProject>false</IsTestProject>
54
</PropertyGroup>
6-
<ItemGroup>
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">
10-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
11-
<PrivateAssets>all</PrivateAssets>
12-
</PackageReference>
13-
<PackageReference Include="coverlet.collector" Version="6.0.2">
14-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
15-
<PrivateAssets>all</PrivateAssets>
16-
</PackageReference>
17-
</ItemGroup>
185
<ItemGroup>
196
<ProjectReference Include="..\OnixLabs.Core\OnixLabs.Core.csproj" />
207
</ItemGroup>
21-
<ItemGroup>
22-
<Using Include="OnixLabs.Core.Preconditions" Static="True" />
23-
</ItemGroup>
248
</Project>

OnixLabs.Core.UnitTests/ArrayExtensionTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// limitations under the License.
1414

1515
using System.Text;
16-
using Xunit;
1716

1817
namespace OnixLabs.Core.UnitTests;
1918

OnixLabs.Core.UnitTests/Collections/CollectionTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
using System.Collections.Generic;
1616
using System.Collections.Immutable;
1717
using System.Linq;
18-
using Xunit;
1918
using static OnixLabs.Core.Collections.Collection;
2019

2120
namespace OnixLabs.Core.UnitTests.Collections;

OnixLabs.Core.UnitTests/DateTimeExtensionTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// limitations under the License.
1414

1515
using System;
16-
using Xunit;
1716

1817
namespace OnixLabs.Core.UnitTests;
1918

OnixLabs.Core.UnitTests/EnumerationTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
using System.Collections.Generic;
1616
using OnixLabs.Core.UnitTests.Data;
17-
using Xunit;
1817

1918
namespace OnixLabs.Core.UnitTests;
2019

OnixLabs.Core.UnitTests/Linq/IEnumerableExtensionTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
using System.Numerics;
2121
using OnixLabs.Core.Linq;
2222
using OnixLabs.Core.UnitTests.Data;
23-
using Xunit;
2423

2524
namespace OnixLabs.Core.UnitTests.Linq;
2625

OnixLabs.Core.UnitTests/ObjectExtensionTests.cs

Lines changed: 88 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,40 +15,36 @@
1515
using System;
1616
using System.Threading.Tasks;
1717
using OnixLabs.Core.UnitTests.Data;
18-
using Xunit;
1918

2019
namespace OnixLabs.Core.UnitTests;
2120

2221
public sealed class ObjectExtensionTests
2322
{
24-
[Theory(DisplayName = "IsWithinRangeInclusive should produce the expected result")]
25-
[InlineData(2, 1, 3, true)]
26-
[InlineData(1, 1, 3, true)]
27-
[InlineData(3, 1, 3, true)]
28-
[InlineData(0, 1, 3, false)]
29-
[InlineData(4, 1, 3, false)]
30-
public void IsWithinRangeInclusiveShouldProduceExpectedResult(int value, int min, int max, bool expected)
23+
[Fact(DisplayName = "Apply should produce the expected result (reference type)")]
24+
public void ApplyShouldProduceExpectedResultReferenceType()
3125
{
26+
// Given
27+
Mutable value = new() { Value = 123 };
28+
3229
// When
33-
bool actual = value.IsWithinRangeInclusive(min, max);
30+
Mutable result = value.Apply(it => it.Value = 456);
3431

3532
// Then
36-
Assert.Equal(expected, actual);
33+
Assert.Equal(456, value.Value);
34+
Assert.Same(value, result);
3735
}
3836

39-
[Theory(DisplayName = "IsWithinRangeExclusive should produce the expected result")]
40-
[InlineData(2, 1, 3, true)]
41-
[InlineData(1, 1, 3, false)]
42-
[InlineData(3, 1, 3, false)]
43-
[InlineData(0, 1, 3, false)]
44-
[InlineData(4, 1, 3, false)]
45-
public void IsWithinRangeExclusiveShouldProduceExpectedResult(int value, int min, int max, bool expected)
37+
[Fact(DisplayName = "Apply should produce the expected result (value type)")]
38+
public void ApplyShouldProduceExpectedResultValueType()
4639
{
40+
// Given
41+
int value = 123;
42+
4743
// When
48-
bool actual = value.IsWithinRangeExclusive(min, max);
44+
value = value.Apply(it => it * 2);
4945

5046
// Then
51-
Assert.Equal(expected, actual);
47+
Assert.Equal(246, value);
5248
}
5349

5450
[Fact(DisplayName = "CompareToObject should produce zero if the current IComparable<T> is equal to the specified object.")]
@@ -113,6 +109,51 @@ public void CompareToObjectShouldThrowArgumentExceptionIfSpecifiedObjectIsOfInco
113109
Assert.Equal("Object must be of type System.Int32 (Parameter 'right')", exception.Message);
114110
}
115111

112+
[Theory(DisplayName = "IsWithinRangeInclusive should produce the expected result")]
113+
[InlineData(2, 1, 3, true)]
114+
[InlineData(1, 1, 3, true)]
115+
[InlineData(3, 1, 3, true)]
116+
[InlineData(0, 1, 3, false)]
117+
[InlineData(4, 1, 3, false)]
118+
public void IsWithinRangeInclusiveShouldProduceExpectedResult(int value, int min, int max, bool expected)
119+
{
120+
// When
121+
bool actual = value.IsWithinRangeInclusive(min, max);
122+
123+
// Then
124+
Assert.Equal(expected, actual);
125+
}
126+
127+
[Theory(DisplayName = "IsWithinRangeExclusive should produce the expected result")]
128+
[InlineData(2, 1, 3, true)]
129+
[InlineData(1, 1, 3, false)]
130+
[InlineData(3, 1, 3, false)]
131+
[InlineData(0, 1, 3, false)]
132+
[InlineData(4, 1, 3, false)]
133+
public void IsWithinRangeExclusiveShouldProduceExpectedResult(int value, int min, int max, bool expected)
134+
{
135+
// When
136+
bool actual = value.IsWithinRangeExclusive(min, max);
137+
138+
// Then
139+
Assert.Equal(expected, actual);
140+
}
141+
142+
[Fact(DisplayName = "Let should produce the expected result")]
143+
public void LetShouldProduceExpectedResult()
144+
{
145+
// Given
146+
const string value = "123";
147+
148+
// When
149+
int result = value
150+
.Let(int.Parse)
151+
.Let(it => it * 2);
152+
153+
// Then
154+
Assert.Equal(246, result);
155+
}
156+
116157
[Fact(DisplayName = "ToRecordString should produce null when the object is null")]
117158
public void ToRecordStringShouldProduceNullWhenObjectIsNull()
118159
{
@@ -361,4 +402,32 @@ public async Task ToSuccessAsyncShouldProduceTheExpectedResult()
361402
Success<string> success = Assert.IsType<Success<string>>(result);
362403
Assert.Equal(expected, success.Value);
363404
}
405+
406+
[Fact(DisplayName = "TryGetNonNull should produce the expected result (true)")]
407+
public void TryGetNotNullShouldProduceExpectedResultTrue()
408+
{
409+
// Given
410+
const string? value = "Hello, World!";
411+
412+
// When
413+
bool result = value.TryGetNonNull(out string output);
414+
415+
// Then
416+
Assert.True(result);
417+
Assert.NotNull(output);
418+
}
419+
420+
[Fact(DisplayName = "TryGetNonNull should produce the expected result (false)")]
421+
public void TryGetNotNullShouldProduceExpectedResultFalse()
422+
{
423+
// Given
424+
const string? value = null;
425+
426+
// When
427+
bool result = value.TryGetNonNull(out string? output);
428+
429+
// Then
430+
Assert.False(result);
431+
Assert.Null(output);
432+
}
364433
}
Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
<PropertyGroup>
3-
<IsPackable>false</IsPackable>
4-
<IsTestProject>true</IsTestProject>
5-
</PropertyGroup>
62
<ItemGroup>
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">
10-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
11-
<PrivateAssets>all</PrivateAssets>
12-
</PackageReference>
13-
<PackageReference Include="coverlet.collector" Version="6.0.2">
14-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
15-
<PrivateAssets>all</PrivateAssets>
16-
</PackageReference>
17-
</ItemGroup>
18-
<ItemGroup>
19-
<ProjectReference Include="..\OnixLabs.Core.UnitTests.Data\OnixLabs.Core.UnitTests.Data.csproj" />
20-
<ProjectReference Include="..\OnixLabs.Core\OnixLabs.Core.csproj" />
21-
</ItemGroup>
22-
<ItemGroup>
23-
<Using Include="OnixLabs.Core.Preconditions" Static="True" />
3+
<ProjectReference Include="..\OnixLabs.Core\OnixLabs.Core.csproj"/>
4+
<ProjectReference Include="..\OnixLabs.Core.UnitTests.Data\OnixLabs.Core.UnitTests.Data.csproj"/>
5+
<Using Include="OnixLabs.Core.Preconditions" Static="True"/>
246
</ItemGroup>
257
</Project>

0 commit comments

Comments
 (0)