Skip to content

Commit 9ce28bc

Browse files
committed
EntityClient and EntityCollectionPage fixes
1 parent 7ed2489 commit 9ce28bc

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

Templates/CSharp/Requests/EntityClient.cs.tt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,14 @@ namespace <#=@namespace#>
7979
}
8080
else
8181
{
82-
var requestBuilder = prop.Projection.Type.Name.ToCheckedCase() + "RequestBuilder";
82+
var requestBuilder = prop.GetTypeString(@namespace, "{0}RequestBuilder");
83+
var iRequestBuilder = prop.GetTypeString(@namespace, "I{0}RequestBuilder");
8384
#>
8485

8586
/// <summary>
8687
/// Gets the <#=propName#> request builder.
8788
/// </summary>
88-
public I<#=requestBuilder#> <#=sanitizedPropName#>
89+
public <#=iRequestBuilder#> <#=sanitizedPropName#>
8990
{
9091
get
9192
{

Templates/CSharp/Requests/EntityCollectionPage.cs.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace <#=@namespace#>
3232
/// <summary>
3333
/// Initializes the NextPageRequest property.
3434
/// </summary>
35-
public void InitializeNextPageRequest(IBaseClient client, string nextPageLinkString)
35+
public void InitializeNextPageRequest(<#[email protected]("IBaseClient")#> client, string nextPageLinkString)
3636
{
3737
if (!string.IsNullOrEmpty(nextPageLinkString))
3838
{

src/GraphODataTemplateWriter/CodeHelpers/CSharp/TypeHelperCSharp.cs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,17 @@ public static string GetTypeString(this OdcmProperty property)
162162
return GetTypeString(property.Projection.Type);
163163
}
164164

165-
public static string GetTypeString(this OdcmType type, string namespaceContext)
165+
public static string GetTypeString(this OdcmType type, string namespaceContext, string format = null)
166166
{
167167
var typesNamespace = type.Namespace.GetNamespaceName().Replace("edm.", "");
168168
var plainTypeString = type.GetTypeString();
169+
if (format != null)
170+
{
171+
plainTypeString = string.Format(format, plainTypeString);
172+
}
173+
169174
if (string.Equals(typesNamespace, namespaceContext, StringComparison.OrdinalIgnoreCase)
170-
|| typesNamespace == "Edm")
175+
|| typesNamespace == "Edm")
171176
{
172177
return plainTypeString;
173178
}
@@ -177,9 +182,9 @@ public static string GetTypeString(this OdcmType type, string namespaceContext)
177182
}
178183
}
179184

180-
public static string GetTypeString(this OdcmProperty property, string namespaceContext)
185+
public static string GetTypeString(this OdcmProperty property, string namespaceContext, string format = null)
181186
{
182-
return property.Projection.Type.GetTypeString(namespaceContext);
187+
return property.Projection.Type.GetTypeString(namespaceContext, format);
183188
}
184189

185190
public static bool IsTypeNullable(this OdcmProperty property)
@@ -337,5 +342,17 @@ public static string GetToLowerImport(this OdcmProperty property)
337342
var index = type.Name.LastIndexOf('.');
338343
return type.Name.Substring(0, index).ToLower() + type.Name.Substring(index);
339344
}
345+
346+
public static string GetMiddlewareTypeName(this string namespaceContext, string typeName)
347+
{
348+
if (namespaceContext == "Microsoft.Graph")
349+
{
350+
return typeName;
351+
}
352+
else
353+
{
354+
return $"Microsoft.Graph.{typeName}";
355+
}
356+
}
340357
}
341358
}

0 commit comments

Comments
 (0)