-
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Priority: P2 - Important
Tier: 3 - Advanced Features
Effort: Large (10-16 hours)
Already In Codebase
- No
IDynamoConverter<T>exists insrc/LayeredCraft.DynamoMapper.Runtime/. DynamoFieldAttributedoes not expose a converter-type property today.- Generator has no converter parsing/validation logic.
- Docs reference
IDynamoConverter<T>heavily (e.g.,docs/usage/converters.md).
Goal
Support declaring a reusable converter type for a mapped member via class-level [DynamoField].
Example desired usage:
[DynamoMapper]
[DynamoField(nameof(MyEntity.Status), Converter = typeof(OrderStatusConverter))]
public static partial class MyEntityMapper { }Runtime API (part of this story)
- Add
IDynamoConverter<T>:
public interface IDynamoConverter<T>
{
AttributeValue ToAttributeValue(T value);
T FromAttributeValue(AttributeValue value);
}- Extend
DynamoFieldAttributewith:
Type? Converter
Generator behavior
- Validate converter type implements
IDynamoConverter<TProperty>. - Emit code that uses the converter:
- Prefer a cached
static readonlyconverter instance per mapper to avoid allocations. - Call
converter.ToAttributeValue(value)/converter.FromAttributeValue(attributeValue).
- Prefer a cached
Conflicts
- Converter cannot be used together with
ToMethod/FromMethod(emit diagnostic).
Diagnostics
- Converter type does not implement
IDynamoConverter<T>. - Converter generic type mismatch with property type.
- Conflicting converter config.
Tests (must be part of this story)
Add verify tests covering:
- Happy path: converter type used in generated code.
- Failure: wrong interface or mismatch emits diagnostic.
- Failure: converter + ToMethod/FromMethod emits diagnostic.
Acceptance criteria
- Converter types work for custom member types.
- Diagnostics are clear and point to the attribute usage.
- Snapshot tests cover happy path and key failures.
Metadata
Metadata
Assignees
Labels
No labels