diegofrata / Generator.Equals

A source code generator for automatically implementing IEquatable<T> using only attributes.
MIT License
134 stars 19 forks source link

Do not require runtime reference to Generator.Equals.Runtime.dll #14

Closed tom-englert closed 3 years ago

tom-englert commented 3 years ago

Even for a simple usage like this

    [Equatable]
    internal partial class Class1
    {
        public string Text { get; set; } = string.Empty;
    }

a runtime reference to Generator.Equals.Runtime.dll is required, just because of the usage of the attribute.

Proposed solution:

Decorate the attributes with e.g. [Conditional("GENERATOR_EQUALS")] (like e.g. JetBrains does for their annotation attributes: https://www.jetbrains.com/help/resharper/Code_Analysis__Annotations_in_Source_Code.html)

This way a runtime reference should only be needed when using one of the special comparators.

diegofrata commented 3 years ago

It will take me a couple of weeks to look at this as I'm travelling at the moment.

diegofrata commented 3 years ago

Adding the conditional attribute is not enough here, the attribute declarations would need to be injected into the Roslyn context, so that they no longer exist in the runtime project.

tom-englert commented 3 years ago

It's just about removing the reference to the Generator.Equals.Runtime.dll - it's not a problem if the attributes are in the runtime dll. The PR did exactly this - just inspect the target assembly with e.g. ILSpy.

diegofrata commented 3 years ago

My bad, I think I understand the purpose of the change now.

diegofrata commented 3 years ago

Released in 2.2.3.