CollinAlpert / Lombok.NET

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

Don't change field name in parameters list #38

Closed View12138 closed 7 months ago

View12138 commented 8 months ago

Is your feature request related to a problem? Please describe. Don't change field name in parameters list when the parameter name is the same as the field name. eg: name = newName;.

Describe the solution you'd like when the parameter name is the same as field name, use this to assess field. eg: this.name = name;.

Describe alternatives you've considered

// source code
[AllArgsConstructor(MemberType = MemberType.{{memberType}})]
internal partial class TestClass
{
    private string name;
    private string _name;
    private string @string;
    private int _age;
}

// now <auto-generated/>
internal partial class TestClass
{
    internal TestClass(string newName, string name, string newString, int newAge)
    {
        name = newName;
        _name = name;
        @string = newString;
        _age = newAge;
    }
}

// new <auto-generated/>
internal partial class TestClass
{
    internal TestClass(string name1, string name2, string @string, int age)
    {
        name = name1;
        _name = name2;
        this.@string = @string;
        this.age = age;
    }
}
CollinAlpert commented 7 months ago

Fixed in v2.3.1