Skip to content

Commit

Permalink
Merge pull request #2 from pfpack/release/early_v0.99.0
Browse files Browse the repository at this point in the history
release/early_v0.99.0
  • Loading branch information
andreise authored Feb 5, 2023
2 parents 8fe896a + 790d83f commit 47f2fee
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 98 deletions.
34 changes: 18 additions & 16 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: .NET

on:
push:
branches: [ main, dev, dev/*, feature/*, fix/*, release/* ]
branches: [ main, dev, feature/*, fix/*, release/* ]

pull_request:
branches: [ main ]
Expand All @@ -21,7 +21,9 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'
dotnet-version: |
6.0.x
7.0.x
# Create Local NuGet Source

Expand All @@ -31,33 +33,33 @@ jobs:
- name: Add Local Nuget Source
run: dotnet nuget add source ~/nuget

# Collections.EqualityComparers
# EqualityComparers

- name: Restore Collections.EqualityComparers
run: dotnet restore ./src/*/*/Collections.EqualityComparers.csproj
- name: Restore EqualityComparers
run: dotnet restore ./src/*/*/Collections.Generic.EqualityComparers.csproj

- name: Build Collections.EqualityComparers
run: dotnet build ./src/*/*/Collections.EqualityComparers.csproj --no-restore -c Release
- name: Build EqualityComparers
run: dotnet build ./src/*/*/Collections.Generic.EqualityComparers.csproj --no-restore -c Release

- name: Pack Collections.EqualityComparers
run: dotnet pack ./src/*/*/Collections.EqualityComparers.csproj --no-restore -o ~/nuget -c Release
- name: Pack EqualityComparers
run: dotnet pack ./src/*/*/Collections.Generic.EqualityComparers.csproj --no-restore -o ~/nuget -c Release

- name: Restore Collections.EqualityComparers.Tests
run: dotnet restore ./src/*/*/Collections.EqualityComparers.Tests.csproj
- name: Restore EqualityComparers.Tests
run: dotnet restore ./src/*/*/Collections.Generic.EqualityComparers.Tests.csproj

- name: Test Collections.EqualityComparers.Tests
run: dotnet test ./src/*/*/Collections.EqualityComparers.Tests.csproj --no-restore -c Release
- name: Test EqualityComparers.Tests
run: dotnet test ./src/*/*/Collections.Generic.EqualityComparers.Tests.csproj --no-restore -c Release

# Collections

- name: Restore Collections
run: dotnet restore ./src/*/*/Collections.csproj
run: dotnet restore ./src/*/*/Collections.Generic.csproj

- name: Build Collections
run: dotnet build ./src/*/*/Collections.csproj --no-restore -c Release
run: dotnet build ./src/*/*/Collections.Generic.csproj --no-restore -c Release

- name: Pack Collections
run: dotnet pack ./src/*/*/Collections.csproj --no-restore -o ~/nuget -c Release
run: dotnet pack ./src/*/*/Collections.Generic.csproj --no-restore -o ~/nuget -c Release

# Push

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Andrei Sergeev, Pavel Moskovoy
Copyright (c) 2022-2023 Andrei Sergeev, Pavel Moskovoy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# PrimeFuncPack Collections
# PrimeFuncPack Generic Collections

PrimeFuncPack Collections is a core library pack for .NET consisting of useful collection extensions:
- Collection equality comparers (implementing value equality);
- Immutable FlatArray.
PrimeFuncPack Generic Collections is a core library pack for .NET consisting of collection extensions such as collection value equality comparers.
6 changes: 3 additions & 3 deletions docs/collections-equality-comparers/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# PrimeFuncPack Collections.EqualityComparers
# PrimeFuncPack Generic Collections.EqualityComparers

PrimeFuncPack Collections.EqualityComparers is a core library for .NET consisting of collection equality comparers (implementing value equality).
The Collections.EqualityComparers is shipped as a part of PrimeFuncPack Collections pack.
PrimeFuncPack Generic Collections.EqualityComparers is a core library for .NET consisting of collection value equality comparers.
The Generic Collections.EqualityComparers is shipped as a part of PrimeFuncPack Generic Collections pack.
4 changes: 0 additions & 4 deletions docs/collections-flat-array/README.md

This file was deleted.

6 changes: 2 additions & 4 deletions docs/collections/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# PrimeFuncPack Collections
# PrimeFuncPack Generic Collections

PrimeFuncPack Collections is a core library pack for .NET consisting of useful collection extensions:
- Collection equality comparers (implementing value equality);
- Immutable FlatArray.
PrimeFuncPack Generic Collections is a core library pack for .NET consisting of collection extensions such as collection value equality comparers.
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<InvariantGlobalization>true</InvariantGlobalization>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<IsPackable>false</IsPackable>
<Authors>Andrei Sergeev, Pavel Moskovoy</Authors>
<Copyright>Copyright © 2022 Andrei Sergeev, Pavel Moskovoy</Copyright>
<RootNamespace>PrimeFuncPack.Collections.EqualityComparers.Tests</RootNamespace>
<AssemblyName>PrimeFuncPack.Collections.EqualityComparers.Tests</AssemblyName>
<Copyright>Copyright © 2022-2023 Andrei Sergeev, Pavel Moskovoy</Copyright>
<RootNamespace>PrimeFuncPack.Collections.Generic.EqualityComparers.Tests</RootNamespace>
<AssemblyName>PrimeFuncPack.Collections.Generic.EqualityComparers.Tests</AssemblyName>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand All @@ -27,7 +27,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Collections.EqualityComparers\Collections.EqualityComparers.csproj" />
<ProjectReference Include="..\Collections.Generic.EqualityComparers\Collections.Generic.EqualityComparers.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<InvariantGlobalization>true</InvariantGlobalization>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageProjectUrl>https://github.com/pfpack/pfpack-collections</PackageProjectUrl>
<RepositoryUrl>https://github.com/pfpack/pfpack-collections</RepositoryUrl>
<PackageProjectUrl>https://github.com/pfpack/pfpack-collections-generic</PackageProjectUrl>
<RepositoryUrl>https://github.com/pfpack/pfpack-collections-generic</RepositoryUrl>
<Company>pfpack</Company>
<Authors>Andrei Sergeev, Pavel Moskovoy</Authors>
<Copyright>Copyright © 2022 Andrei Sergeev, Pavel Moskovoy</Copyright>
<Description>PrimeFuncPack Collections.EqualityComparers is a core library for .NET consisting of collection equality comparers (implementing value equality).</Description>
<Copyright>Copyright © 2022-2023 Andrei Sergeev, Pavel Moskovoy</Copyright>
<Description>PrimeFuncPack Generic Collections.EqualityComparers is a core library for .NET consisting of collection value equality comparers.</Description>
<RootNamespace>System.Collections.Generic</RootNamespace>
<AssemblyName>EarlyFuncPack.Collections.EqualityComparers</AssemblyName>
<Version>0.4.1</Version>
<AssemblyName>EarlyFuncPack.Collections.Generic.EqualityComparers</AssemblyName>
<Version>0.99.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ public bool Equals(T[]? x, T[]? y)
return true;
}

public int GetHashCode(T[] obj)
public int GetHashCode(T[]? obj)
{
// Return zero instead of throwing ArgumentNullException
if (obj is null)
if (obj is null) // Return zero instead of throwing ArgumentNullException
{
return default;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Collections.Generic;
using System.Collections.Immutable;

namespace System.Collections.Immutable;
namespace System.Collections.Generic;

public sealed class ImmutableArrayEqualityComparer<T> : IEqualityComparer<ImmutableArray<T>>
public sealed class ImmutableArrayEqualityComparer<T> : IEqualityComparer<ImmutableArray<T>>, IEqualityComparer<ImmutableArray<T>?>
{
private readonly IEqualityComparer<T> comparer;

Expand All @@ -24,20 +24,12 @@ public static ImmutableArrayEqualityComparer<T> Default

public bool Equals(ImmutableArray<T> x, ImmutableArray<T> y)
{
// ImmutableArray 'reference' equality
if (x.Equals(y))
if (x.Equals(y)) // Check if the values' underlying arrays are reference equal (incl. the null case)
{
return true;
}

// Redundant since the 'reference' equality check is already done
// Keep for safety purposes to avoid possible NullReferenceException
if (x.IsDefault && y.IsDefault)
{
return true;
}

if (x.IsDefault || y.IsDefault)
if (x.IsDefault || y.IsDefault) // The default means null
{
return false;
}
Expand All @@ -61,8 +53,7 @@ public bool Equals(ImmutableArray<T> x, ImmutableArray<T> y)

public int GetHashCode(ImmutableArray<T> obj)
{
// Return zero instead of throwing ArgumentNullException
if (obj.IsDefault)
if (obj.IsDefault) // Return zero instead of throwing ArgumentNullException
{
return default;
}
Expand All @@ -78,6 +69,14 @@ public int GetHashCode(ImmutableArray<T> obj)
return builder.ToHashCode();
}

public bool Equals(ImmutableArray<T>? x, ImmutableArray<T>? y)
=>
Equals(x ?? default, y ?? default); // The default means null

public int GetHashCode(ImmutableArray<T>? obj)
=>
GetHashCode(obj ?? default); // The default means null

private static class InnerDefault
{
internal static readonly ImmutableArrayEqualityComparer<T> Value = Create();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Runtime.CompilerServices;

namespace System.Collections.Generic;
namespace System.Collections.Generic;

public sealed class ListEqualityComparer<T> : IEqualityComparer<IList<T>>, IEqualityComparer<List<T>>
{
Expand All @@ -23,23 +21,6 @@ public static ListEqualityComparer<T> Default
InnerDefault.Value;

public bool Equals(IList<T>? x, IList<T>? y)
=>
InnerEquals(x, y);

public bool Equals(List<T>? x, List<T>? y)
=>
InnerEquals(x, y);

public int GetHashCode(IList<T> obj)
=>
InnerGetHashCode(obj);

public int GetHashCode(List<T> obj)
=>
InnerGetHashCode(obj);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private bool InnerEquals(IList<T>? x, IList<T>? y)
{
if (ReferenceEquals(x, y))
{
Expand Down Expand Up @@ -68,11 +49,9 @@ private bool InnerEquals(IList<T>? x, IList<T>? y)
return true;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private int InnerGetHashCode(IList<T> obj)
public int GetHashCode(IList<T>? obj)
{
// Return zero instead of throwing ArgumentNullException
if (obj is null)
if (obj is null) // Return zero instead of throwing ArgumentNullException
{
return default;
}
Expand All @@ -88,6 +67,14 @@ private int InnerGetHashCode(IList<T> obj)
return builder.ToHashCode();
}

public bool Equals(List<T>? x, List<T>? y)
=>
Equals((IList<T>?)x, y);

public int GetHashCode(List<T>? obj)
=>
GetHashCode((IList<T>?)obj);

private static class InnerDefault
{
internal static readonly ListEqualityComparer<T> Value = Create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ public bool Equals(IReadOnlyList<T>? x, IReadOnlyList<T>? y)
return true;
}

public int GetHashCode(IReadOnlyList<T> obj)
public int GetHashCode(IReadOnlyList<T>? obj)
{
// Return zero instead of throwing ArgumentNullException
if (obj is null)
if (obj is null) // Return zero instead of throwing ArgumentNullException
{
return default;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<InvariantGlobalization>true</InvariantGlobalization>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageProjectUrl>https://github.com/pfpack/pfpack-collections</PackageProjectUrl>
<RepositoryUrl>https://github.com/pfpack/pfpack-collections</RepositoryUrl>
<PackageProjectUrl>https://github.com/pfpack/pfpack-collections-generic</PackageProjectUrl>
<RepositoryUrl>https://github.com/pfpack/pfpack-collections-generic</RepositoryUrl>
<Company>pfpack</Company>
<Authors>Andrei Sergeev, Pavel Moskovoy</Authors>
<Copyright>Copyright © 2022 Andrei Sergeev, Pavel Moskovoy</Copyright>
<Description>PrimeFuncPack Collections is a core library pack for .NET consisting of useful collection extensions such as collection equality comparers and immutable FlatArray.</Description>
<Copyright>Copyright © 2022-2023 Andrei Sergeev, Pavel Moskovoy</Copyright>
<Description>PrimeFuncPack Generic Collections is a core library pack for .NET consisting of collection extensions such as collection value equality comparers.</Description>
<RootNamespace>System.Collections.Generic</RootNamespace>
<AssemblyName>EarlyFuncPack.Collections</AssemblyName>
<Version>0.11.0</Version>
<AssemblyName>EarlyFuncPack.Collections.Generic</AssemblyName>
<Version>0.99.0</Version>
</PropertyGroup>

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

<ItemGroup>
<PackageReference Include="EarlyFuncPack.Collections.EqualityComparers" Version="0.4.1" />
<PackageReference Include="EarlyFuncPack.Collections.Generic.EqualityComparers" Version="0.99.0" />
</ItemGroup>

</Project>

0 comments on commit 47f2fee

Please sign in to comment.