Skip to content

Commit b84dc66

Browse files
committed
fix middleware type names in request and request builder constructors
1 parent 9ce28bc commit b84dc66

File tree

7 files changed

+40
-21
lines changed

7 files changed

+40
-21
lines changed

Templates/CSharp/Base/CollectionRequest.Base.template.tt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public string GetCollectionClassDefinition(OdcmProperty odcmProperty)
1313

1414
public string GetCollectionRequestConstructor(OdcmProperty odcmProperty)
1515
{
16-
return this.GetConstructor(this.GetPropertyCollectionRequestName(odcmProperty));
16+
return this.GetConstructor(this.GetPropertyCollectionRequestName(odcmProperty), odcmProperty.Class.AsOdcmClass().GetNamespaceName());
1717
}
1818

1919

@@ -27,7 +27,7 @@ public string GetCollectionReferencesClassDefinition(OdcmProperty odcmProperty)
2727

2828
public string GetCollectionReferencesRequestConstructor(OdcmProperty odcmProperty)
2929
{
30-
return this.GetConstructor(this.GetPropertyCollectionReferencesRequestName(odcmProperty));
30+
return this.GetConstructor(this.GetPropertyCollectionReferencesRequestName(odcmProperty), odcmProperty.Class.AsOdcmClass().GetNamespaceName());
3131
}
3232

3333

@@ -41,7 +41,7 @@ public string GetCollectionWithReferencesClassDefinition(OdcmProperty odcmProper
4141

4242
public string GetCollectionWithReferencesRequestConstructor(OdcmProperty odcmProperty)
4343
{
44-
return this.GetConstructor(this.GetPropertyCollectionWithReferencesRequestName(odcmProperty));
44+
return this.GetConstructor(this.GetPropertyCollectionWithReferencesRequestName(odcmProperty), odcmProperty.Class.AsOdcmClass().GetNamespaceName());
4545
}
4646

4747

Templates/CSharp/Base/CollectionRequestBuilder.Base.template.tt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public string GetCollectionClassDefinition(OdcmProperty odcmProperty)
1313

1414
public string GetCollectionRequestBuilderConstructor(OdcmProperty odcmProperty)
1515
{
16-
return this.GetConstructor(this.GetPropertyCollectionRequestBuilderName(odcmProperty));
16+
return this.GetConstructor(this.GetPropertyCollectionRequestBuilderName(odcmProperty), odcmProperty.Class.AsOdcmClass().GetNamespaceName());
1717
}
1818

1919
public string GetCollectionRequestMethod(OdcmProperty odcmProperty)
@@ -37,7 +37,7 @@ public string GetCollectionReferencesClassDefinition(OdcmProperty odcmProperty)
3737

3838
public string GetCollectionReferencesRequestBuilderConstructor(OdcmProperty odcmProperty)
3939
{
40-
return this.GetConstructor(this.GetPropertyCollectionReferencesRequestBuilderName(odcmProperty));
40+
return this.GetConstructor(this.GetPropertyCollectionReferencesRequestBuilderName(odcmProperty), odcmProperty.Class.AsOdcmClass().GetNamespaceName());
4141
}
4242

4343
public string GetCollectionReferencesRequestMethod(OdcmProperty odcmProperty)
@@ -61,7 +61,7 @@ public string GetCollectionWithReferencesClassDefinition(OdcmProperty odcmProper
6161

6262
public string GetCollectionWithReferencesRequestBuilderConstructor(OdcmProperty odcmProperty)
6363
{
64-
return this.GetConstructor(this.GetPropertyCollectionWithReferencesRequestBuilderName(odcmProperty));
64+
return this.GetConstructor(this.GetPropertyCollectionWithReferencesRequestBuilderName(odcmProperty), odcmProperty.Class.AsOdcmClass().GetNamespaceName());
6565
}
6666

6767
public string GetCollectionWithReferencesRequestMethod(OdcmProperty odcmProperty)

Templates/CSharp/Base/EntityRequest.Base.template.tt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ public string GetEntityWithReferenceRequestClassDefinition(OdcmClass odcmClass)
1818

1919
public string GetEntityReferenceRequestConstructor(OdcmClass odcmClass)
2020
{
21-
return this.GetConstructor(this.GetEntityReferenceRequestName(odcmClass));
21+
return this.GetConstructor(this.GetEntityReferenceRequestName(odcmClass), odcmClass.GetNamespaceName());
2222
}
2323

2424
public string GetEntityWithReferenceRequestConstructor(OdcmClass odcmClass)
2525
{
26-
return this.GetConstructor(this.GetEntityWithReferenceRequestName(odcmClass));
26+
return this.GetConstructor(this.GetEntityWithReferenceRequestName(odcmClass), odcmClass.GetNamespaceName());
2727
}
2828

2929
// -------------------------------------------------------------
@@ -36,7 +36,7 @@ public string GetEntityRequestClassDefinition(OdcmClass odcmClass)
3636

3737
public string GetEntityRequestConstructor(OdcmClass odcmClass)
3838
{
39-
return this.GetConstructor(this.GetEntityRequestName(odcmClass));
39+
return this.GetConstructor(this.GetEntityRequestName(odcmClass), odcmClass.GetNamespaceName());
4040
}
4141

4242

Templates/CSharp/Base/EntityRequestBuilder.Base.template.tt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public string GetEntityRequestBuilderClassDefinition(OdcmClass odcmClass)
1313

1414
public string GetEntityRequestBuilderConstructor(OdcmClass odcmClass)
1515
{
16-
return this.GetConstructor(this.GetEntityRequestBuilderName(odcmClass));
16+
return this.GetConstructor(this.GetEntityRequestBuilderName(odcmClass), odcmClass.GetNamespaceName());
1717
}
1818

1919
public string GetEntityRequestMethod(OdcmClass odcmClass)
@@ -37,7 +37,7 @@ public string GetEntityReferenceRequestBuilderClassDefinition(OdcmClass odcmClas
3737

3838
public string GetEntityReferenceRequestBuilderConstructor(OdcmClass odcmClass)
3939
{
40-
return this.GetConstructor(this.GetEntityReferenceRequestBuilderName(odcmClass));
40+
return this.GetConstructor(this.GetEntityReferenceRequestBuilderName(odcmClass), odcmClass.GetNamespaceName());
4141
}
4242

4343
public string GetEntityReferenceRequestMethod(OdcmClass odcmClass)
@@ -90,7 +90,7 @@ public string GetEntityWithReferenceRequestBuilderClassDefinition(OdcmClass odcm
9090

9191
public string GetEntityWithReferenceRequestBuilderConstructor(OdcmClass odcmClass)
9292
{
93-
return this.GetConstructor(this.GetEntityWithReferenceRequestBuilderName(odcmClass));
93+
return this.GetConstructor(this.GetEntityWithReferenceRequestBuilderName(odcmClass), odcmClass.GetNamespaceName());
9494
}
9595

9696
public string GetEntityWithReferenceRequestMethod(OdcmClass odcmClass)

Templates/CSharp/Base/Request.Base.template.tt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ public string GetClassDefinition(string className)
1818
return stringBuilder.ToString();
1919
}
2020

21-
public string GetConstructor(string instanceTypeName)
21+
public string GetConstructor(string instanceTypeName, string @namespace)
2222
{
23+
var iBaseClientTypeName = @namespace.GetMiddlewareTypeName("IBaseClient");
24+
var optionTypeName = @namespace.GetMiddlewareTypeName("Option");
25+
2326
var stringBuilder = new StringBuilder();
2427

2528
stringBuilder.Append("/// <summary>");
@@ -29,16 +32,22 @@ public string GetConstructor(string instanceTypeName)
2932
stringBuilder.Append(
3033
@" /// </summary>
3134
/// <param name=""requestUrl"">The URL for the built request.</param>
32-
/// <param name=""client"">The <see cref=""IBaseClient""/> for handling requests.</param>
35+
/// <param name=""client"">The <see cref=""");
36+
stringBuilder.Append(iBaseClientTypeName);
37+
stringBuilder.Append(@"""/> for handling requests.</param>
3338
/// <param name=""options"">Query and header option name value pairs for the request.</param>");
3439

3540
stringBuilder.Append(Environment.NewLine);
3641
stringBuilder.AppendFormat(" public {0}(", instanceTypeName);
3742
stringBuilder.Append(Environment.NewLine);
3843
stringBuilder.Append(
3944
@" string requestUrl,
40-
IBaseClient client,
41-
IEnumerable<Option> options)
45+
");
46+
stringBuilder.Append(iBaseClientTypeName);
47+
stringBuilder.Append(@" client,
48+
IEnumerable<");
49+
stringBuilder.Append(optionTypeName);
50+
stringBuilder.Append(@"> options)
4251
: base(requestUrl, client, options)
4352
{
4453
}");

Templates/CSharp/Base/RequestBuilder.Base.template.tt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ public string GetEntityClassDefinition(OdcmClass entity)
4545
return stringBuilder.ToString();
4646
}
4747

48-
public string GetConstructor(string instanceTypeName)
48+
public string GetConstructor(string instanceTypeName, string @namespace)
4949
{
50+
var iBaseClientTypeName = @namespace.GetMiddlewareTypeName("IBaseClient");
51+
5052
var stringBuilder = new StringBuilder();
5153

5254
stringBuilder.Append("/// <summary>");
@@ -56,14 +58,17 @@ public string GetConstructor(string instanceTypeName)
5658
stringBuilder.Append(
5759
@" /// </summary>
5860
/// <param name=""requestUrl"">The URL for the built request.</param>
59-
/// <param name=""client"">The <see cref=""IBaseClient""/> for handling requests.</param>");
61+
/// <param name=""client"">The <see cref=""");
62+
stringBuilder.Append(iBaseClientTypeName);
63+
stringBuilder.Append(@"""/> for handling requests.</param>");
6064

6165
stringBuilder.Append(Environment.NewLine);
6266
stringBuilder.AppendFormat(" public {0}(", instanceTypeName);
6367
stringBuilder.Append(Environment.NewLine);
64-
stringBuilder.Append(
65-
@" string requestUrl,
66-
IBaseClient client)
68+
stringBuilder.Append(@" string requestUrl,
69+
");
70+
stringBuilder.Append(iBaseClientTypeName);
71+
stringBuilder.Append(@" client)
6772
: base(requestUrl, client)
6873
{
6974
}");

src/GraphODataTemplateWriter/CodeHelpers/CSharp/TypeHelperCSharp.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ public static string GetNamespaceName(this OdcmProperty property)
197197
return property.Projection.Type.Namespace.GetNamespaceName();
198198
}
199199

200+
public static string GetNamespaceName(this OdcmClass odcmClass)
201+
{
202+
return odcmClass.Namespace.GetNamespaceName();
203+
}
204+
200205
public static bool IsTypeNullable(this OdcmType type)
201206
{
202207
var t = type.GetTypeString();

0 commit comments

Comments
 (0)