IgnoreDuringEqualsAttribute not accessible at runtime
SebastianStehle opened this issue · comments
Almost everything works great, but I have a class that is also json serialized.
The serializer throws the following exception:
System.TypeLoadException : Could not load type 'IgnoreDuringEqualsAttribute' from assembly 'System.Diagnostics.Debug, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
When I open this type in ILSpy, I see that the IgnoreDuringEqualsAttribute is there but I cannot follow it to the implementation, so somehow the IL is corrupt.
Btw: I am using .NET Core 3
@SebastianStehle did you read the issue template https://github.com/Fody/.github/blob/master/.github/ISSUE_TEMPLATE/bug_report.md ?
You mean the "Minimal Repro"?
Yeah, I was lazy, sorry. Here is the repro: https://github.com/SebastianStehle/FodyTest
The problem is when the attributes are used in a base class that do not have the Equals attribute.
My solution is to add
[Equals(DoNotAddEquals = true, DoNotAddGetHashCode = true, DoNotAddEqualityOperators = true)]
to the base class, but it is not very intuitive.
From a quick glance at the source code, it looks like this weaver won't remove the attributes on classes which don't have an [Equals]
attribute.
Note that [Equals]
is not inherited, therefore using other attributes on a class without [Equals]
is an error. A warning should probably be emitted there, and in any case attributes should be removed from all types, not just those marked with [Equals]
.
The behavior makes sense, it is just the remove that it is the problem. Because the IgnoreDuringEqualsAttribute works as expected :)
i will add a compile error that explains the problem