Skip to content

Computed properties in constructors #63

Description

@daaa57150

Describe the bug
The [AllArgsConstructor] when instructed to consider Properties, tries to set the computed properties.

To Reproduce
Example of code:

[AllArgsConstructor(MemberType = MemberType.Property, AccessTypes = AccessTypes.Public)]
public partial class ExampleDto
{
    public string? Example { get; set; }
    public string ComputedProperty => Example ?? "Empty";
}

The generated code is:

public partial class ExampleDto
{
    public ExampleDto(string? example, string computedProperty)
    {
        this.Example = example;
        this.ComputedProperty = computedProperty;
    }
}

This results in the error message Property or indexer 'ExampleDto.ComputedProperty' cannot be assigned to -- it is read only

Expected behavior
Constructors should not pick up read-only properties.

Environment info

  • .NET version: 6.x
  • Lombok.NET version: 2.4.1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions