Nullable enum cause circular reference
michalciolek opened this issue · comments
- Fody 6.6.0 and 6.6.4
- Any Fody weavers being used: Equals 4.0.2
- .NetFramework
Describe the issue
I added nullable to my enum field in class (with [Equls]):
#nullable enable
namespace NullableEnum
{
[Equals]
public class Example
{
/// <summary>
/// This adds a circular reference to self (NullableEnum.exe)!
/// </summary>
public ExampleEnum? ExampleEnum { get; set; }
public static bool operator ==(Example? left, Example? right) => Operator.Weave(left, right);
public static bool operator !=(Example? left, Example? right) => Operator.Weave(left, right);
}
}
This cause my result binary to have a (circular) reference to itself:
Without nullability, in enum, my result binary does not have reference to itself.
Minimal Repro
I have created a minimal project with this issue:
https://github.com/michalciolek/NullableEnum-fody-equals
I would recommend to switch to a source generator to auto-implement the equality pattern.
@tom-englert can you elaborate because I don't understand.
Now I manually wrote the equals code (using visual studio code generator) as a solution. That's what you mean?
Something like this https://github.com/diegofrata/Generator.Equals