Show / Hide Table of Contents

Struct EqualityComparerBuilder<T>

Generates hash code and equality check functions for the particular type.

Inherited Members
ValueType.Equals(object)
ValueType.GetHashCode()
ValueType.ToString()
object.GetType()
object.Equals(object, object)
object.ReferenceEquals(object, object)
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public readonly struct EqualityComparerBuilder<T>
Type Parameters
Name Description
T

The type for which equality check and hash code functions should be generated.

Remarks

Automatically generated hash code and equality check functions can be used instead of manually written implementation of overridden GetHashCode() and Equals(object) methods.

Properties

View Source

ExcludedFields

Sets an array of excluded field names.

Declaration
public string[] ExcludedFields { init; }
Property Value
Type Description
string[]

An array of excluded fields.

View Source

SaltedHashCode

Set a value indicating that hash code must be unique for each application instance.

Declaration
public bool SaltedHashCode { init; }
Property Value
Type Description
bool

true to include randomized salt data into hashing; false to use data from memory only.

Methods

View Source

Build()

Generates implementation of equality comparer.

Declaration
[RequiresDynamicCode("Runtime binding requires dynamic code compilation")]
[RequiresUnreferencedCode("Dynamic code generation may be incompatible with IL trimming")]
public IEqualityComparer<T> Build()
Returns
Type Description
IEqualityComparer<T>

The generated equality comparer.

Exceptions
Type Condition
PlatformNotSupportedException

Dynamic code generation is not supported by underlying CLR implementation.

View Source

Build(out Func<T?, T?, bool>, out Func<T, int>)

Generates implementation of GetHashCode() and Equals(object) methods for particular type T.

Declaration
[RequiresDynamicCode("Runtime binding requires dynamic code compilation")]
[RequiresUnreferencedCode("Dynamic code generation may be incompatible with IL trimming")]
public void Build(out Func<T?, T?, bool> equals, out Func<T, int> hashCode)
Parameters
Type Name Description
Func<T, T, bool> equals

The implementation of equality check.

Func<T, int> hashCode

The implementation of hash code.

Exceptions
Type Condition
PlatformNotSupportedException

Dynamic code generation is not supported by underlying CLR implementation.

Extension Methods

BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, params ReadOnlySpan<T>)
Enumerator.Skip<TEnumerator, T>(ref TEnumerator, int)
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾