Skip to content

Conversation

@thomashilzendegen
Copy link
Contributor

This should implement #15

@thomashilzendegen thomashilzendegen force-pushed the feature/skip-equals-method branch from f458508 to 7aff4f1 Compare November 7, 2025 23:33
@PawelGerr
Copy link
Owner

The flag should disable all equality relevant stuff, like Equal(object), Equals(T), GetHashCode, equality operators == and !=, and comparison operators <, <=, >, >=. (IComparable stays untouched by this flag)
Especially GetHashCode must not be generated otherwise the types most likely are unusable with a Dictionary. Introducing another flag SkipGetHashCode is unnecessary because they should be implemented together.

Detailed Feedback

UnionAttribute, UnionAttributeBase, ValueObjectAttributeBase:

  • Attribute property SkipEqualsMethod should be renamed to SkipEqualityComparison
  • The xml docs should be adjusted that Equals, GetHashCode, equality comparison operators and comparisons operators will not be implemented

ValueObjectAttribute:

  • When SkipEqualityComparison is set to true then EqualityComparisonOperators and ComparisonOperators must return EqualityComparisonOperators.None

ThinktectureRuntimeExtensionsAnalyzer:

  • When SkipEqualityComparison is set to true then the analyzer must not trigger DiagnosticsDescriptors.StringBasedValueObjectNeedsEqualityComparer nor DiagnosticsDescriptors.ComplexValueObjectWithStringMembersNeedsDefaultEqualityComparer
    • tests

AdHocUnionSettings, AllValueObjectSettings, ValueObjectSettings:

  • Property SkipEqualsMethod should be renamed to SkipEqualityComparison

AllValueObjectSettings:

  • When SkipEqualityComparison is set to "true" then EqualityComparisonOperators and ComparisonOperators must be set to None
    • tests

AdHocUnionCodeGenerator, ComplexValueObjectCodeGenerator:

  • When SkipEqualityComparison is set to "true" then
    • we must not generate Equals, equality operators and GetHashCode, i.e. these 3 methods must not be invoked: GenerateEqualityOperators, GenerateEquals and GenerateGetHashCode
    • the type must not have global::System.IEquatable<T> nor global::System.Numerics.IEqualityOperators<T, T, bool>
    • tests

KeyedValueObjectCodeGenerator:

  • When SkipEqualityComparison is set to "true" then
    • we must not generate Equals nor GetHashCode, i.e. these 2 methods must not be invoked: GenerateEquals and GenerateGetHashCode
    • the type must not have global::System.IEquatable<T> nor global::System.Numerics.IEqualityOperators<T, T, bool>
    • tests

@thomashilzendegen
Copy link
Contributor Author

Sure, I get your idea. My idea was to rely on the remaining implementation and only skip especially the typed Equals method. Maybe this is too specific for my use case... I will change this PR to the requested feature amount.

@thomashilzendegen thomashilzendegen force-pushed the feature/skip-equals-method branch 2 times, most recently from 15dd304 to 43cd6b5 Compare November 9, 2025 06:37
@thomashilzendegen thomashilzendegen force-pushed the feature/skip-equals-method branch from 43cd6b5 to d9bb6e3 Compare November 9, 2025 07:29
@thomashilzendegen thomashilzendegen changed the title Allow skipping the generation of the equals method Allow skipping of IEquatable<T> and comparison operators Nov 9, 2025
@PawelGerr PawelGerr merged commit 2965c7e into PawelGerr:master Nov 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants