Skip to content

Commit f50c9e6

Browse files
author
Caitlin Bales (MSFT)
authored
Merge branch 'master' into cbales-working
2 parents 2a3bcf8 + fd9b29b commit f50c9e6

File tree

15 files changed

+3127
-12
lines changed

15 files changed

+3127
-12
lines changed

src/GraphODataTemplateWriter/.config/TemplateWriterSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"AvailableLanguages": [ "Android", "ObjC", "CSharp", "PHP", "Python", "TypeScript", "GraphEndpointList" ],
33
"TargetLanguage": "CSharp",
44
"Plugins": [ ],

src/GraphODataTemplateWriter/CodeHelpers/Android/TypeHelperAndroid.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ namespace Microsoft.Graph.ODataTemplateWriter.CodeHelpers.Android
66
using Microsoft.Graph.ODataTemplateWriter.Extensions;
77
using Vipr.Core.CodeModel;
88
using System;
9+
using NLog;
910

1011
public static class TypeHelperAndroid
1112
{
13+
private static Logger logger = LogManager.GetCurrentClassLogger();
1214
public const string ReservedPrefix = "msgraph_";
1315
public static HashSet<string> ReservedNames
1416
{
@@ -95,6 +97,7 @@ public static string SanitizePropertyName(this string property, OdcmObject odcmP
9597
{
9698
if (ReservedNames.Contains(property))
9799
{
100+
logger.Info("Property \"{0}\" is a reserved word in Android. Converting to \"{1}{0}\"", property, ReservedPrefix);
98101
return ReservedPrefix + property;
99102
}
100103

@@ -104,6 +107,7 @@ public static string SanitizePropertyName(this string property, OdcmObject odcmP
104107
if (odcmProperty.Projection.Type.Name.ToUpperFirstChar() == odcmProperty.Name.ToUpperFirstChar())
105108
{
106109
// Name the property: {metadataName} + "Property"
110+
logger.Info("Property type \"{0}\" has the same name as the class. Converting to \"{0}Property\"", property);
107111
return string.Concat(property, "Property");
108112
}
109113

src/GraphODataTemplateWriter/CodeHelpers/CSharp/TypeHelperCSharp.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ namespace Microsoft.Graph.ODataTemplateWriter.CodeHelpers.CSharp
66
using System.Collections.Generic;
77
using Microsoft.Graph.ODataTemplateWriter.Extensions;
88
using Vipr.Core.CodeModel;
9+
using NLog;
910

1011
public static class TypeHelperCSharp
1112
{
13+
private static Logger logger = LogManager.GetCurrentClassLogger();
14+
1215
public const string DefaultReservedPrefix = "@";
1316
public static ICollection<string> GetReservedNames()
1417
{
@@ -235,6 +238,7 @@ public static string GetSanitizedPropertyName(this string property, OdcmProperty
235238
{
236239
var reservedPrefix = string.IsNullOrEmpty(prefix) ? DefaultReservedPrefix : prefix;
237240

241+
logger.Info("Property \"{0}\" is a reserved word in .NET. Converting to \"{1}{0}\"", property.ToUpperFirstChar(), reservedPrefix);
238242
return string.Concat(reservedPrefix, property.ToUpperFirstChar());
239243
}
240244

@@ -247,6 +251,7 @@ public static string GetSanitizedPropertyName(this string property, OdcmProperty
247251
if (odcmProperty.Projection.Type.Name.ToUpperFirstChar() == odcmProperty.Class.Name.ToUpperFirstChar())
248252
{
249253
// Name the property: {metadataName} + "Property"
254+
logger.Info("Property type \"{0}\" has the same name as the class. Converting to \"{0}Property\"", property);
250255
return string.Concat(property, "Property");
251256
}
252257

src/GraphODataTemplateWriter/CodeHelpers/ObjC/TypeHelperObjC.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ namespace Microsoft.Graph.ODataTemplateWriter.CodeHelpers.ObjC
77
using Microsoft.Graph.ODataTemplateWriter.Extensions;
88
using Microsoft.Graph.ODataTemplateWriter.Settings;
99
using Vipr.Core.CodeModel;
10+
using NLog;
1011

1112
public static class TypeHelperObjC
1213
{
1314
public static string Prefix = ConfigurationService.Settings.NamespacePrefix;
1415

16+
private static Logger logger = LogManager.GetCurrentClassLogger();
17+
1518
private static ICollection<string> reservedNames;
1619
public static ICollection<string> ReservedNames
1720
{
@@ -157,6 +160,10 @@ public static string SanitizePropertyName(this OdcmProperty property)
157160
{
158161
if (ReservedNames.Contains(property.Name.ToLower()))
159162
{
163+
logger.Info("Property \"{0}\" is a reserved word in Objective-C. Converting to \"{1}{0}\"",
164+
property.Name.ToUpperFirstChar(),
165+
property.Class.Name.ToLowerFirstChar()
166+
);
160167
return property.Class.Name.ToLowerFirstChar() + property.Name.ToUpperFirstChar();
161168
}
162169
return property.Name;

src/GraphODataTemplateWriter/CodeHelpers/PHP/TypeHelperPHP.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ namespace Microsoft.Graph.ODataTemplateWriter.CodeHelpers.PHP
66
using Microsoft.Graph.ODataTemplateWriter.Extensions;
77
using Vipr.Core.CodeModel;
88
using System;
9+
using NLog;
910

1011
public static class TypeHelperPHP
1112
{
1213
public const string ReservedPrefix = "Graph";
14+
private static Logger logger = LogManager.GetCurrentClassLogger();
15+
1316
public static HashSet<string> ReservedNames
1417
{
1518
get
@@ -120,6 +123,7 @@ public static string SanitizeEntityName(this String name)
120123
{
121124
if (ReservedNames.Contains(name))
122125
{
126+
logger.Info("Property \"{0}\" is a reserved word in PHP. Converting to \"{1}{0}\"", name, ReservedPrefix);
123127
return ReservedPrefix + name.ToCheckedCase();
124128
}
125129

@@ -130,6 +134,7 @@ public static string SanitizePropertyName(this String name, String entityName)
130134
{
131135
if (name == "properties")
132136
{
137+
logger.Info("Property \"{0}\" is a reserved word in PHP. Converting to \"{1}{0}\"", name, ReservedPrefix);
133138
return entityName + name.ToCheckedCase();
134139
}
135140

src/GraphODataTemplateWriter/CodeHelpers/Python/TypeHelperPython.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ namespace Microsoft.Graph.ODataTemplateWriter.CodeHelpers.Python
55
using System.Collections.Generic;
66
using Microsoft.Graph.ODataTemplateWriter.Extensions;
77
using Vipr.Core.CodeModel;
8+
using NLog;
89

910
public static class TypeHelperPython
1011
{
1112
public const string ReservedPrefix = "$$__$$";
13+
private static Logger logger = LogManager.GetCurrentClassLogger();
14+
1215
public static ICollection<string> ReservedNames
1316
{
1417
get
@@ -102,6 +105,7 @@ public static string GetToLowerFirstCharName(this OdcmProperty property)
102105
public static string SanitizePropertyName(this OdcmProperty property)
103106
{
104107
if (ReservedNames.Contains(property.Name.ToLower())) {
108+
logger.Info("Property \"{0}\" is a reserved word in Python. Converting to \"{1}{0}\"", property.Name, ReservedPrefix);
105109
return ReservedPrefix + property.Name;
106110
}
107111
return property.Name;

src/GraphODataTemplateWriter/Extensions/OdcmModelExtensions.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ namespace Microsoft.Graph.ODataTemplateWriter.Extensions
77
using System.Linq;
88
using Microsoft.Graph.ODataTemplateWriter.Settings;
99
using Vipr.Core.CodeModel;
10+
using NLog;
1011

1112
public static class OdcmModelExtensions
1213
{
14+
private static Logger logger = LogManager.GetCurrentClassLogger();
15+
1316
public static bool IsCollection(this OdcmProperty odcmProperty)
1417
{
1518
return odcmProperty.IsCollection;
@@ -152,8 +155,8 @@ public static OdcmProperty GetServiceCollectionNavigationPropertyForPropertyType
152155
.First();
153156
} catch (Exception e)
154157
{
155-
//TODO: Pass the exception to the logger
156-
Console.WriteLine("Error: The navigation property \"{0}\" on class \"{1}\" does not specify it is self-contained nor is it defined in an EntitySet", odcmProperty.Name.ToString(), odcmProperty.Class.FullName.ToString());
158+
logger.Error("The navigation property \"{0}\" on class \"{1}\" does not specify it is self-contained nor is it defined in an EntitySet", odcmProperty.Name.ToString(), odcmProperty.Class.FullName.ToString());
159+
logger.Error(e);
157160
return null;
158161
}
159162
}

src/GraphODataTemplateWriter/GraphODataTemplateWriter.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
<Reference Include="Mono.TextTemplating">
3939
<HintPath>..\..\packages\Mono.TextTemplating.1.0.0\lib\Mono.TextTemplating.dll</HintPath>
4040
</Reference>
41+
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
42+
<HintPath>..\..\packages\NLog.4.4.11\lib\net45\NLog.dll</HintPath>
43+
<Private>True</Private>
44+
</Reference>
4145
<Reference Include="System" />
4246
<Reference Include="System.Core" />
4347
<Reference Include="System.Xml.Linq" />
@@ -122,6 +126,12 @@
122126
<None Include=".config\TemplateWriterSettings.json">
123127
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
124128
</None>
129+
<Content Include="NLog.config">
130+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
131+
</Content>
132+
<None Include="NLog.xsd">
133+
<SubType>Designer</SubType>
134+
</None>
125135
<None Include="packages.config" />
126136
</ItemGroup>
127137
<ItemGroup>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
5+
autoReload="true"
6+
throwExceptions="false"
7+
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log">
8+
9+
<!-- optional, add some variables
10+
https://github.com/nlog/NLog/wiki/Configuration-file#variables
11+
-->
12+
<variable name="myvar" value="myvalue"/>
13+
14+
<!--
15+
See https://github.com/nlog/nlog/wiki/Configuration-file
16+
for information on customizing logging rules and outputs.
17+
-->
18+
<targets>
19+
<target name="logfile" xsi:type="File" fileName="generator-output.txt" />
20+
<!--
21+
add your targets here
22+
See https://github.com/nlog/NLog/wiki/Targets for possible targets.
23+
See https://github.com/nlog/NLog/wiki/Layout-Renderers for the possible layout renderers.
24+
-->
25+
26+
<!--
27+
Write events to a file with the date in the filename.
28+
<target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log"
29+
layout="${longdate} ${uppercase:${level}} ${message}" />
30+
-->
31+
</targets>
32+
33+
<rules>
34+
<!-- add your logging rules here -->
35+
<logger name="*" minlevel="Debug" writeTo="logfile" />
36+
<!--
37+
Write all events with minimal level of Debug (So Debug, Info, Warn, Error and Fatal, but not Trace) to "f"
38+
<logger name="*" minlevel="Debug" writeTo="f" />
39+
-->
40+
</rules>
41+
</nlog>

0 commit comments

Comments
 (0)