Skip to content

Commit

Permalink
Merge pull request #111 from pfpack/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
andreise authored May 18, 2022
2 parents 313129c + 92b8151 commit c398114
Show file tree
Hide file tree
Showing 25 changed files with 146 additions and 58 deletions.
6 changes: 3 additions & 3 deletions src/core-taggeds-failure/Failure.Tests/Failure.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@

<ItemGroup>
<PackageReference Include="PrimeFuncPack.UnitTest.Data" Version="3.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ private static Type EqualityContract
=>
typeof(Failure<TFailureCode>);

private static EqualityComparer<Type> EqualityContractComparer
=>
EqualityComparer<Type>.Default;

private static EqualityComparer<TFailureCode> FailureCodeComparer
=>
EqualityComparer<TFailureCode>.Default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ partial struct Failure<TFailureCode>
public override int GetHashCode()
=>
HashCode.Combine(
EqualityContract,
EqualityContractComparer.GetHashCode(EqualityContract),
FailureCodeComparer.GetHashCode(FailureCode),
FailureMessageComparer.GetHashCode(FailureMessage));
}
4 changes: 2 additions & 2 deletions src/core-taggeds-failure/Failure/Failure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<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>
<Version>2.0.0</Version>
<Version>2.0.1-preview.1.0.0</Version>
</PropertyGroup>

<ItemGroup>
Expand All @@ -32,7 +32,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="PrimeFuncPack.Core.Unit" Version="2.1.1" />
<PackageReference Include="PrimeFuncPack.Core.Unit" Version="2.1.2" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="PrimeFuncPack.UnitTest.Data" Version="3.0.0" />
<PackageReference Include="PrimeFuncPack.UnitTest.Moq" Version="1.0.3" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

namespace System;

Expand All @@ -14,5 +15,6 @@ public override bool Equals([NotNullWhen(true)] object? obj)

public override int GetHashCode()
=>
HashCode.Combine(typeof(Absent<T>));
HashCode.Combine(
EqualityComparer<Type>.Default.GetHashCode(typeof(Absent<T>)));
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ namespace System;

partial struct Optional<T>
{
private static Type EqualityContract => typeof(Optional<T>);
private static Type EqualityContract
=>
typeof(Optional<T>);

private static EqualityComparer<T> EqualityComparer => EqualityComparer<T>.Default;
private static EqualityComparer<Type> EqualityContractComparer
=>
EqualityComparer<Type>.Default;

private static EqualityComparer<T> EqualityComparer
=>
EqualityComparer<T>.Default;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@ public override int GetHashCode()
private int PresentHashCode()
=>
value is not null
? HashCode.Combine(EqualityContract, true, EqualityComparer.GetHashCode(value))
: HashCode.Combine(EqualityContract, true);
? HashCode.Combine(EqualityContractHashCode(), true, EqualityComparer.GetHashCode(value))
: HashCode.Combine(EqualityContractHashCode(), true);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static int AbsentHashCode()
=>
HashCode.Combine(EqualityContract);
HashCode.Combine(EqualityContractHashCode());

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static int EqualityContractHashCode()
=>
EqualityContractComparer.GetHashCode(EqualityContract);
}
4 changes: 2 additions & 2 deletions src/core-taggeds-optional/Optional/Optional.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<Description>PrimeFuncPack Core.Optional is a core library for .NET consisting of Optional monad targeted for use in functional programming.</Description>
<RootNamespace>System</RootNamespace>
<AssemblyName>PrimeFuncPack.Core.Optional</AssemblyName>
<Version>2.0.0</Version>
<Version>2.0.1-preview.1.0.0</Version>
</PropertyGroup>

<ItemGroup>
Expand All @@ -32,7 +32,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="PrimeFuncPack.Core.Unit" Version="2.1.1" />
<PackageReference Include="PrimeFuncPack.Core.Unit" Version="2.1.2" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ namespace System;

partial struct Present<T>
{
private static Type EqualityContract => typeof(Present<T>);
private static Type EqualityContract
=>
typeof(Present<T>);

private static EqualityComparer<T> EqualityComparer => EqualityComparer<T>.Default;
private static EqualityComparer<Type> EqualityContractComparer
=>
EqualityComparer<Type>.Default;

private static EqualityComparer<T> EqualityComparer
=>
EqualityComparer<T>.Default;
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
using System.Runtime.CompilerServices;

namespace System;

partial struct Present<T>
{
public override int GetHashCode()
=>
value is not null
? HashCode.Combine(EqualityContract, EqualityComparer.GetHashCode(value))
: HashCode.Combine(EqualityContract);
? HashCode.Combine(EqualityContractHashCode(), EqualityComparer.GetHashCode(value))
: HashCode.Combine(EqualityContractHashCode());

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static int EqualityContractHashCode()
=>
EqualityContractComparer.GetHashCode(EqualityContract);
}
4 changes: 2 additions & 2 deletions src/core-taggeds-result/Result.Tests/Result.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="PrimeFuncPack.UnitTest.Data" Version="3.0.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ namespace PrimeFuncPack.Core;

partial struct FailureBuilder<TFailure>
{
private static Type EqualityContract => typeof(FailureBuilder<TFailure>);
private static Type EqualityContract
=>
typeof(FailureBuilder<TFailure>);

private static EqualityComparer<TFailure> FailureComparer => EqualityComparer<TFailure>.Default;
private static EqualityComparer<Type> EqualityContractComparer
=>
EqualityComparer<Type>.Default;

private static EqualityComparer<TFailure> FailureComparer
=>
EqualityComparer<TFailure>.Default;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ partial struct FailureBuilder<TFailure>
{
public override int GetHashCode()
=>
HashCode.Combine(EqualityContract, FailureComparer.GetHashCode(failure));
HashCode.Combine(
EqualityContractComparer.GetHashCode(EqualityContract),
FailureComparer.GetHashCode(failure));
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ namespace PrimeFuncPack.Core;

partial struct SuccessBuilder<TSuccess>
{
private static Type EqualityContract => typeof(SuccessBuilder<TSuccess>);
private static Type EqualityContract
=>
typeof(SuccessBuilder<TSuccess>);

private static EqualityComparer<TSuccess> SuccessComparer => EqualityComparer<TSuccess>.Default;
private static EqualityComparer<Type> EqualityContractComparer
=>
EqualityComparer<Type>.Default;

private static EqualityComparer<TSuccess> SuccessComparer
=>
EqualityComparer<TSuccess>.Default;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Runtime.CompilerServices;

namespace PrimeFuncPack.Core;

Expand All @@ -7,6 +8,11 @@ partial struct SuccessBuilder<TSuccess>
public override int GetHashCode()
=>
success is not null
? HashCode.Combine(EqualityContract, SuccessComparer.GetHashCode(success))
: HashCode.Combine(EqualityContract);
? HashCode.Combine(EqualityContractHashCode(), SuccessComparer.GetHashCode(success))
: HashCode.Combine(EqualityContractHashCode());

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static int EqualityContractHashCode()
=>
EqualityContractComparer.GetHashCode(EqualityContract);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,19 @@ namespace System;

partial struct Result<TSuccess, TFailure>
{
private static Type EqualityContract => typeof(Result<TSuccess, TFailure>);
private static Type EqualityContract
=>
typeof(Result<TSuccess, TFailure>);

private static EqualityComparer<TSuccess> SuccessComparer => EqualityComparer<TSuccess>.Default;
private static EqualityComparer<Type> EqualityContractComparer
=>
EqualityComparer<Type>.Default;

private static EqualityComparer<TFailure> FailureComparer => EqualityComparer<TFailure>.Default;
private static EqualityComparer<TSuccess> SuccessComparer
=>
EqualityComparer<TSuccess>.Default;

private static EqualityComparer<TFailure> FailureComparer
=>
EqualityComparer<TFailure>.Default;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@ public override int GetHashCode()
private int SuccessHashCode()
=>
success is not null
? HashCode.Combine(EqualityContract, true, SuccessComparer.GetHashCode(success))
: HashCode.Combine(EqualityContract, true);
? HashCode.Combine(EqualityContractHashCode(), true, SuccessComparer.GetHashCode(success))
: HashCode.Combine(EqualityContractHashCode(), true);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private int FailureHashCode()
=>
HashCode.Combine(EqualityContract, false, FailureComparer.GetHashCode(failure));
HashCode.Combine(EqualityContractHashCode(), false, FailureComparer.GetHashCode(failure));

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static int EqualityContractHashCode()
=>
EqualityContractComparer.GetHashCode(EqualityContract);
}
4 changes: 2 additions & 2 deletions src/core-taggeds-result/Result/Result.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<Description>PrimeFuncPack Core.Result is a core library for .NET consisting of Result monad targeted for use in functional programming.</Description>
<RootNamespace>System</RootNamespace>
<AssemblyName>PrimeFuncPack.Core.Result</AssemblyName>
<Version>2.0.0</Version>
<Version>2.0.1-preview.1.0.0</Version>
</PropertyGroup>

<ItemGroup>
Expand All @@ -32,7 +32,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="PrimeFuncPack.Core.Unit" Version="2.1.1" />
<PackageReference Include="PrimeFuncPack.Core.Unit" Version="2.1.2" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="PrimeFuncPack.UnitTest.Data" Version="3.0.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,19 @@ namespace System;

partial struct TaggedUnion<TFirst, TSecond>
{
private static Type EqualityContract => typeof(TaggedUnion<TFirst, TSecond>);
private static Type EqualityContract
=>
typeof(TaggedUnion<TFirst, TSecond>);

private static EqualityComparer<TFirst> FirstComparer => EqualityComparer<TFirst>.Default;
private static EqualityComparer<Type> EqualityContractComparer
=>
EqualityComparer<Type>.Default;

private static EqualityComparer<TSecond> SecondComparer => EqualityComparer<TSecond>.Default;
private static EqualityComparer<TFirst> FirstComparer
=>
EqualityComparer<TFirst>.Default;

private static EqualityComparer<TSecond> SecondComparer
=>
EqualityComparer<TSecond>.Default;
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,23 @@ public override int GetHashCode()
private int FirstHashCode()
=>
first is not null
? HashCode.Combine(EqualityContract, InternalTag.First, FirstComparer.GetHashCode(first))
: HashCode.Combine(EqualityContract, InternalTag.First);
? HashCode.Combine(EqualityContractHashCode(), InternalTag.First, FirstComparer.GetHashCode(first))
: HashCode.Combine(EqualityContractHashCode(), InternalTag.First);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private int SecondHashCode()
=>
second is not null
? HashCode.Combine(EqualityContract, InternalTag.Second, SecondComparer.GetHashCode(second))
: HashCode.Combine(EqualityContract, InternalTag.Second);
? HashCode.Combine(EqualityContractHashCode(), InternalTag.Second, SecondComparer.GetHashCode(second))
: HashCode.Combine(EqualityContractHashCode(), InternalTag.Second);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static int NoneHashCode()
=>
HashCode.Combine(EqualityContract);
HashCode.Combine(EqualityContractHashCode());

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static int EqualityContractHashCode()
=>
EqualityContractComparer.GetHashCode(EqualityContract);
}
4 changes: 2 additions & 2 deletions src/core-taggeds-union/TaggedUnion/TaggedUnion.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<Description>PrimeFuncPack Core.TaggedUnion is a core library for .NET consisting of Tagged Union targeted for use in functional programming.</Description>
<RootNamespace>System</RootNamespace>
<AssemblyName>PrimeFuncPack.Core.TaggedUnion</AssemblyName>
<Version>2.0.0</Version>
<Version>2.0.1-preview.1.0.0</Version>
</PropertyGroup>

<ItemGroup>
Expand All @@ -32,7 +32,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="PrimeFuncPack.Core.Unit" Version="2.1.1" />
<PackageReference Include="PrimeFuncPack.Core.Unit" Version="2.1.2" />
</ItemGroup>

</Project>
Loading

0 comments on commit c398114

Please sign in to comment.