CollinAlpert / Lombok.NET

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

With Attribute fails to properly name method parameters when they collide with c# keywords #55

Closed ristogod closed 2 weeks ago

ristogod commented 3 weeks ago

Describe the bug If a property is named Default, the parameter is named default which is a reserved keyword in C#. It should be named @default.

To Reproduce

[With(MemberType = Property)]
public partial class MyClass
{
   public bool Default { get; set; }
}

Generates

public partial class MyClass
{
    public ImageDataModel WithDefault(bool default)
    {
        this.Default = default;
        return this;
    }
}

Expected behavior

public partial class MyClass
{
    public ImageDataModel WithDefault(bool @default)
    {
        this.Default = @default;
        return this;
    }
}

Environment info

.NET version: 8.0 Lombok.NET version: 2.4.0

CollinAlpert commented 2 weeks ago

Thank you for the issue, the fix is available in v2.4.1.