Replies: 1 comment
-
not to be nitpicker (just to clarify), these are properties and not fields. when you define a new property, you should initialize it with a default value otherwise it will be null in case of nullable types, and not optional |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Instead of having to use field initializers for default values for a config it would be nice to override a method that creates the desired default values for fields.
For example:
You have a field inside your class that is optional to include in the config.
In the current implementation if this field is not initialized the value in the default config will be empty, and the user making changes to the default configuration will not necessarily understand how to format it to make it work as intended.
If you define the default value using a field initialization but the users config file is now missing this "optional" field, the config that loads will use the initialized value from the field initialization which is not always what you want.
Example:
If the users config is missing this field, the field will be initialized like above. To work around this, they have to define
MapConfigs
in their config file but make it empty so that the deserializer will override the default instance of this field.Beta Was this translation helpful? Give feedback.
All reactions