Generate mutation die helpers for fields #149
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Many more common mutation methods are now generated. These methods require additional metadata since they use dies backing a field value within the current die. Typically the required metadata is the name of the field on the current die, and the type for the Die backing the nested field's type. Additional metadata is required for fields backed by slices.
See updates to the README for details.
Where possible, existing mutation methods are updated to use the new code generation. In cases where the generated method name is different, the previous method was deprecated in favor of the new method. Where there is a discrepancy, the new names are more consistent.
Remaining mutation methods are mostly custom one-off methods that will likely never be generated. Adding additional methods in the future will be much easier as all applicable dies will get the new behavior.
Future enhancements can reduce the amount of metadata that the user must provide for each field by looking up type information and existing doc tags about the target field.