Skip to content

Nullable values #6

@hhenrik08

Description

@hhenrik08

Hi there! I’m a big fan of your data builder generator!

I’m just having one small issue when working with nullable types. Since I like my classes to be immutable, I’m using constructors for all parameters, including those that may actually be null.

When using your generator with e.g. a nullable int, the generated code calls the constructor in the following way (excluding null checks):

var instance = new Module(_id ?? default, _header, _text);
return instance;

Unfortunately, the default seems to be the default value for int-types, so I never actually get null when creating the class, as these are replaced by the value “0”.

Do you think that is something you could fix? I Would offer to look into it myself, but I doubt my experience will be sufficient to fix this.

Cheers!
Henrik

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