refactor(mapper): rename methods from ToItem/FromItem to FromModel/ToModel#46
Closed
refactor(mapper): rename methods from ToItem/FromItem to FromModel/ToModel#46
Conversation
- Renamed methods to ensure clearer and standardized naming conventions. - Changed `ToItem` to `FromModel`, and `FromItem` to `ToModel`. - Updated related tests, documentation, and snapshots to reflect this change. - Adjusted parameter/property names and method signatures accordingly.
- Fixed improper formatting in `TypeMappingStrategyResolver` for nullable enums. - Resolved misplacement of enum name in the expression.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🚀 Pull Request
📋 Summary
This PR implements a comprehensive refactoring to change the naming convention for mapper methods from
FromItem/ToItemtoFromModel/ToModelwith semantic reversal:ToItem→FromModel(Model → DynamoDB mapping)FromItem→ToModel(DynamoDB → Model mapping)BeforeToItem→BeforeFromModel,AfterToItem→AfterFromModel, etc.This makes the API more intuitive by naming methods based on their relationship TO or FROM the model (domain object), rather than the DynamoDB item representation.
🔧 Changes Made
Phase 1: Generator & Runtime Code (12 files)
MapperClassInfo.cs- Swapped method detection logic and renamed propertiesGeneratorContext.cs- Renamed context flags (HasFromModelMethod,HasToModelMethod)PropertyMappingSpecBuilder.cs- Renamed all builder methodsPropertyMappingCodeRenderer.cs- Updated rendering methodsMapper.scriban- Updated template variablesMapperEmitter.cs- Updated data passed to templateTypeMappingStrategyResolver.cs- Updated context flag referencesIgnoreMapping.csXML documentationPhase 2: Test Files (25 files)
DynamoIgnoreVerifyTests(IgnoreInFromModel/IgnoreInToModel)Phase 3: Example Projects (5 files)
DynamoMapper.SimpleExample/Program.csDynamoMapper.FieldLevelOverride/Program.csPhase 4: Documentation (12 files)
README.md,CLAUDE.mddocs/:dynamo-field-attribute-checklist.md✅ Checklist
🧪 Test Results
💬 Notes for Reviewers
Breaking Change
This is a MAJOR breaking change:
ToItem/FromItemtoFromModel/ToModelKey Design Decision
The refactoring uses semantic reversal rather than simple renaming:
ToModel) now map DynamoDB → ModelFromModel) now map Model → DynamoDBToMethodPrefix = "To",FromMethodPrefix = "From") remain unchanged, but their semantic interpretation is reversedThis aligns the naming with the model-centric design philosophy where methods are described relative to the model, not the item representation.
Files Changed
51 files changed, 507 insertions(+), 487 deletions(-)
Recommendation
Consider bumping version to 0.2.0-alpha or 1.0.0 to reflect the breaking change.