@@ -304,7 +304,13 @@ private static IPropertySymbol[] GetMappableProperties(
304304 }
305305
306306 // Create collection strategy (simplified for nested objects)
307- var collectionStrategy = CreateCollectionStrategy ( collectionInfo , propertyType ) ;
307+ var collectionStrategy =
308+ CreateCollectionStrategy (
309+ collectionInfo ,
310+ propertyType ,
311+ fieldOptions ,
312+ nestedContext . Context
313+ ) ;
308314 propertySpecs . Add (
309315 new NestedPropertySpec (
310316 property . Name ,
@@ -532,7 +538,8 @@ GeneratorContext context
532538 /// Creates a collection type mapping strategy.
533539 /// </summary>
534540 private static TypeMappingStrategy CreateCollectionStrategy (
535- CollectionInfo collectionInfo , ITypeSymbol originalType
541+ CollectionInfo collectionInfo , ITypeSymbol originalType , DynamoFieldOptions ? fieldOptions ,
542+ GeneratorContext context
536543 )
537544 {
538545 var isNullable = originalType . NullableAnnotation == NullableAnnotation . Annotated ;
@@ -560,16 +567,61 @@ private static TypeMappingStrategy CreateCollectionStrategy(
560567 ) ,
561568 } ;
562569
570+ var ( fromArgs , toArgs ) =
571+ GetCollectionElementTypeSpecificArgs ( collectionInfo . ElementType , fieldOptions , context ) ;
572+
563573 return new TypeMappingStrategy (
564574 typeName ,
565575 genericArg ,
566576 nullableModifier ,
567- [ ] ,
568- [ ] ,
577+ fromArgs ,
578+ toArgs ,
569579 KindOverride : collectionInfo . TargetKind
570580 ) ;
571581 }
572582
583+ private static ( string [ ] FromArgs , string [ ] ToArgs ) GetCollectionElementTypeSpecificArgs (
584+ ITypeSymbol elementType , DynamoFieldOptions ? fieldOptions , GeneratorContext context
585+ )
586+ {
587+ var underlyingType = UnwrapNullable ( elementType ) ;
588+
589+ return underlyingType switch
590+ {
591+ { SpecialType : SpecialType . System_DateTime } => CreateCollectionFormatArgs (
592+ fieldOptions ? . Format ?? context . MapperOptions . DateTimeFormat
593+ ) ,
594+ INamedTypeSymbol t when context . WellKnownTypes . IsType (
595+ t ,
596+ WellKnownTypeData . WellKnownType . System_DateTimeOffset
597+ ) => CreateCollectionFormatArgs (
598+ fieldOptions ? . Format ?? context . MapperOptions . DateTimeFormat
599+ ) ,
600+ INamedTypeSymbol t when context . WellKnownTypes . IsType (
601+ t ,
602+ WellKnownTypeData . WellKnownType . System_Guid
603+ ) => CreateCollectionFormatArgs (
604+ fieldOptions ? . Format ?? context . MapperOptions . GuidFormat
605+ ) ,
606+ INamedTypeSymbol t when context . WellKnownTypes . IsType (
607+ t ,
608+ WellKnownTypeData . WellKnownType . System_TimeSpan
609+ ) => CreateCollectionFormatArgs (
610+ fieldOptions ? . Format ?? context . MapperOptions . TimeSpanFormat
611+ ) ,
612+ INamedTypeSymbol { TypeKind : TypeKind . Enum } => CreateCollectionFormatArgs (
613+ fieldOptions ? . Format ?? context . MapperOptions . EnumFormat
614+ ) ,
615+ _ => ( [ ] , [ ] ) ,
616+ } ;
617+ }
618+
619+ private static ( string [ ] FromArgs , string [ ] ToArgs ) CreateCollectionFormatArgs ( string format )
620+ {
621+ var arg = $ "\" { format } \" ";
622+ return ( [ arg ] , [ arg ] ) ;
623+ }
624+
573625 /// <summary>
574626 /// Unwraps Nullable{T} to get the underlying type.
575627 /// </summary>
0 commit comments