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

Nullable enum cause circular reference #480

Open
michalciolek opened this issue Jan 20, 2023 · 3 comments
Open

Nullable enum cause circular reference #480

michalciolek opened this issue Jan 20, 2023 · 3 comments

Comments

@michalciolek
Copy link

  • 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:
references

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

@tom-englert
Copy link
Member

I would recommend to switch to a source generator to auto-implement the equality pattern.

@michalciolek
Copy link
Author

@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?

@tom-englert
Copy link
Member

Something like this https://github.com/diegofrata/Generator.Equals

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants