Skip to content

MercuryNuGet/SuperTuples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Super Tuples

NuGet Build Status

An abstract replacement for .net Tuples.

Key Features

  1. abstract, built for descending from with:
  2. No public members
  3. Simple and correct Equals and GetHashCode implementation
  4. Optional cached hash
  5. Verifiably Immutable

Example

public class Person : Suple<string, string>
{
    public Person(string firstName, string lastName) : base(firstName, lastName, SupleHash.Cached)
    {
    }
    
    public string FirstName => Item1;
    public string LastName => Item2;
}

Person fully supports a correct equality contract, much like inheriting from Tuple<string, string>, but unlike inheriting from Tuple<string, string>:

  1. Item1 and Item2 are protected, keeping intellisense clean and they shouldn't appear with most serializers.
  2. Equals and/or GetHashCode could be overridden if required without breaking contract.
  3. The hash is cached for performance

Packages

No packages published

Languages