Support for struct
Hello,
Would it be possible to also generate equality members for struct ?
Yes, although I can't think of a scenario where I would ever use it. Out of curiosity, how would you use it?
I have some enums like this one and I would like to generate the equality members automatically
[Equatable]
public readonly struct Color
{
[DefaultEquality]
public int R { get; }
[DefaultEquality]
public int G { get; }
[DefaultEquality]
public int B { get; }
[DefaultEquality]
public int A { get; }
}
That should already be equatable by default -- as long as every field in a struct is a value type, equality should work. The only caveat is that, apparently, it uses reflection which is slower. I think it's easy enough to add support to structs, I will have a look.
By the way, you only need to specify DefaultEquality if using explicit mode. This would be shorter:
[Equatable]
public readonly struct Color
{
public int R { get; }
public int G { get; }
public int B { get; }
public int A { get; }
}
This is now available in version 2.6.0