Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Support CustomEqualityAttribute for the whole class #64

Open
emphasis87 opened this issue Oct 15, 2024 · 2 comments
Open

Comments

@emphasis87
Copy link

This is to be able to setup the default comparer for all properties at once.

@diegofrata
Copy link
Owner

Could you elaborate on how you imagine this working? Code examples are helpful too!

@emphasis87
Copy link
Author

If you mean implementation-wise then I will be of not much help, I haven't had a good look at implementing source generators yet.

If you mean usage-wise, instead of

[Equatable]
public record MyRecord(
  [propery: CustomEquality(typeof(MyEqualityComparer)] object property1,
  [propery: CustomEquality(typeof(MyEqualityComparer)] object property2,
  [propery: CustomEquality(typeof(MyEqualityComparer)] object property3);

You would write:

[Equatable]
[CustomEquality(typeof(MyEqualityComparer))]
public record MyRecord(object property1, object property2, object property3);

or

[Equatable]
[DefaultComparer(typeof(MyEqualityComparer))]
public record MyRecord(object property1, object property2, object property3);

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

No branches or pull requests

2 participants