File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
src/GraphODataTemplateWriter/Extensions Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ namespace <#=method.Namespace.GetNamespaceName()#>
31
31
public partial class <#=requestBody#>
32
32
{
33
33
<#
34
- foreach (var param in method.Parameters )
34
+ foreach (var param in method.WithDistinctParameters() )
35
35
{
36
36
var paramTypeString = param.Type.GetTypeString(method.Namespace.GetNamespaceName());
37
37
Original file line number Diff line number Diff line change @@ -500,11 +500,30 @@ public static List<OdcmMethod> WithDistinctOverloads(this OdcmMethod odcmMethod)
500
500
return methods . Distinct ( methodComparer ) . ToList ( ) ;
501
501
}
502
502
503
+ private static readonly OdcmParameterEqualityComparer paramComparer = new OdcmParameterEqualityComparer ( ) ;
504
+ /// <summary>
505
+ /// Deduplicates the parameter list for an overloaded method.
506
+ /// </summary>
507
+ /// <param name="odcmMethod">Method with potential overloads and duplicate parameters across overloads.</param>
508
+ /// <returns>A deduplicated list of OdcmParameter.</returns>
509
+ public static List < OdcmParameter > WithDistinctParameters ( this OdcmMethod odcmMethod )
510
+ {
511
+ var distinctMethods = odcmMethod . WithDistinctOverloads ( ) ;
512
+
513
+ var parameters = new List < OdcmParameter > ( ) ;
514
+
515
+ foreach ( var method in distinctMethods )
516
+ {
517
+ parameters . AddRange ( method . Parameters ) ;
518
+ }
519
+
520
+ return parameters . Distinct ( paramComparer ) . ToList ( ) ;
521
+ }
522
+
503
523
/// Returns a List containing the supplied class' methods plus their overloads
504
524
public static IEnumerable < OdcmMethod > MethodsAndOverloads ( this OdcmClass odcmClass )
505
525
{
506
526
return odcmClass . Methods . SelectMany ( x => x . WithOverloads ( ) ) ;
507
527
}
508
528
}
509
-
510
529
}
You can’t perform that action at this time.
0 commit comments