Skip to content

Support for init-only properties#38

Merged
StefH merged 3 commits intomainfrom
init
Jun 23, 2022
Merged

Support for init-only properties#38
StefH merged 3 commits intomainfrom
init

Conversation

@StefH
Copy link
Copy Markdown
Owner

@StefH StefH commented Jun 21, 2022

No description provided.

{
Normal = _normal.Value
};
if (_idIsSet) { SetId(instance, _id.Value); }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After some more thought, I'd suggest the constructor can just be this:

instance = new ClassWithInit
{
   Normal = _normal.Value,
   Id = _id.Value,
   Test = _test.Value
}

Leave it to the developer to call WithId, WithNormal, and WithTest to set diff values.

For my knowledge, what problem are you trying to solve with _<name>IsSet? Since you've initialized all the lazy fields, defaults will just be used and that should be fine.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is changed.

@StefH StefH merged commit f624c4f into main Jun 23, 2022
@StefH StefH deleted the init branch June 23, 2022 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants