Add diagnostics in case any property is marked with a Generator.Equals-related attribute, but the containing type is not marked [Equatable]
First of all, thanks for this amazing project! It has snuck its way into many projects of mine.
As a small suggestion, it might be really helpful if it'd be possible to add diagnostics when any property is annotated with a Generator.Equals-related attribute, but the containing type is not properly marked. For example
record Test([property: UnorderedEquality] IReadOnlyCollection<int> stuff)
This looks deceptively correct to the coffee-deprived brain, and in fact "someone" may have just accidentally wasted an hour debugging an issue that just boiled down to this oversight.
The code above currently doesn't generate any warnings or errors. It'd be quite nice to get a diagnostics warning in such cases saying that the type should be marked with [Equatable].
This is an excellent suggestion. An analyzer should support something like an opt-out mechanism where all non-primitive fields are explicitly marked with a specific attribute to control their comparison behavior.
Added Analyzer for this scenario: https://github.com/NikiforovAll/Generator.Equals.Analyzers
cc: @fabianoliver
@diegofrata, could you please consider adding this package to your repo?
yeah, that would be nice feature to have
@NikiforovAll what's the proposed integration here? Add this as dependency or just have it built into this package?
I'd like to suggest adding an analyzer as a separate package to this GitHub repo. My analyzer implementation could serve as a foundation or reference point for this addition.
@NikiforovAll that's what I thought! I might try to rip your code into Generator.Equals if that's okay with you. Would you mind adding a LICENCE.md file to your repo (I suggest MIT), so that I can bring your code in?
FYI
@diegofrata updated the license file.