-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat(hooks): implement customization lifecycle hooks #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e460557
feat(mapper): add support for lifecycle hooks in generated mappers
j-d-ha 8af6574
test(hooks): add comprehensive tests for lifecycle hooks in mappers
j-d-ha a30db0e
feat(diagnostics): introduce new rules for hook signature validation
j-d-ha de90419
docs(hooks): enhance customization hooks documentation
j-d-ha 844d98f
test(integration-tests): add integration tests for HooksIntegrationMoβ¦
j-d-ha cb2c930
fix(generators): remove path-specific ToItem semicolon sentinel
j-d-ha b9deb2c
docs(generators): document diagnostic ID range conventions
j-d-ha b415c8e
feat(config): add JetBrains ReSharper Global Tools to .config
j-d-ha ad0a043
fix(generators): validate hook signatures and surface DM040x diagnostics
j-d-ha 1c75201
test(generators): cover hook diagnostics and from-only hook scenarios
j-d-ha a0b170f
docs(hooks): add detailed lifecycle hooks documentation
j-d-ha dfa771b
chore(build): bump version prefix to 1.4.0
j-d-ha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "version": 1, | ||
| "isRoot": true, | ||
| "tools": { | ||
| "jetbrains.resharper.globaltools": { | ||
| "version": "2025.3.3", | ||
| "commands": [ | ||
| "jb" | ||
| ], | ||
| "rollForward": false | ||
| } | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -422,8 +422,6 @@ FodyWeavers.xsd | |
|
|
||
| .idea | ||
|
|
||
| .config | ||
|
|
||
| # macOS | ||
| .DS_Store | ||
| .DS_Store? | ||
|
|
||
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # Hooks | ||
|
|
||
| ## Supported lifecycle hooks | ||
|
|
||
| Hooks are optional `static partial void` methods on the mapper class. | ||
|
|
||
| - `BeforeToItem(T source, Dictionary<string, AttributeValue> item)` | ||
| - `AfterToItem(T source, Dictionary<string, AttributeValue> item)` | ||
| - `BeforeFromItem(Dictionary<string, AttributeValue> item)` | ||
| - `AfterFromItem(Dictionary<string, AttributeValue> item, ref T entity)` | ||
|
|
||
| Where `T` is the mapper model type. | ||
|
|
||
| ## Generation behavior | ||
|
|
||
| - hooks are discovered by exact method names above | ||
| - hooks can be declared and implemented in separate parts of the same partial mapper class | ||
| - one-way mappers are supported; only hooks for generated directions are emitted | ||
| - no `To*` hooks keeps `To*` expression-bodied | ||
| - any `To*` hook switches `To*` generation to block body | ||
|
|
||
| ## Execution order | ||
|
|
||
| - `To*`: create dictionary -> `BeforeToItem` -> map members -> `AfterToItem` -> return | ||
| - `From*`: `BeforeFromItem` -> map/construct model -> `AfterFromItem` -> return | ||
|
|
||
| ## Validation diagnostics | ||
|
|
||
| - `DM0401` invalid hook signature | ||
| - wrong parameter count | ||
| - wrong `ref` usage (`AfterFromItem` must use `ref` on entity) | ||
| - non-void return type | ||
| - non-partial hook method | ||
| - `DM0402` hook is not static | ||
| - `DM0403` hook parameter types do not match mapper model/dictionary requirements | ||
|
|
||
| These diagnostics are warnings. | ||
|
|
||
| ## Safe guidance | ||
|
|
||
| - use hooks for DynamoDB-specific concerns (PK/SK composition, TTL, metadata, normalization) | ||
| - keep hook logic focused; avoid placing domain business workflows in hooks |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.