ComparableLibrary 2.0.1

dotnet add package ComparableLibrary --version 2.0.1
                    
NuGet\Install-Package ComparableLibrary -Version 2.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ComparableLibrary" Version="2.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ComparableLibrary" Version="2.0.1" />
                    
Directory.Packages.props
<PackageReference Include="ComparableLibrary" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ComparableLibrary --version 2.0.1
                    
#r "nuget: ComparableLibrary, 2.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ComparableLibrary@2.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ComparableLibrary&version=2.0.1
                    
Install as a Cake Addin
#tool nuget:?package=ComparableLibrary&version=2.0.1
                    
Install as a Cake Tool

ComparableLibrary

ComparableLibrary is a .NET library for comparing objects by selected property values. Classes implement the IGeneralComparable interface and mark significant properties with ComparablePropertyAttribute. The library generates a hash from these properties, allowing objects to be compared efficiently.

The library is implemented in C# and uses XxHash128 from the System.IO.Hashing NuGet package.

Installation

dotnet add package ComparableLibrary --version 2.0.1

Features

The IGeneralComparable interface allows objects to be compared using hashes generated from their significant properties.

To include a property in the comparison, mark it with ComparablePropertyAttribute.

ComparablePropertyAttribute supports the following properties:

  • Name — specifies the logical property name. Use the same name to compare corresponding properties from different object types. By default, the original property name is used.
  • Order — defines the order in which properties are processed. Corresponding properties in different object types should use the same order.
  • Type — defines how collections are processed:
    • Ordered — the order of collection items affects the hash.
    • Unordered — the order of collection items does not affect the hash.

Properties without ComparablePropertyAttribute are not included in the hash.

The optional GeneralComparable base class implements IGeneralComparable and provides the cached HashSum property.

You can also implement IGeneralComparable directly and generate the hash using the GetHashSum() extension method.

Important

XxHash128 is a fast, non-cryptographic hashing algorithm. It is suitable for object comparison and change detection, but it should not be used for passwords, digital signatures, or security checks.

Earlier versions of ComparableLibrary used MurmurHash3. Hashes generated with XxHash128 are different and are not compatible with hashes from previous versions. Regenerate any hashes stored in a database, cache, or file after upgrading.

See more in the ComparableLibrary GitHub repository.

License

ComparableLibrary is available under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.1 65 8/24/2026
2.0.0 68 8/24/2026
1.1.1 192 10/8/2025
1.1.0 182 10/8/2025
1.0.0 197 7/7/2025