Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release/2.2.0-preview.9_development #136

Merged
merged 17 commits into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ jobs:
- name: Pack Taggeds
run: dotnet pack ./src/*/*/Taggeds.csproj --no-restore -o ~/nuget -c Release

- name: Restore Taggeds.Tests.Old
run: dotnet restore ./src/*/*/Taggeds.Tests.Old.csproj

- name: Test Taggeds.Tests.Old
run: dotnet test ./src/*/*/Taggeds.Tests.Old.csproj --no-restore -c Release

- name: Restore Taggeds.Tests
run: dotnet restore ./src/*/*/Taggeds.Tests.csproj

Expand Down
12 changes: 7 additions & 5 deletions src/core-taggeds-failure/Failure.Tests/Failure.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<InvariantGlobalization>true</InvariantGlobalization>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<Authors>Andrei Sergeev, Pavel Moskovoy</Authors>
<Copyright>Copyright © 2020-2023 Andrei Sergeev, Pavel Moskovoy</Copyright>
<Copyright>Copyright © 2020-2024 Andrei Sergeev, Pavel Moskovoy</Copyright>
<RootNamespace>PrimeFuncPack.Core.Tests</RootNamespace>
<AssemblyName>PrimeFuncPack.Core.Failure.Tests</AssemblyName>
</PropertyGroup>
Expand All @@ -18,11 +20,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="DeepEqual" Version="4.2.1" />
<PackageReference Include="DeepEqual" Version="5.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="PrimeFuncPack.UnitTest.Data" Version="3.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
4 changes: 2 additions & 2 deletions src/core-taggeds-failure/Failure/Failure.T/Failure.T.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ public string FailureMessage
=>
failureMessage ?? string.Empty;

public System.Exception? SourceException { get; init; } = null;
}
public System.Exception? SourceException { get; init; }
}
6 changes: 4 additions & 2 deletions src/core-taggeds-failure/Failure/Failure.T/T.Deconstruct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ namespace System;

partial struct Failure<TFailureCode>
{
public void Deconstruct(out TFailureCode failureCode, out string failureMessage)
public void Deconstruct(
out TFailureCode failureCode, out string failureMessage)
{
failureCode = FailureCode;
failureMessage = FailureMessage;
}

public void Deconstruct(out TFailureCode failureCode, out string failureMessage, out System.Exception? sourceException)
public void Deconstruct(
out TFailureCode failureCode, out string failureMessage, out System.Exception? sourceException)
{
failureCode = FailureCode;
failureMessage = FailureMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

partial struct Failure<TFailureCode>
{
public Failure<TFailureCode>.Exception ToException()
public Exception ToException()
=>
new(
failureCode: FailureCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ private Failure<TResultFailureCode> InnerMapFailureCode<TResultFailureCode>(
where TResultFailureCode : struct
=>
new(
mapFailureCode.Invoke(FailureCode),
failureMessage, // pass the inner state
failureCode: mapFailureCode.Invoke(FailureCode),
failureMessage: failureMessage,
default)
{
SourceException = SourceException
Expand Down
32 changes: 16 additions & 16 deletions src/core-taggeds-failure/Failure/Failure.T/T.ToString.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using System.Runtime.CompilerServices;
using static System.FormattableString;

namespace System;

partial struct Failure<TFailureCode>
{
public override string ToString()
=>
Invariant(
$"Failure<{typeof(TFailureCode).Name}>:{{ \"FailureCode\": {FailureCode}, \"FailureMessage\": \"{FailureMessage}\", \"SourceException\": {InnerSourceExceptionString()} }}");

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private string InnerSourceExceptionString()
=>
SourceException is null ? "null" : Invariant($"\"{SourceException}\"");
}
using static System.FormattableString;
namespace System;
partial struct Failure<TFailureCode>
{
public override string ToString()
=>
Invariant(
$"Failure<{typeof(TFailureCode).Name}>:{{ \"FailureCode\": {FailureCode}, \"FailureMessage\": \"{FailureMessage}\", \"SourceException\": {InnerSourceExceptionString()} }}");
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private string InnerSourceExceptionString()
=>
SourceException is null ? "null" : Invariant($"\"{SourceException}\"");
}
3 changes: 2 additions & 1 deletion src/core-taggeds-failure/Failure/Failure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<InvariantGlobalization>true</InvariantGlobalization>
Expand All @@ -13,7 +14,7 @@
<RepositoryUrl>https://github.com/pfpack/pfpack-core-taggeds</RepositoryUrl>
<Company>pfpack</Company>
<Authors>Andrei Sergeev, Pavel Moskovoy</Authors>
<Copyright>Copyright © 2020-2023 Andrei Sergeev, Pavel Moskovoy</Copyright>
<Copyright>Copyright © 2020-2024 Andrei Sergeev, Pavel Moskovoy</Copyright>
<Description>PrimeFuncPack Core.Failure is a core library for .NET consisting of Failure type targeted for use in functional programming.</Description>
<RootNamespace>System</RootNamespace>
<AssemblyName>PrimeFuncPack.Core.Failure</AssemblyName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<InvariantGlobalization>true</InvariantGlobalization>
Expand Down
1 change: 1 addition & 0 deletions src/core-taggeds-result/Result.Tests/Result.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<InvariantGlobalization>true</InvariantGlobalization>
Expand Down
1 change: 1 addition & 0 deletions src/core-taggeds-result/Result/Result.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<InvariantGlobalization>true</InvariantGlobalization>
Expand Down
1 change: 1 addition & 0 deletions src/core-taggeds/Taggeds.Tests.Old/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global using NUnit.Framework;
34 changes: 34 additions & 0 deletions src/core-taggeds/Taggeds.Tests.Old/Taggeds.Tests.Old.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<InvariantGlobalization>true</InvariantGlobalization>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<Authors>Andrei Sergeev, Pavel Moskovoy</Authors>
<Copyright>Copyright © 2020-2024 Andrei Sergeev, Pavel Moskovoy</Copyright>
<RootNamespace>PrimeFuncPack.Core.Tests</RootNamespace>
<AssemblyName>PrimeFuncPack.Core.Taggeds.Tests.Old</AssemblyName>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="NUnit" Version="4.0.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="PrimeFuncPack.UnitTest.Data" Version="3.1.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Taggeds\Taggeds.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using NUnit.Framework;
using System;
using static PrimeFuncPack.UnitTest.TestData;

Expand All @@ -20,7 +19,7 @@ public void Optional_ToResult_SourceOptionalIsPresent_ExpectSuccessResultOfSourc
var actual = sourceOptional.ToResult();
var expected = Result<string?, Unit>.Success(sourceValue);

Assert.AreEqual(expected, actual);
Assert.That(actual, Is.EqualTo(expected));
}

[Test]
Expand All @@ -31,6 +30,6 @@ public void Optional_ToResult_SourceOptionalIsAbsent_ExpectFailureResultOfUnit()
var actual = sourceOptional.ToResult();
var expected = Result<SomeRecord, Unit>.Failure(Unit.Value);

Assert.AreEqual(expected, actual);
Assert.That(actual, Is.EqualTo(expected));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using NUnit.Framework;
using PrimeFuncPack.UnitTest;
using PrimeFuncPack.UnitTest;
using System;

namespace PrimeFuncPack.Core.Tests;
Expand All @@ -15,7 +14,7 @@ public void Optional_ToTaggedUnion_OptionalIsPresent_ExpectActualIsFirst(
var actual = optional.ToTaggedUnion();

var expected = TaggedUnion<object?, Unit>.First(sourceValue);
Assert.AreEqual(expected, actual);
Assert.That(actual, Is.EqualTo(expected));
}

[Test]
Expand All @@ -25,6 +24,6 @@ public void Optional_ToTaggedUnion_OptionalIsAbsent_ExpectActualIsSecond()
var actual = optional.ToTaggedUnion();

var expected = TaggedUnion<RefType, Unit>.Second(Unit.Value);
Assert.AreEqual(expected, actual);
Assert.That(actual, Is.EqualTo(expected));
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using NUnit.Framework;
using PrimeFuncPack.UnitTest;
using System;
using static PrimeFuncPack.UnitTest.TestData;
Expand All @@ -15,7 +14,7 @@ public void Result_ToOptional_SourceResultIsDefault_ExpectAbsent()
var actual = sourceResult.ToOptional();
var expected = Optional<SomeRecord?>.Absent;

Assert.AreEqual(expected, actual);
Assert.That(actual, Is.EqualTo(expected));
}

[Test]
Expand All @@ -26,7 +25,7 @@ public void Result_ToOptional_SourceResultIsFailure_ExpectUnionSecondOfSourceFai
var actual = sourceResult.ToOptional();
var expected = Optional<RefType>.Absent;

Assert.AreEqual(expected, actual);
Assert.That(actual, Is.EqualTo(expected));
}

[Test]
Expand All @@ -37,7 +36,7 @@ public void Result_ToOptional_SourceResultIsSuccessAndSourceValueIsNull_ExpectPr
var actual = sourceResult.ToOptional();
var expected = Optional<object?>.Present(null);

Assert.AreEqual(expected, actual);
Assert.That(actual, Is.EqualTo(expected));
}

[Test]
Expand All @@ -49,6 +48,6 @@ public void Result_ToOptional_SourceResultIsSuccessAndSourceValueIsNotNull_Expec
var actual = sourceResult.ToOptional();
var expected = Optional<RefType>.Present(sourceValue);

Assert.AreEqual(expected, actual);
Assert.That(actual, Is.EqualTo(expected));
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using NUnit.Framework;
using PrimeFuncPack.UnitTest;
using System;
using static PrimeFuncPack.UnitTest.TestData;
Expand All @@ -13,9 +12,9 @@ public void Result_ToTaggedUnion_SourceResultIsDefault_ExpectUnionSecondOfDefaul
Result<RefType?, StructType> sourceResult)
{
var actual = sourceResult.ToTaggedUnion();
var expected = TaggedUnion<RefType?, StructType>.Second(default(StructType));
var expected = TaggedUnion<RefType?, StructType>.Second(default);

Assert.AreEqual(expected, actual);
Assert.That(actual, Is.EqualTo(expected));
}

[Test]
Expand All @@ -26,7 +25,7 @@ public void Result_ToTaggedUnion_SourceResultIsFailure_ExpectUnionSecondOfSource
var actual = sourceResult.ToTaggedUnion();
var expected = TaggedUnion<RefType, StructType>.Second(SomeTextStructType);

Assert.AreEqual(expected, actual);
Assert.That(actual, Is.EqualTo(expected));
}

[Test]
Expand All @@ -37,7 +36,7 @@ public void Result_ToTaggedUnion_SourceResultIsSuccessAndSourceValueIsNull_Expec
var actual = sourceResult.ToTaggedUnion();
var expected = TaggedUnion<RefType?, StructType>.First(null);

Assert.AreEqual(expected, actual);
Assert.That(actual, Is.EqualTo(expected));
}

[Test]
Expand All @@ -48,6 +47,6 @@ public void Result_ToTaggedUnion_SourceResultIsSuccessAndSourceValueIsNotNull_Ex
var actual = sourceResult.ToTaggedUnion();
var expected = TaggedUnion<RefType, StructType>.First(PlusFifteenIdRefType);

Assert.AreEqual(expected, actual);
Assert.That(actual, Is.EqualTo(expected));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using NUnit.Framework;
using PrimeFuncPack.UnitTest;
using PrimeFuncPack.UnitTest;
using System;

namespace PrimeFuncPack.Core.Tests;
Expand All @@ -15,7 +14,7 @@ public void TaggedUnion_ToOptional_UnionIsFirst_ExpectPresent(
var actual = union.ToOptional();

var expected = Optional.Present(sourceValue);
Assert.AreEqual(expected, actual);
Assert.That(actual, Is.EqualTo(expected));
}

[Test]
Expand All @@ -25,7 +24,7 @@ public void TaggedUnion_ToOptional_UnionIsDefault_ExpectAbsent()
var actual = union.ToOptional();

var expected = Optional.Absent<StructType>();
Assert.AreEqual(expected, actual);
Assert.That(actual, Is.EqualTo(expected));
}

[Test]
Expand All @@ -35,6 +34,6 @@ public void TaggedUnion_ToOptional_UnionIsSecond_ExpectAbsent()
var actual = union.ToOptional();

var expected = Optional.Absent<RefType>();
Assert.AreEqual(expected, actual);
Assert.That(actual, Is.EqualTo(expected));
}
}
Loading