{"record":{"id":"995bb83d199d2538","repo":"louthy/language-ext","slug":"don-t-use-equals-use-either-recordtype-a-equality-or-995bb8","errorCode":null,"errorMessage":"Don't use Equals - use either RecordType<A>.Equality or RecordType<A>.EqualityTyped","messagePattern":"Don't use Equals - use either RecordType<A>\\.Equality or RecordType<A>\\.EqualityTyped","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"LanguageExt.Core/DataTypes/Record/RecordTypeIgnoreBase.cs","lineNumber":61,"sourceCode":"\n    /// <summary>\n    /// General ToString function\n    /// </summary>\n    public new static readonly Func<A, string> ToString;\n\n    /// <summary>\n    /// De-serialise an A\n    /// </summary>\n    public static readonly Action<A, SerializationInfo> SetObjectData;\n\n    /// <summary>\n    /// Serialise an A\n    /// </summary>\n    public static readonly Action<A, SerializationInfo> GetObjectData;\n\n    [Obsolete(\"Don't use Equals - use either RecordType<A>.Equality or RecordType<A>.EqualityTyped\")]\n    public new static bool Equals(object objA, object objB) => \n        throw new InvalidOperationException(\"Don't use Equals - use either RecordType<A>.Equality or RecordType<A>.EqualityTyped\");\n}\n","sourceCodeStart":43,"sourceCodeEnd":63,"githubUrl":"https://github.com/louthy/language-ext/blob/2f0e3628242889774d4141960a35671a0280051f/LanguageExt.Core/DataTypes/Record/RecordTypeIgnoreBase.cs#L43-L63","documentation":"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.","triggerScenarios":"Calling RecordTypeIgnoreBase<A>.Equals(objA, objB) in code that compares records whose base-class fields are ignored for equality.","commonSituations":"Mechanical refactor of System.Object.Equals calls; shared generic helper that invokes static Equals on any RecordType variant.","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."],"exampleFix":"// before\nbool same = RecordTypeIgnoreBase<MyRecord>.Equals(a, b); // throws\n\n// after\nbool same = RecordTypeIgnoreBase<MyRecord>.Equality(a, b);","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static bool RecordsEqual<A>(A a, A b) where A : RecordIgnoreBase<A> => RecordTypeIgnoreBase<A>.EqualityTyped(a, b);","tryCatchPattern":null,"preventionTips":["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."],"tags":["csharp","languageext","records","equality","deprecated"],"backgroundTag":"deprecated-api-usage","analyzedSha":"2f0e3628242889774d4141960a35671a0280051f","analyzedAt":"2026-09-15T03:31:55.716Z","contentChangedAt":"2026-09-15T03:31:55.716Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}