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
- Call RecordTypeIgnoreBase<A>.Equality(objA, objB) instead.
- Use RecordTypeIgnoreBase<A>.EqualityTyped for strongly-typed A operands.
- 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
- Enable warn-as-error for Obsolete to catch this at compile time.
- Pick one record equality entry point per codebase and lint for the other.
- Document that Equals overloads on RecordType* are intentionally broken.
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
- Don't use Equals - use either RecordType
- Eq attribute should have a struct type that derives from…
- Ord attribute should have a struct type that derives from…
- Hashable attribute should have a struct type that derives…
- s
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)