Repository navigation
fix: refuse a value object's Equals of a base record's type - #202
Merged
CaffeinatedCoder merged 3 commits intoOct 30, 2026
Merged
Conversation
A value object over a base record could declare an Equals of a deeper base's type, such as Equals(DeepBase?). It implemented IEquatable<DeepBase>, which the value object lists again through IReimplementedEquatable, so a HashSet<DeepBase> compared by it, while == compared the wrapped value: two holding "a" were equal, and the set held both. EqualityDeclaredByHand refused Equals(TSelf) alone, and IntroduceEquality skipped its own new Equals(TBase) because the value object declared one. EqualityDeclaredByHand now refuses an Equals of the value object's type or of any of its base records' types, nullability aside, with the existing CMTK1011 and its remedy (normalise in Create). One of the direct base's type is C#'s own CS0111, beside the override the record synthesizes (measured). Input class (GTS): the parameter type of a hand-written Equals. Catalogue: the value object's own on a record struct and on a record class (nullable parameter, already refused), a deeper base's (refused now), and the direct base's (C#'s CS0111). The record class case had no fixture; it has one now, and no sibling was found. The test fails before the fix and with the base types dropped from the check (1 of 233 BuildOutcomeTests). Refs #196 Defect-Class: GTS Found-By: OR Co-Authored-By: Claude Opus 5.5 <[email protected]>
…written-equals-tbase-refused-2-3-1
CaffeinatedCoder
deleted the
fix/hand-written-equals-tbase-refused-2-3-1
branch
October 30, 2026 18:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #196
Problem
A value object over a base record could declare an
Equalsof a deeper base's type:It implemented
IEquatable<DeepBase>, which the value object lists again throughIReimplementedEquatable<DeepBase>, so a collection of the base compared by it while==compared the wrapped value.ValueObjectDeclaration.EqualityDeclaredByHandrefusedEquals(TSelf)alone, andValueObjectContractAspect.IntroduceEqualityskipped its ownnew Equals(TBase)because the value object declared one. Measured onrelease/2.4.0, the code unchanged since 2.3.0.Change
EqualityDeclaredByHandrefuses anEqualsof the value object's type or of any of its base records' types, nullability aside, with the existing CMTK1011 and its remedy (normalise inCreate). One of the direct base's type is C#'s own CS0111, beside the override the record synthesizes (measured).C22-equals-of-a-base-record-s-type. The 2.3.1 changelog's Changed section says a build can fail on upgrade.Tests
BuildOutcomeTests.A_hand_written_equality_is_refused_by_namegains two rows:EqualsDeeperBase, anEquals(DeepEqualityBase?)of a deeper base's type, which fails before the fix and when the base types are dropped from the check (1 of 233).EqualsOnClass, a record class'sEquals(TSelf?), which had no fixture. It was refused already, so no sibling was found.Input class (GTS): the parameter type of a hand-written
Equals, which is the value object's own (struct, class), a deeper base's, or the direct base's (C#'s CS0111).Stacked on #200 (
build/open-2-3-1): merge it first. Independent of the #191 PR, though both add a line to 2.3.1's changelog.🤖 Generated with Claude Code