Lombok.NET icon indicating copy to clipboard operation
Lombok.NET copied to clipboard

`[AllArgsConstructor]` with inheritance

Open daaa57150 opened this issue 1 year ago • 2 comments

Is your feature request related to a problem? Please describe. Hi, I was trying to add the [AllArgsConstructor] to a class inheriting another, and the constructor generated only uses the current class' properties. Is this expected ?

Describe the solution you'd like The corresponding properties of the base class should be included in the constructor, or at least have a flag parameter ?

Describe alternatives you've considered None, just write the constructors myself in this particular case.

Additional context Here is the code that fails to generate what I was expecting

[AllArgsConstructor(MemberType = MemberType.Property, AccessTypes = AccessTypes.Public)]
public partial class BaseModel
{
    public string Number { get; set; }
    public string Label { get; set; }
}

[AllArgsConstructor(MemberType = MemberType.Property, AccessTypes = AccessTypes.Public)]
public partial class ExtendedModel : BaseModel
{
    public string? Summary { get; set; }
    public string? Result{ get; set; }
}

The generated code is:

public partial class ExtendedModel
{
    public ExtendedModel (string? summary, string? result)
    {
        this.Summary = summary;
        this.Result = result;
    }
}

I would expect a constructor with 4 parameters, optionally calling base() with the parameters of the base class.

daaa57150 avatar Jan 27 '25 13:01 daaa57150