Skip to content

Commit 32fc646

Browse files
author
Caitlin Bales
committed
Merge remote-tracking branch 'refs/remotes/origin/master' into dev
2 parents 57a6b1b + 23e2276 commit 32fc646

File tree

98 files changed

+5989
-2868
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+5989
-2868
lines changed
Lines changed: 141 additions & 26 deletions
Large diffs are not rendered by default.

9-22-16-staging-v1_noannots.xml

Lines changed: 4046 additions & 0 deletions
Large diffs are not rendered by default.

GraphODataTemplateWriter.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
4-
VisualStudioVersion = 14.0.25123.0
4+
VisualStudioVersion = 14.0.25420.1
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{6ACF6CEE-A594-4DFE-9286-C7154E91738B}"
77
ProjectSection(SolutionItems) = preProject

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ Source code writers for [VIPR][vipr-source-repo] utilizing T4 templates. The Gra
77
Currently the following target languages are supported by this writer:
88
- Android
99
- CSharp
10-
- JavaScript
1110
- Objective-C
1211
- Python
12+
- TypeScript
1313

1414
# Contents
1515
- [Prerequisites](#prerequisites)
@@ -44,7 +44,7 @@ By default, output source code will be put in a folder named "output" next to th
4444
## Template Writer Settings
4545
### Available Languages
4646

47-
There are four languages to choose from at the moment. Java, ObjC, CSharp, and Python. Specify which language you want to generate in the `TargetLanguage` setting.
47+
There are five languages to choose from at the moment. Java, ObjC, CSharp, TypeScript and Python. Specify which language you want to generate in the `TargetLanguage` setting.
4848

4949
### Templates
5050
You must specify a template directory under the `TemplatesDirectory` Settings. The directory can be a full path or relative to the running directory. The directory must contain a sub directory for each platform you want to generate code for. See the Templates directory for an example.

Templates/Android/BaseModel.template.tt

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,10 @@
1313
<# } #>
1414
<#+
1515

16-
/// Is this request type a post?
17-
public bool IsPostRequestType(OdcmMethod method) {
18-
return method.IsAction()
19-
&& null != method.Parameters
20-
&& method.Parameters.Any();
21-
}
22-
2316
/// Choose an intermediate class type based on GETs/POSTs
2417
public string RequestBuilderSuperClass(OdcmObject currentType) {
25-
var isPostAction =
26-
IsPostRequestType(
27-
currentType.AsOdcmMethod()
28-
);
29-
30-
string superClass;
31-
32-
if (isPostAction) {
33-
superClass = "BasePostMethodRequestBuilder";
34-
} else {
35-
superClass = "BaseGetMethodRequestBuilder";
36-
}
37-
38-
return superClass;
18+
return currentType.AsOdcmMethod().IsFunction ?
19+
"BaseFunctionRequestBuilder" : "BaseActionRequestBuilder";
3920
}
4021

4122
/// <summary>
@@ -376,15 +357,37 @@
376357

377358
/// The Type of this param, as a string
378359
public string ParamType(OdcmParameter c) {
360+
var typeString = c.Type.GetTypeString();
379361
if (c.IsCollection){
380-
return String.Format("List<{0}>", c.Type.GetTypeString());
362+
typeString = String.Format("List<{0}>", c.Type.GetTypeString());
363+
} else if (typeString.Equals("Stream")) {
364+
365+
// Excel introduced the use of "Edm.Stream" types
366+
// normally this would be addressed at the TypeHelper level
367+
// but because streams will use different data containers
368+
// for outgoing vs. incoming streams I'm going to apply the type
369+
// here. Outbound Streams will use byte[]
370+
371+
typeString = "byte[]";
381372
}
382-
return c.Type.GetTypeString();
373+
return typeString;
383374
}
384375

385376
public string ReturnType(OdcmObject c) {
386-
if (c.AsOdcmMethod().ReturnType != null) {
387-
return c.AsOdcmMethod().ReturnType.Name.ToUpperFirstChar();
377+
var returnType = c.AsOdcmMethod().ReturnType;
378+
if (returnType != null) {
379+
var returnTypeString = returnType.GetTypeString();
380+
381+
// Excel introduced the use of "Edm.Stream" types
382+
// normally this would be addressed at the TypeHelper level
383+
// but because streams will use different data containers
384+
// for outgoing vs. incoming streams I'm going to apply the type
385+
// here. Inbound Streams will use java.io.InputStream
386+
387+
if (returnTypeString.Equals("Stream")) {
388+
returnTypeString = "java.io.InputStream";
389+
}
390+
return returnTypeString;
388391
}
389392
return "Void";
390393
}
@@ -619,14 +622,15 @@ public {1} {2}{3}{4} {{";
619622
* The {0}.
620623
*/
621624
@SerializedName(""{1}"")
622-
public {4}{2} {3};
625+
@Expose
626+
public {2} {3};
623627

624628
";
625629
var collectionFormat =
626630
@" /**
627631
* The {0}.
628632
*/
629-
public transient {4}{2} {3};
633+
public transient {2} {3};
630634

631635
";
632636

@@ -635,7 +639,6 @@ public {1} {2}{3}{4} {{";
635639
var propertyName = property.Name.ToUpperFirstChar();
636640
var propertyType = "";
637641
var propertyFormat = format;
638-
var shouldFullyQualify = TypeHelperAndroid.ReservedNames.Contains(propertyName);
639642
if (property.IsCollection)
640643
{
641644
if (!property.IsNavigation())
@@ -657,8 +660,7 @@ public {1} {2}{3}{4} {{";
657660
propertyName.SplitCamelCase(),
658661
property.Name,
659662
propertyType,
660-
property.SanitizePropertyName().ToLowerFirstChar(),
661-
shouldFullyQualify ? "com.microsoft.graph.extensions." : "");
663+
property.SanitizePropertyName().ToLowerFirstChar());
662664
}
663665
return sb.ToString();
664666
}
@@ -672,6 +674,7 @@ public {1} {2}{3}{4} {{";
672674
* The {0}.
673675
*/
674676
@SerializedName(""{1}"")
677+
@Expose
675678
public {2} {3};
676679

677680
";

Templates/Android/extensions/EntityCollectionReferenceRequestBuilder.java.tt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
*
1414
* @param requestUrl The request url
1515
* @param client The service client
16-
* @param options The options for this request
16+
* @param requestOptions The options for this request
1717
*/
18-
public <#=TypeCollectionReferenceRequestBuilder(c)#>(final String requestUrl, final <#=IBaseClientType()#> client, final List<Option> options) {
19-
super(requestUrl, client, options);
18+
public <#=TypeCollectionReferenceRequestBuilder(c)#>(final String requestUrl, final <#=IBaseClientType()#> client, final List<Option> requestOptions) {
19+
super(requestUrl, client, requestOptions);
2020
}
2121
}

Templates/Android/extensions/EntityCollectionRequest.java.tt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
*
1414
* @param requestUrl The request url
1515
* @param client The service client
16-
* @param options The options for this request
16+
* @param requestOptions The options for this request
1717
*/
18-
public <#=TypeCollectionRequest(c)#>(final String requestUrl, final <#=IBaseClientType()#> client, final List<Option> options) {
19-
super(requestUrl, client, options);
18+
public <#=TypeCollectionRequest(c)#>(final String requestUrl, final <#=IBaseClientType()#> client, final List<Option> requestOptions) {
19+
super(requestUrl, client, requestOptions);
2020
}
2121
}

Templates/Android/extensions/EntityCollectionRequestBuilder.java.tt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
*
1414
* @param requestUrl The request url
1515
* @param client The service client
16-
* @param options The options for this request
16+
* @param requestOptions The options for this request
1717
*/
18-
public <#=TypeCollectionRequestBuilder(c)#>(final String requestUrl, final <#=IBaseClientType()#> client, final List<Option> options) {
19-
super(requestUrl, client, options);
18+
public <#=TypeCollectionRequestBuilder(c)#>(final String requestUrl, final <#=IBaseClientType()#> client, final List<Option> requestOptions) {
19+
super(requestUrl, client, requestOptions);
2020
}
2121
}

Templates/Android/extensions/EntityCollectionWithReferencesRequest.java.tt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
*
1414
* @param requestUrl The request url
1515
* @param client The service client
16-
* @param options The options for this request
16+
* @param requestOptions The options for this request
1717
*/
18-
public <#=TypeCollectionWithReferencesRequest(c)#>(final String requestUrl, final <#=IBaseClientType()#> client, final List<Option> options) {
19-
super(requestUrl, client, options);
18+
public <#=TypeCollectionWithReferencesRequest(c)#>(final String requestUrl, final <#=IBaseClientType()#> client, final List<Option> requestOptions) {
19+
super(requestUrl, client, requestOptions);
2020
}
2121
}

Templates/Android/extensions/EntityCollectionWithReferencesRequestBuilder.java.tt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
*
1414
* @param requestUrl The request url
1515
* @param client The service client
16-
* @param options The options for this request
16+
* @param requestOptions The options for this request
1717
*/
18-
public <#=TypeCollectionWithReferencesRequestBuilder(c)#>(final String requestUrl, final <#=IBaseClientType()#> client, final List<Option> options) {
19-
super(requestUrl, client, options);
18+
public <#=TypeCollectionWithReferencesRequestBuilder(c)#>(final String requestUrl, final <#=IBaseClientType()#> client, final List<Option> requestOptions) {
19+
super(requestUrl, client, requestOptions);
2020
}
2121
}

0 commit comments

Comments
 (0)