CollinAlpert / Lombok.NET

.NET adaptation for Java's Lombok using Source Generators.
MIT License
309 stars 16 forks source link

Make the [With] attribute work for inherited members #42

Closed michaldivis closed 4 months ago

michaldivis commented 4 months ago

Is your feature request related to a problem? Please describe. I'd like to use this library to generate With methods for a class that inherits from a base class, however, I only get With methods generated for the members of the class I apply the attribute on.

This of course wouldn't be a problem if I owned the base class, but that is not the case as the base class comes from an external library.

Describe the solution you'd like Optionally allow to generate With methods on inherited members.

I image it could be a property on the WithAttribute, something like:

[With(IncludeInheritedMembers = true)]
public class MyClass : ExternalBaseClass
{
    // ...
}

Describe alternatives you've considered An alternative solution would be to apply the WithAttribute to the base class, but as mentioned before, that's not possible in my case.

CollinAlpert commented 4 months ago

I like the solution with the IncludeInheritedMembers option! If this is urgent, you could look into opening a PR, I will probably only get to it sometime this month.

michaldivis commented 4 months ago

I already solved the problem by implementing my own source generator for it but I'll try to find time to open a PR here as well.

CollinAlpert commented 4 months ago

@michaldivis I have started working on this now.

CollinAlpert commented 4 months ago

Available in v2.4.0

michaldivis commented 4 months ago

@CollinAlpert Thanks a lot!