@@ -211,15 +211,21 @@ internal void AddParametersAssignment(LanguageWriter writer, CodeTypeBase? pathP
211
211
foreach ( var p in parameters )
212
212
{
213
213
var isStringStruct = ! p . Item1 . IsNullable && p . Item1 . Name . Equals ( "string" , StringComparison . OrdinalIgnoreCase ) ;
214
- var defaultValue = isStringStruct ? "\" \" " : "nil" ;
215
- var pointerDereference = isStringStruct ? string . Empty : "*" ;
216
- writer . StartBlock ( $ "if { p . Item3 } != { defaultValue } {{") ;
214
+ var ( defaultValue , pointerDereference , shouldCheckNullability ) = ( isStringStruct , p . Item1 . IsNullable ) switch
215
+ {
216
+ ( true , _ ) => ( "\" \" " , string . Empty , true ) ,
217
+ ( _, true ) => ( "nil" , "*" , true ) ,
218
+ ( _, false ) => ( string . Empty , string . Empty , false ) ,
219
+ } ;
220
+ if ( shouldCheckNullability )
221
+ writer . StartBlock ( $ "if { p . Item3 } != { defaultValue } {{") ;
217
222
writer . WriteLine ( $ "{ pathParametersTarget } [\" { p . Item2 } \" ] = { GetValueStringConversion ( p . Item1 . Name , pointerDereference + p . Item3 ) } ") ;
218
- writer . CloseBlock ( ) ;
223
+ if ( shouldCheckNullability )
224
+ writer . CloseBlock ( ) ;
219
225
}
220
226
}
221
227
#pragma warning restore CA1822 // Method should be static
222
- private const string StrConvHash = "i53ac87e8cb3cc9276228f74d38694a208cacb99bb8ceb705eeae99fb88d4d274" ;
228
+ internal const string StrConvHash = "i53ac87e8cb3cc9276228f74d38694a208cacb99bb8ceb705eeae99fb88d4d274" ;
223
229
private const string TimeFormatHash = "i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e" ;
224
230
private static string GetValueStringConversion ( string typeName , string reference )
225
231
{
0 commit comments