louthy/language-ext · error · InvalidOperationException

Don't use Equals - use either RecordType

Error message

Don't use Equals - use either RecordType<A>.Equality or RecordType<A>.EqualityTyped

What it means

RecordTypeIgnoreBase<A>.Equals(object, object) is the same deliberate trap as in RecordType: it is marked [Obsolete] and always throws InvalidOperationException. Use the Equality or EqualityTyped delegates on RecordTypeIgnoreBase<A> instead.

Solutions

  1. Call RecordTypeIgnoreBase<A>.Equality(objA, objB) instead.
  2. Use RecordTypeIgnoreBase<A>.EqualityTyped for strongly-typed A operands.
  3. If base fields should participate, use RecordType<A> instead of the IgnoreBase variant.

Example fix

// before
bool same = RecordTypeIgnoreBase<MyRecord>.Equals(a, b); // throws

// after
bool same = RecordTypeIgnoreBase<MyRecord>.Equality(a, b);
Defensive patterns

Strategy: type-guard

Type guard

static bool RecordsEqual<A>(A a, A b) where A : RecordIgnoreBase<A> => RecordTypeIgnoreBase<A>.EqualityTyped(a, b);

Prevention

When it happens

Trigger: Calling RecordTypeIgnoreBase<A>.Equals(objA, objB) in code that compares records whose base-class fields are ignored for equality.

Common situations: Mechanical refactor of System.Object.Equals calls; shared generic helper that invokes static Equals on any RecordType variant.

Understand the failure class

Background: "is deprecated and will be removed" — deprecation warnings for old API names, keywords, and options, and how to migrate before the removal release — this error's family across 29 libraries.

Related errors


AI-assisted analysis of louthy/language-ext@2f0e362824 (2026-09-15). Data as JSON: /api/errors/995bb83d199d2538. Report an issue: GitHub.

Appendix: source

Thrown at LanguageExt.Core/DataTypes/Record/RecordTypeIgnoreBase.cs:61

    /// <summary>
    /// General ToString function
    /// </summary>
    public new static readonly Func<A, string> ToString;

    /// <summary>
    /// De-serialise an A
    /// </summary>
    public static readonly Action<A, SerializationInfo> SetObjectData;

    /// <summary>
    /// Serialise an A
    /// </summary>
    public static readonly Action<A, SerializationInfo> GetObjectData;

    [Obsolete("Don't use Equals - use either RecordType<A>.Equality or RecordType<A>.EqualityTyped")]
    public new static bool Equals(object objA, object objB) => 
        throw new InvalidOperationException("Don't use Equals - use either RecordType<A>.Equality or RecordType<A>.EqualityTyped");
}

View on GitHub (pinned to 2f0e362824)