Skip to content

Commit b223551

Browse files
author
Caitlin Bales (MSFT)
committed
Merge remote-tracking branch 'refs/remotes/origin/master' into cbales-working
# Conflicts: # Templates/CSharp/Model/ComplexType.cs.tt # Templates/CSharp/Model/EntityType.cs.tt # Templates/CSharp/Requests/IMethodRequest.cs.tt # Templates/CSharp/Requests/MethodRequest.cs.tt # src/GraphODataTemplateWriter/CodeHelpers/CSharp/TypeHelperCSharp.cs
2 parents 9c3cee4 + 50a8137 commit b223551

17 files changed

+280
-27
lines changed

Templates/Android/generated/BaseEntityCollectionRequestBuilder.java.tt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ if (currentTypeProjection != null) {
5151
public <#=ITypeCollectionRequestBuilder(method)#> get<#=MethodName(method)#>(<#=parameterList#>) {
5252
return new <#=TypeCollectionRequestBuilder(method)#>(getRequestUrlWithAdditionalSegment("<#=MethodFullName(method)#>"), getClient(), null<#=MethodParametersValues(method)#>);
5353
}
54+
<#
55+
// Add a method to support delta query by string (opaque deltaLink)
56+
if (MethodName(method) == "Delta") {
57+
#>
58+
59+
public <#=ITypeCollectionRequestBuilder(method)#> get<#=MethodName(method)#>(final String deltaLink) {
60+
return new <#=TypeCollectionRequestBuilder(method)#>(deltaLink, getClient(), null<#=MethodParametersValues(method)#>);
61+
}
62+
<# } #>
5463
<#
5564
} else {
5665
#>

Templates/Android/generated/BaseMethodCollectionPage.java.tt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,33 @@
55
<#host.TemplateName = BaseTypeCollectionPage(c);#>
66
<#=writer.WriteHeader()#>
77
<#=CreatePackageDef(host)#>
8+
<#
9+
/**
10+
* Manual check for deltaLink
11+
* This allows for a user to get the delta link URL with which
12+
* to make future delta query calls to the service. Since it is
13+
* not surfaced in the additionalDataManager, we add it manually
14+
* to the object for easy access.
15+
*/
16+
var deltaPage = false;
17+
if (c.Name == "delta") {
18+
deltaPage = true;
19+
}
20+
#>
821

922
import com.google.gson.JsonObject;
1023
import com.google.gson.annotations.*;
1124

1225
<#=CreateClassDef(BaseTypeCollectionPage(c), "BaseCollectionPage" + CollectionPageGeneric(c), IBaseTypeCollectionPage(c))#>
1326

27+
<# if (deltaPage) { #>
28+
/**
29+
* The opaque link to query delta after the
30+
* initial request
31+
*/
32+
public String deltaLink;
33+
34+
<# } #>
1435
/**
1536
* A collection page for <#=TypeName(c)#>.
1637
*
@@ -19,5 +40,23 @@ import com.google.gson.annotations.*;
1940
*/
2041
public <#=BaseTypeCollectionPage(c)#>(final <#=BaseTypeCollectionResponse(c)#> response, final <#=ITypeCollectionRequestBuilder(c)#> builder) {
2142
super(response.value, builder);
43+
<# if (deltaPage) { #>
44+
45+
if (response.getRawObject().get("@odata.deltaLink") != null) {
46+
deltaLink = response.getRawObject().get("@odata.deltaLink").getAsString();
47+
} else {
48+
deltaLink = null;
49+
}
50+
<# } #>
51+
}
52+
<# if (deltaPage) { #>
53+
/**
54+
* The deltaLink to make future delta requests
55+
*
56+
* @return String The deltaLink URL
57+
*/
58+
public String getDeltaLink() {
59+
return deltaLink;
2260
}
61+
<# } #>
2362
}

Templates/Android/generated/IBaseEntityCollectionRequestBuilder.java.tt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ if (currentTypeProjection != null)
3636
#>
3737

3838
<#=ITypeCollectionRequestBuilder(method)#> get<#=MethodName(method)#>(<#=parameterList#>);
39+
<#
40+
// Add a method to support delta query by string (opaque deltaLink)
41+
if (MethodName(method) == "Delta") {
42+
#>
43+
44+
<#=ITypeCollectionRequestBuilder(method)#> get<#=MethodName(method)#>(final String deltaLink);
45+
<# } #>
3946
<# } else { #>
4047
<#=ITypeRequestBuilder(method)#> get<#=MethodName(method)#>(<#=parameterList#>);
4148
<#

Templates/Android/generated/IBaseMethodCollectionPage.java.tt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,29 @@
55
<#host.TemplateName = IBaseTypeCollectionPage(c);#>
66
<#=writer.WriteHeader()#>
77
<#=CreatePackageDef(host)#>
8+
<#
9+
/**
10+
* Manual check for deltaLink
11+
* This allows for a user to get the delta link URL with which
12+
* to make future delta query calls to the service. Since it is
13+
* not surfaced in the additionalDataManager, we add it manually
14+
* to the object for easy access.
15+
*/
16+
var deltaPage = false;
17+
if (c.Name == "delta") {
18+
deltaPage = true;
19+
}
20+
#>
821

922
import com.google.gson.JsonObject;
1023

1124
<#=CreateInterfaceDef(IBaseTypeCollectionPage(c), "IBaseCollectionPage" + CollectionPageGeneric(c))#>
25+
<# if (deltaPage) { #>
26+
/**
27+
* The deltaLink to make future delta requests
28+
*
29+
* @return String The deltaLink URL
30+
*/
31+
public String getDeltaLink();
32+
<# } #>
1233
}

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

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,16 @@ public string GetEntityCreateAsyncMethod(OdcmClass odcmClass)
197197

198198
var templateWriterHost = (CustomT4Host)Host;
199199
var templateWriter = (CodeWriterCSharp)templateWriterHost.CodeWriter;
200+
200201
var entityName = this.GetEntityNameString(odcmClass);
201-
var lowerCaseEntityName = entityName.ToLowerFirstChar();
202+
203+
// Special case for when an entity name ends with "Request". Associated with the change in EntityType.cs.tt
204+
if (entityName.EndsWith("Request"))
205+
{
206+
entityName = String.Concat(entityName, "Object");
207+
}
208+
209+
var lowerCaseEntityName = entityName.ToLowerFirstChar();
202210

203211
this.AppendCreateAsyncHeader(entityName, lowerCaseEntityName, stringBuilder, false);
204212
stringBuilder.Append(Environment.NewLine);
@@ -235,6 +243,13 @@ public string GetEntityCreateAsyncMethod(OdcmClass odcmClass)
235243

236244
public void AppendGetAsyncHeader(string entityName, StringBuilder stringBuilder, bool includeSendParams)
237245
{
246+
247+
// Special case for when an entity name ends with "Request". Associated with the change in EntityType.cs.tt
248+
if (entityName.EndsWith("Request"))
249+
{
250+
entityName = String.Concat(entityName, "Object");
251+
}
252+
238253
if (includeSendParams)
239254
{
240255
stringBuilder.AppendFormat(" ");
@@ -263,6 +278,12 @@ public string GetEntityGetAsyncMethod(OdcmClass odcmClass, bool initializeCollec
263278

264279
var entityName = this.GetEntityNameString(odcmClass);
265280

281+
// Special case for when an entity name ends with "Request". Associated with the change in EntityType.cs.tt
282+
if (entityName.EndsWith("Request"))
283+
{
284+
entityName = String.Concat(entityName, "Object");
285+
}
286+
266287
this.AppendGetAsyncHeader(entityName, stringBuilder, false);
267288
stringBuilder.Append(Environment.NewLine);
268289
stringBuilder.AppendFormat(" public System.Threading.Tasks.Task<{0}> GetAsync()", entityName);
@@ -297,6 +318,12 @@ public string GetEntityGetAsyncMethod(OdcmClass odcmClass, bool initializeCollec
297318

298319
public void AppendUpdateAsyncHeader(string entityName, string lowerCaseEntityName, StringBuilder stringBuilder, bool includeSendParams)
299320
{
321+
// Special case for when an entity name ends with "Request". Associated with the change in EntityType.cs.tt
322+
if (entityName.EndsWith("Request"))
323+
{
324+
entityName = String.Concat(entityName, "Object");
325+
}
326+
300327
if (includeSendParams)
301328
{
302329
stringBuilder.AppendFormat(" ");
@@ -325,6 +352,13 @@ public string GetEntityUpdateAsyncMethod(OdcmClass odcmClass)
325352
var stringBuilder = new StringBuilder();
326353

327354
var entityName = this.GetEntityNameString(odcmClass);
355+
356+
// Special case for when an entity name ends with "Request". Associated with the change in EntityType.cs.tt
357+
if (entityName.EndsWith("Request"))
358+
{
359+
entityName = String.Concat(entityName, "Object");
360+
}
361+
328362
var lowerCaseEntityName = entityName.ToLowerFirstChar();
329363

330364
var templateWriterHost = (CustomT4Host)Host;
@@ -395,6 +429,13 @@ public string GetSelectMethod(string requestType)
395429

396430
public string GetSelectExpressionMethod(string requestType, string underlyingType)
397431
{
432+
433+
// Special case for when an entity name ends with "Request". Associated with the change in EntityType.cs.tt
434+
if (underlyingType.EndsWith("Request"))
435+
{
436+
underlyingType = String.Concat(underlyingType, "Object");
437+
}
438+
398439
var stringBuilder = new StringBuilder();
399440

400441
stringBuilder.Append(
@@ -429,6 +470,13 @@ public string GetSelectExpressionMethod(string requestType, string underlyingTyp
429470

430471
public string GetExpandExpressionMethod(string requestType, string underlyingType)
431472
{
473+
474+
// Special case for when an entity name ends with "Request". Associated with the change in EntityType.cs.tt
475+
if (underlyingType.EndsWith("Request"))
476+
{
477+
underlyingType = String.Concat(underlyingType, "Object");
478+
}
479+
432480
var stringBuilder = new StringBuilder();
433481

434482
stringBuilder.Append(

Templates/CSharp/Base/IEntityRequest.Base.template.tt

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ public string GetEntityRequestInterfaceDefinition(OdcmClass odcmClass)
4040
// -------------------------------------------------------------
4141
public void AppendEntityCreateAsyncMethodHeader(string entityName, string lowerCaseEntityName, StringBuilder stringBuilder, bool includeSendParams)
4242
{
43+
// Special case for when an entity name ends with "Request". Associated with the change in EntityType.cs.tt
44+
if (entityName.EndsWith("Request"))
45+
{
46+
entityName = String.Concat(entityName, "Object");
47+
}
48+
4349
if (includeSendParams)
4450
{
4551
stringBuilder.Append(" ");
@@ -68,6 +74,13 @@ public string GetEntityCreateAsyncMethod(OdcmClass odcmClass)
6874
var stringBuilder = new StringBuilder();
6975

7076
var entityName = this.GetEntityNameString(odcmClass);
77+
78+
// Special case for when an entity name ends with "Request". Associated with the change in EntityType.cs.tt
79+
if (entityName.EndsWith("Request"))
80+
{
81+
entityName = String.Concat(entityName, "Object");
82+
}
83+
7184
var lowerCaseEntityName = entityName.ToLowerFirstChar();
7285

7386
this.AppendEntityCreateAsyncMethodHeader(entityName, lowerCaseEntityName, stringBuilder, false);
@@ -83,6 +96,12 @@ public string GetEntityCreateAsyncMethod(OdcmClass odcmClass)
8396

8497
public void AppendDeleteAsyncMethodHeader(string deleteTargetString, StringBuilder stringBuilder, bool includeSendParams)
8598
{
99+
// Special case for when an entity name ends with "Request". Associated with the change in EntityType.cs.tt
100+
if (deleteTargetString.EndsWith("Request"))
101+
{
102+
deleteTargetString = String.Concat(deleteTargetString, "Object");
103+
}
104+
86105
if (includeSendParams)
87106
{
88107
stringBuilder.Append(" ");
@@ -106,6 +125,12 @@ public void AppendDeleteAsyncMethodHeader(string deleteTargetString, StringBuild
106125

107126
public string GetDeleteAsyncMethod(string deleteTargetString)
108127
{
128+
// Special case for when an entity name ends with "Request". Associated with the change in EntityType.cs.tt
129+
if (deleteTargetString.EndsWith("Request"))
130+
{
131+
deleteTargetString = String.Concat(deleteTargetString, "Object");
132+
}
133+
109134
var stringBuilder = new StringBuilder();
110135

111136
this.AppendDeleteAsyncMethodHeader(deleteTargetString, stringBuilder, false);
@@ -170,6 +195,12 @@ public string GetEntityDeleteAsyncMethod(OdcmClass odcmClass)
170195

171196
public void AppendGetAsyncMethodHeader(string entityName, StringBuilder stringBuilder, bool includeSendParams)
172197
{
198+
// Special case for when an entity name ends with "Request". Associated with the change in EntityType.cs.tt
199+
if (entityName.EndsWith("Request"))
200+
{
201+
entityName = String.Concat(entityName, "Object");
202+
}
203+
173204
if (includeSendParams)
174205
{
175206
stringBuilder.Append(" ");
@@ -197,6 +228,12 @@ public string GetEntityGetAsyncMethod(OdcmClass odcmClass)
197228

198229
var entityName = this.GetEntityNameString(odcmClass);
199230

231+
// Special case for when an entity name ends with "Request". Associated with the change in EntityType.cs.tt
232+
if (entityName.EndsWith("Request"))
233+
{
234+
entityName = String.Concat(entityName, "Object");
235+
}
236+
200237
this.AppendGetAsyncMethodHeader(entityName, stringBuilder, false);
201238
stringBuilder.Append(Environment.NewLine);
202239
stringBuilder.AppendFormat(" System.Threading.Tasks.Task<{0}> GetAsync();", entityName);
@@ -213,6 +250,12 @@ public string GetEntityGetAsyncMethod(OdcmClass odcmClass)
213250

214251
public void AppendUpdateAsyncMethodHeader(string entityName, string lowerCaseEntityName, StringBuilder stringBuilder, bool includeSendParams)
215252
{
253+
// Special case for when an entity name ends with "Request". Associated with the change in EntityType.cs.tt
254+
if (entityName.EndsWith("Request"))
255+
{
256+
entityName = String.Concat(entityName, "Object");
257+
}
258+
216259
if (includeSendParams)
217260
{
218261
stringBuilder.Append(" ");
@@ -241,6 +284,13 @@ public string GetEntityUpdateAsyncMethod(OdcmClass odcmClass)
241284
var stringBuilder = new StringBuilder();
242285

243286
var entityName = this.GetEntityNameString(odcmClass);
287+
288+
// Special case for when an entity name ends with "Request". Associated with the change in EntityType.cs.tt
289+
if (entityName.EndsWith("Request"))
290+
{
291+
entityName = String.Concat(entityName, "Object");
292+
}
293+
244294
var lowerCaseEntityName = entityName.ToLowerFirstChar();
245295

246296
this.AppendUpdateAsyncMethodHeader(entityName, lowerCaseEntityName, stringBuilder, false);
@@ -264,6 +314,13 @@ public string GetEntityUpdateAsyncMethod(OdcmClass odcmClass)
264314

265315
public string GetExpandExpressionMethod(string requestType, string underlyingType)
266316
{
317+
318+
// Special case for when an entity name ends with "Request". Associated with the change in EntityType.cs.tt
319+
if (underlyingType.EndsWith("Request"))
320+
{
321+
underlyingType = String.Concat(underlyingType, "Object");
322+
}
323+
267324
var stringBuilder = new StringBuilder();
268325

269326
stringBuilder.Append(
@@ -296,6 +353,13 @@ public string GetExpandMethod(string entityRequest)
296353

297354
public string GetSelectExpressionMethod(string requestType, string underlyingType)
298355
{
356+
357+
// Special case for when an entity name ends with "Request". Associated with the change in EntityType.cs.tt
358+
if (underlyingType.EndsWith("Request"))
359+
{
360+
underlyingType = String.Concat(underlyingType, "Object");
361+
}
362+
299363
var stringBuilder = new StringBuilder();
300364

301365
stringBuilder.Append(

Templates/CSharp/Model/ComplexType.cs.tt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ namespace <#=complex.Namespace.GetNamespaceName()#>
4949
var propertyType = property.IsCollection ? string.Format("IEnumerable<{0}>", property.GetTypeString()) : property.GetTypeString();
5050
var propertyName = isMethodResponse
5151
? property.Name.Substring(property.Name.IndexOf('.') + 1).ToCheckedCase()
52-
: property.Name.ToCheckedCase().GetSanitizedPropertyName(null, true);
52+
: property.Name.ToCheckedCase().GetSanitizedPropertyName(property);
5353

54-
var attributeDefinition = string.Format("[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = \"{0}\", Required = Required.Default)]", property.Name);
54+
var attributeDefinition = string.Format("[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = \"{0}\", Required = Newtonsoft.Json.Required.Default)]", property.Name);
5555

5656
if (property.IsTypeNullable() || property.IsCollection)
5757
{

0 commit comments

Comments
 (0)