Skip to content

Commit a62511a

Browse files
Merge pull request #109 from microsoftgraph/dev_updateMethodRequest
Dev update method request
2 parents 12664fc + 341bcb7 commit a62511a

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

Templates/CSharp/Model/MethodRequestBody.cs.tt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ var method = host.CurrentType.AsOdcmMethod();
77
var entityName = method.Class.Name.ToCheckedCase();
88
var requestBody = entityName + method.Name.Substring(method.Name.IndexOf('.') + 1).ToCheckedCase() + "RequestBody";
99

10-
// These types of request bodies are only used for OData actions, which when containing parameters,
11-
// will always result in POST calls. The OData spec is explicit in saying that overload methods bound
12-
// to other types are explicitly not allowed. Therefore, any overload methods found here are invalid
13-
// and violate the spec.
14-
System.Diagnostics.Debug.Assert(!method.Overloads.Any(), "Overload actions are not allowed in OData services");
10+
// Commenting this out as 12.1.1.1, Action Overload Rules, states "Bound actions support overloading (multiple
11+
// actions having the same name within the same namespace) by binding parameter type. The combination of action
12+
// name and the binding parameter type MUST be unique within a namespace."
13+
// System.Diagnostics.Debug.Assert(!method.Overloads.Any(), "Overload actions are not allowed in OData services");
1514

1615
var attributeStringBuilder = new StringBuilder();
1716
attributeStringBuilder.Append("[JsonObject(MemberSerialization = MemberSerialization.OptIn)]");

Templates/CSharp/Requests/MethodRequest.cs.tt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ namespace <#=method.Namespace.GetNamespaceName()#>
298298
/// </summary>
299299
/// <param name="<#=returnEntityParameter#>">The <#=returnEntityType#> object set with the properties to update.</param>
300300
/// <returns>The task to await for async call.</returns>
301-
public <#=methodReturnType#> PatchAsync(<#=returnEntityType#> <#=returnEntityParameter#>)
301+
public <#=methodOverloadReturnType#> PatchAsync(<#=returnEntityType#> <#=returnEntityParameter#>)
302302
{
303303
return this.PatchAsync(<#=returnEntityParameter#>, CancellationToken.None);
304304
}
@@ -399,7 +399,7 @@ namespace <#=method.Namespace.GetNamespaceName()#>
399399
/// </summary>
400400
/// <param name="<#=returnEntityParameter#>">The <#=returnEntityType#> object to update.</param>
401401
/// <returns>The task to await for async call.</returns>
402-
public <#=methodReturnType#> PutAsync(<#=returnEntityType#> <#=returnEntityParameter#>)
402+
public <#=methodOverloadReturnType#> PutAsync(<#=returnEntityType#> <#=returnEntityParameter#>)
403403
{
404404
return this.PutAsync(<#=returnEntityParameter#>, CancellationToken.None);
405405
}

Templates/CSharp/Requests/MethodRequestBuilder.cs.tt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,16 @@ var methodType = method.IsFunction ? "Function" : "Action";
1414

1515
var overloads = new List<OdcmMethod>();
1616
overloads.Add(method);
17-
overloads.AddRange(method.Overloads);
17+
18+
// So far, it appears that the overloads on the functions are working as expected.
19+
// The overloads on actions should be skipped. If we see more issues here, we may need to
20+
// revisit how VIPR determines overloaded methods.
21+
if (method.IsFunction)
22+
{
23+
overloads.AddRange(method.Overloads);
24+
}
25+
26+
1827

1928
var methods = overloads
2029
.Select(m =>
@@ -66,7 +75,9 @@ namespace <#=method.Namespace.GetNamespaceName()#>
6675
{
6776
<#
6877
foreach (var m in methods)
78+
6979
{
80+
7081
#>
7182
/// <summary>
7283
/// Constructs a new <see cref="<#=requestBuilderType#>"/>.

0 commit comments

Comments
 (0)