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

IgnoreDuringEqualsAttribute not accessible at runtime #175

Closed
SebastianStehle opened this issue Jan 30, 2020 · 6 comments
Closed

IgnoreDuringEqualsAttribute not accessible at runtime #175

SebastianStehle opened this issue Jan 30, 2020 · 6 comments
Labels
Milestone

Comments

@SebastianStehle
Copy link

SebastianStehle commented Jan 30, 2020

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

@SimonCropp
Copy link
Member

@SebastianStehle
Copy link
Author

SebastianStehle commented Jan 30, 2020

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.

@SebastianStehle
Copy link
Author

My solution is to add

[Equals(DoNotAddEquals = true, DoNotAddGetHashCode = true, DoNotAddEqualityOperators = true)] to the base class, but it is not very intuitive.

@ltrzesniewski
Copy link
Member

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].

@SebastianStehle
Copy link
Author

The behavior makes sense, it is just the remove that it is the problem. Because the IgnoreDuringEqualsAttribute works as expected :)

@SimonCropp
Copy link
Member

i will add a compile error that explains the problem

@SimonCropp SimonCropp added this to the 4.0.1 milestone Feb 2, 2020
@SimonCropp SimonCropp added the Bug label Feb 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants