@@ -25,22 +25,22 @@ private static CodeFactory CreateDictionaryMethod(TypeIdentifier typeIdentifier,
2525
2626 var marshallerInvocation = InvokeMarshallerMethod ( x . DataMember . TypeIdentifier , accessPattern , $ "\" { x . DataMember . Name } \" ", options ) ;
2727
28- var assignment = x . DataMember . TypeIdentifier . IsNullable
28+ var assignment = x . DataMember . TypeIdentifier . IsSupposedToBeNull
2929 ? $ "if ({ x . DataMember . NameAsCamelCase } is not null)"
3030 . CreateScope ( $ "{ DictionaryReference } [\" { x . AttributeName } \" ] = { x . DataMember . NameAsCamelCase } ;")
3131 . Prepend ( $ "var { x . DataMember . NameAsCamelCase } = { marshallerInvocation } ;")
3232 : new [ ] { $ "{ DictionaryReference } [\" { x . AttributeName } \" ] = { marshallerInvocation } ;" } ;
3333
3434 return (
3535 dictionaryAssignment : assignment ,
36- capacityTernary : x . DataMember . TypeIdentifier . IsNullable ? x . DataMember . TypeIdentifier . TypeSymbol . NotNullTernaryExpression ( in accessPattern , "1" , "0" ) : "1" ,
36+ capacityTernary : x . DataMember . TypeIdentifier . IsSupposedToBeNull ? x . DataMember . TypeIdentifier . TypeSymbol . NotNullTernaryExpression ( in accessPattern , "1" , "0" ) : "1" ,
3737 x . DataMember
3838 ) ;
3939 } )
4040 . ToArray ( ) ;
4141
4242 var enumerable = Enumerable . Empty < string > ( ) ;
43- if ( typeIdentifier . IsNullable )
43+ if ( typeIdentifier . IsSupposedToBeNull )
4444 enumerable = $ "if ({ ParamReference } is null)". CreateScope ( "return null;" ) ;
4545 else if ( typeIdentifier . TypeSymbol . IsReferenceType )
4646 enumerable = $ "if ({ ParamReference } is null)". CreateScope ( $ "throw { ExceptionHelper . NullExceptionMethod } ({ DataMember } );") ;
@@ -51,7 +51,7 @@ private static CodeFactory CreateDictionaryMethod(TypeIdentifier typeIdentifier,
5151 . Append ( $ "return { DictionaryReference } ;") ) ;
5252
5353 var code =
54- $ "public static Dictionary<string, AttributeValue>{ ( typeIdentifier . IsNullable ? '?' : null ) } { GetSerializationMethodName ( typeIdentifier . TypeSymbol ) } ({ typeIdentifier . AnnotatedString } { ParamReference } , { options . FullName } { MarshallerOptions . ParamReference } , string? { DataMember } = null)"
54+ $ "public static Dictionary<string, AttributeValue>{ ( typeIdentifier . IsSupposedToBeNull ? '?' : null ) } { GetSerializationMethodName ( typeIdentifier . TypeSymbol ) } ({ typeIdentifier . AnnotatedString } { ParamReference } , { options . FullName } { MarshallerOptions . ParamReference } , string? { DataMember } = null)"
5555 . CreateScope ( body ) ;
5656
5757 return new CodeFactory ( code , properties . Select ( y => y . DataMember . TypeIdentifier ) ) ;
@@ -81,7 +81,7 @@ private static CodeFactory CreateMethod(TypeIdentifier typeIdentifier, Func<ITyp
8181 return typeIdentifier . CanBeNull is false
8282 ? signature . CreateScope ( $ "return { conversion } ;") . ToConversion ( )
8383 : signature . CreateScope ( $ "if ({ ParamReference } is null)"
84- . CreateScope ( typeIdentifier . IsNullable
84+ . CreateScope ( typeIdentifier . IsSupposedToBeNull
8585 ? "return null;"
8686 : $ "throw { ExceptionHelper . NullExceptionMethod } ({ DataMember } );"
8787 )
@@ -104,28 +104,28 @@ private static CodeFactory CreateMethod(TypeIdentifier typeIdentifier, Func<ITyp
104104 . CreateScope (
105105 $ "if ({ ParamReference } is null)"
106106 . CreateScope ( singleGeneric . ReturnNullOrThrow ( DataMember ) )
107- . Append ( $ "return { AttributeValueUtilityFactory . FromArray } ({ ParamReference } , { MarshallerOptions . ParamReference } , { DataMember } , static (a, o, d) => { InvokeMarshallerMethod ( singleGeneric . T , "a" , "d" , options , "o" ) } { ( singleGeneric . T . IsNullable ? $ " ?? { AttributeValueUtilityFactory . Null } " : null ) } );")
107+ . Append ( $ "return { AttributeValueUtilityFactory . FromArray } ({ ParamReference } , { MarshallerOptions . ParamReference } , { DataMember } , static (a, o, d) => { InvokeMarshallerMethod ( singleGeneric . T , "a" , "d" , options , "o" ) } { ( singleGeneric . T . IsSupposedToBeNull ? $ " ?? { AttributeValueUtilityFactory . Null } " : null ) } );")
108108 ) . ToConversion ( singleGeneric . T ) ,
109109 SingleGeneric . SupportedType . List => signature
110110 . CreateScope (
111111 $ "if ({ ParamReference } is null)"
112112 . CreateScope ( singleGeneric . ReturnNullOrThrow ( DataMember ) )
113- . Append ( $ "return { AttributeValueUtilityFactory . FromList } ({ ParamReference } , { MarshallerOptions . ParamReference } , { DataMember } , static (a, o, d) => { InvokeMarshallerMethod ( singleGeneric . T , "a" , "d" , options , "o" ) } { ( singleGeneric . T . IsNullable ? $ " ?? { AttributeValueUtilityFactory . Null } " : null ) } );")
113+ . Append ( $ "return { AttributeValueUtilityFactory . FromList } ({ ParamReference } , { MarshallerOptions . ParamReference } , { DataMember } , static (a, o, d) => { InvokeMarshallerMethod ( singleGeneric . T , "a" , "d" , options , "o" ) } { ( singleGeneric . T . IsSupposedToBeNull ? $ " ?? { AttributeValueUtilityFactory . Null } " : null ) } );")
114114 ) . ToConversion ( singleGeneric . T ) ,
115115 SingleGeneric . SupportedType . IReadOnlyCollection
116116 or SingleGeneric . SupportedType . IEnumerable
117117 or SingleGeneric . SupportedType . ICollection => signature
118118 . CreateScope (
119119 $ "if ({ ParamReference } is null)"
120120 . CreateScope ( singleGeneric . ReturnNullOrThrow ( DataMember ) )
121- . Append ( $ "return { AttributeValueUtilityFactory . FromEnumerable } ({ ParamReference } , { MarshallerOptions . ParamReference } , { DataMember } , static (a, o, d) => { InvokeMarshallerMethod ( singleGeneric . T , "a" , "d" , options , "o" ) } { ( singleGeneric . T . IsNullable ? $ " ?? { AttributeValueUtilityFactory . Null } " : null ) } );")
121+ . Append ( $ "return { AttributeValueUtilityFactory . FromEnumerable } ({ ParamReference } , { MarshallerOptions . ParamReference } , { DataMember } , static (a, o, d) => { InvokeMarshallerMethod ( singleGeneric . T , "a" , "d" , options , "o" ) } { ( singleGeneric . T . IsSupposedToBeNull ? $ " ?? { AttributeValueUtilityFactory . Null } " : null ) } );")
122122 ) . ToConversion ( singleGeneric . T ) ,
123123 SingleGeneric . SupportedType . Set when singleGeneric . T . TypeSymbol . SpecialType is SpecialType . System_String
124124 => signature
125125 . CreateScope (
126126 $ "if ({ ParamReference } is null)"
127127 . CreateScope ( singleGeneric . ReturnNullOrThrow ( DataMember ) )
128- . Append ( $ "return new { Constants . AWSSDK_DynamoDBv2 . AttributeValue } {{ SS = new List<{ ( singleGeneric . T . IsNullable ? "string?" : "string" ) } >({ ( singleGeneric . T . IsNullable ? ParamReference : $ "{ ParamReference } .Select((y,i) => y ?? throw { ExceptionHelper . NullExceptionMethod } ($\" {{{DataMember}}}[UNKNOWN]\" ))") } )}};")
128+ . Append ( $ "return new { Constants . AWSSDK_DynamoDBv2 . AttributeValue } {{ SS = new List<{ ( singleGeneric . T . IsSupposedToBeNull ? "string?" : "string" ) } >({ ( singleGeneric . T . IsSupposedToBeNull ? ParamReference : $ "{ ParamReference } .Select((y,i) => y ?? throw { ExceptionHelper . NullExceptionMethod } ($\" {{{DataMember}}}[UNKNOWN]\" ))") } )}};")
129129 )
130130 . ToConversion ( singleGeneric . T ) ,
131131 SingleGeneric . SupportedType . Set when singleGeneric . T . IsNumeric
@@ -147,14 +147,14 @@ SingleGeneric.SupportedType.Set when singleGeneric.T.IsNumeric
147147 . CreateScope (
148148 $ "if ({ ParamReference } is null)"
149149 . CreateScope ( keyValueGeneric . ReturnNullOrThrow ( DataMember ) )
150- . Append ( $ "return { AttributeValueUtilityFactory . FromDictionary } ({ ParamReference } , { MarshallerOptions . ParamReference } , { DataMember } , static (a, o, d) => { InvokeMarshallerMethod ( keyValueGeneric . TValue , "a" , "d" , options , "o" ) } { ( keyValueGeneric . TValue . IsNullable ? $ " ?? { AttributeValueUtilityFactory . Null } " : null ) } );")
150+ . Append ( $ "return { AttributeValueUtilityFactory . FromDictionary } ({ ParamReference } , { MarshallerOptions . ParamReference } , { DataMember } , static (a, o, d) => { InvokeMarshallerMethod ( keyValueGeneric . TValue , "a" , "d" , options , "o" ) } { ( keyValueGeneric . TValue . IsSupposedToBeNull ? $ " ?? { AttributeValueUtilityFactory . Null } " : null ) } );")
151151 )
152152 . ToConversion ( keyValueGeneric . TValue ) ,
153153 KeyValueGeneric . SupportedType . LookUp => signature
154154 . CreateScope (
155155 $ "if ({ ParamReference } is null)"
156156 . CreateScope ( keyValueGeneric . ReturnNullOrThrow ( DataMember ) )
157- . Append ( $ "return { AttributeValueUtilityFactory . FromLookup } ({ ParamReference } , { MarshallerOptions . ParamReference } , { DataMember } , static (a, o, d) => { InvokeMarshallerMethod ( keyValueGeneric . TValue , "a" , "d" , options , "o" ) } { ( keyValueGeneric . TValue . IsNullable ? $ " ?? { AttributeValueUtilityFactory . Null } " : null ) } );")
157+ . Append ( $ "return { AttributeValueUtilityFactory . FromLookup } ({ ParamReference } , { MarshallerOptions . ParamReference } , { DataMember } , static (a, o, d) => { InvokeMarshallerMethod ( keyValueGeneric . TValue , "a" , "d" , options , "o" ) } { ( keyValueGeneric . TValue . IsSupposedToBeNull ? $ " ?? { AttributeValueUtilityFactory . Null } " : null ) } );")
158158 )
159159 . ToConversion ( keyValueGeneric . TValue ) ,
160160 _ => throw UncoveredConversionException ( keyValueGeneric , nameof ( CreateMethod ) )
@@ -168,7 +168,7 @@ SingleGeneric.SupportedType.Set when singleGeneric.T.IsNumeric
168168 private static string CreateSignature ( TypeIdentifier typeIdentifier , MarshallerOptions options )
169169 {
170170 var typeSymbol = typeIdentifier . TypeSymbol ;
171- return typeIdentifier . IsNullable
171+ return typeIdentifier . IsSupposedToBeNull
172172 ? $ "public static { Constants . AWSSDK_DynamoDBv2 . AttributeValue } ? { GetSerializationMethodName ( typeSymbol ) } ({ typeIdentifier . AnnotatedString } { ParamReference } , { options . FullName } { MarshallerOptions . ParamReference } , string? { DataMember } = null)"
173173 : $ "public static { Constants . AWSSDK_DynamoDBv2 . AttributeValue } { GetSerializationMethodName ( typeSymbol ) } ({ typeIdentifier . AnnotatedString } { ParamReference } , { options . FullName } { MarshallerOptions . ParamReference } , string? { DataMember } = null)";
174174 }
0 commit comments