You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a strongly typed enum (or any type of parent/child sub classes) it is worth asking: Is it more likely that I add a new member to the enum or is it more likely that I add a new property. The answer should impact how the code should be designed.
The current generator is optimized more for adding properties. When you add a new property you just need to decide what the new property should return (or behave) for each of the enum members.
Adding a new member is harder. You add the new static readonly field (i.e. the member). Then you need to update every single property for how that property needs to support that new member.
The alternate way of designing the class is so that you specify the all property values on the internal constructor for the class. These are saved as backing instance fields by the constructor. When you define the new member you just add the new member and its call to the constructor with all its properties. There is no need to edit the code for all the existing properties when adding the new member.
The text was updated successfully, but these errors were encountered:
When creating a strongly typed enum (or any type of parent/child sub classes) it is worth asking: Is it more likely that I add a new member to the enum or is it more likely that I add a new property. The answer should impact how the code should be designed.
The current generator is optimized more for adding properties. When you add a new property you just need to decide what the new property should return (or behave) for each of the enum members.
Adding a new member is harder. You add the new static readonly field (i.e. the member). Then you need to update every single property for how that property needs to support that new member.
The alternate way of designing the class is so that you specify the all property values on the internal constructor for the class. These are saved as backing instance fields by the constructor. When you define the new member you just add the new member and its call to the constructor with all its properties. There is no need to edit the code for all the existing properties when adding the new member.
The text was updated successfully, but these errors were encountered: