@@ -69,7 +69,7 @@ public static (string ExtensionMethods, string TypeAliases) GenerateExtensionMet
6969 }
7070 }
7171
72- var publicMethodsCode = GenerateGroupedCode ( groupedMethods ) ;
72+ var ( publicMethodsCode , privateDelegatesCode ) = GenerateGroupedCode ( groupedMethods ) ;
7373 var typeAliases = GenerateTypeAliasesFile ( responseTypes , @namespace ) ;
7474
7575 var namingPolicyCode = jsonNamingPolicy switch
@@ -113,12 +113,14 @@ public static class {{className}}
113113 PropertyNamingPolicy = {{ namingPolicyCode }}
114114 };
115115
116+ private static readonly Deserialize<Unit> _deserializeUnit = static (_, _) =>
117+ Task.FromResult(Unit.Value);
118+
116119 #endregion
117120
118121 {{ publicMethodsCode }}
119122
120- private static readonly Deserialize<Unit> _deserializeUnit = static (_, _) =>
121- Task.FromResult(Unit.Value);
123+ {{ privateDelegatesCode }}
122124
123125 private static ProgressReportingHttpContent CreateJsonContent<T>(T data)
124126 {
@@ -170,24 +172,30 @@ private static string GetResourceNameFromPath(string path)
170172 return CodeGenerationHelpers . ToPascalCase ( resourceSegment ) ;
171173 }
172174
173- private static string GenerateGroupedCode ( Dictionary < string , List < ( string PublicMethod , string PrivateDelegate ) > > groupedMethods )
175+ private static ( string PublicMethods , string PrivateDelegates ) GenerateGroupedCode ( Dictionary < string , List < ( string PublicMethod , string PrivateDelegate ) > > groupedMethods )
174176 {
175- var sections = new List < string > ( ) ;
177+ var publicSections = new List < string > ( ) ;
178+ var allPrivateDelegates = new List < string > ( ) ;
176179
177180 foreach ( var group in groupedMethods . OrderBy ( g => g . Key ) )
178181 {
179- var methodPairs = group . Value . Select ( m => $ "{ m . PrivateDelegate } \n \n { m . PublicMethod } ") ;
180- var methodsCode = string . Join ( "\n \n " , methodPairs ) ;
181- var indentedContent = CodeGenerationHelpers . Indent ( methodsCode , 1 ) ;
182+ var publicMethods = group . Value . Select ( m => m . PublicMethod ) ;
183+ var privateDelegates = group . Value . Select ( m => m . PrivateDelegate ) ;
184+
185+ var publicMethodsCode = string . Join ( "\n \n " , publicMethods ) ;
186+ var indentedContent = CodeGenerationHelpers . Indent ( publicMethodsCode , 1 ) ;
182187 var regionName = $ "{ group . Key } Operations";
183188
184189 // #region markers at column 0, content indented by 4 spaces
185190 var section = $ " #region { regionName } \n \n { indentedContent } \n \n #endregion";
186191
187- sections . Add ( section ) ;
192+ publicSections . Add ( section ) ;
193+ allPrivateDelegates . AddRange ( privateDelegates ) ;
188194 }
189195
190- return string . Join ( "\n \n " , sections ) ;
196+ var privateDelegatesCode = string . Join ( "\n \n " , allPrivateDelegates . Select ( d => CodeGenerationHelpers . Indent ( d , 1 ) ) ) ;
197+
198+ return ( string . Join ( "\n \n " , publicSections ) , privateDelegatesCode ) ;
191199 }
192200
193201 private static ( string PublicMethod , string PrivateDelegate ) GenerateMethod (
@@ -516,14 +524,18 @@ string summary
516524 var buildRequestBody =
517525 $ "static param => new HttpRequestParts(new RelativeUrl($\" { pathWithParamInterpolation } { queryString } \" ), CreateJsonContent(param.Body), { headersExpression } )";
518526
527+ // Public methods ALWAYS have individual parameters, never tuples
519528 var publicMethodParams = hasNonPathNonBodyParams
520529 ? string . Join ( ", " , parameters . Select ( p => $ "{ p . Type } { p . Name } ") )
521530 + $ ", { bodyType } body"
522- : $ "{ compositeType } param";
531+ : string . Join ( ", " , pathParams . Select ( p => $ "{ p . Type } { p . Name } ") )
532+ + $ ", { bodyType } body";
523533
524534 var publicMethodInvocation = hasNonPathNonBodyParams
525535 ? $ "({ string . Join ( ", " , parameters . Select ( p => p . Name ) ) } , body)"
526- : "param" ;
536+ : isSinglePathParam
537+ ? $ "({ pathParamsNames } , body)"
538+ : $ "(({ pathParamsNames } ), body)";
527539
528540 return BuildMethod (
529541 methodName ,
0 commit comments