Skip to content

Commit 5d78a5b

Browse files
committed
add comments
1 parent f843e3b commit 5d78a5b

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/GraphODataTemplateWriter/CodeHelpers/Java/TypeHelperJava.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,11 @@ public static string MethodParametersJavadocSignature(this OdcmMethod method)
608608
return parameterSignatureBuilder.ToString();
609609
}
610610

611+
/// <summary>
612+
/// Takes a property object and gets to its type, then returns that types fully qualified namespace: e.g. com.microsoft.graph.callrecords
613+
/// </summary>
614+
/// <param name="p">property object</param>
615+
/// <returns>fully qualified namespace of a property</returns>
611616
public static string GetPropertyNamespace(this OdcmProperty p) => p.Projection.Type.Namespace.Name.AddPrefix();
612617

613618
public static string MethodParametersSignature(this OdcmMethod method)
@@ -846,6 +851,13 @@ public static string CreatePackageDefForBaseMethodRequestBuilder(this CustomT4Ho
846851
return sb.ToString();
847852
}
848853

854+
/// <summary>
855+
/// Appends import statements of types that appear as a method's parameters
856+
/// </summary>
857+
/// <param name="method">Method whose parameter types will be consumed</param>
858+
/// <param name="importFormat">import format, e.g. "import {0}.{1}.{2}"</param>
859+
/// <param name="sb">StringBuilder object currently in use</param>
860+
/// <returns>StringBuilder object with import statements inserted</returns>
849861
public static StringBuilder ImportClassesOfMethodParameters(OdcmMethod method, string importFormat, StringBuilder sb)
850862
{
851863
var importStatements = new HashSet<string>();
@@ -1130,6 +1142,11 @@ public static string CreatePackageDefForEntity(this CustomT4Host host)
11301142

11311143
public static string CreatePackageDef(this CustomT4Host host)
11321144
{
1145+
// {0}: type's namespace with prefix, e.g. com.microsoft.graph.callrecords
1146+
// {1}: relative path, e.g. "models.extensions" or "models.requests" etc.
1147+
// {2}: main namespace, i.e. microsoft.graph
1148+
// {3}: fully qualified import for disambiguation, e.g. TimeOff vs TimeOffRequest
1149+
// {4}: method parameters fully qualified imports
11331150
var format = @"package {0}.{1};
11341151
11351152
import {2}.concurrency.*;
@@ -1146,6 +1163,7 @@ public static string CreatePackageDef(this CustomT4Host host)
11461163
// We need this for disambiguation of generated model class/interfaces references.
11471164
string fullyQualifiedImport = host.GetFullyQualifiedImportStatementForModel();
11481165

1166+
// determine current namespace and generate method imports if applicable
11491167
string @namespace;
11501168
string methodImports = string.Empty;
11511169
switch (host.CurrentType)
@@ -1170,6 +1188,11 @@ public static string CreatePackageDef(this CustomT4Host host)
11701188
methodImports);
11711189
}
11721190

1191+
/// <summary>
1192+
/// Determines which namespace current type belongs to
1193+
/// </summary>
1194+
/// <param name="host">Host object to reach current type being processed</param>
1195+
/// <returns>namespace with prefix prepended, e.g. com.microsoft.graph.callrecords</returns>
11731196
public static string CurrentNamespace(this CustomT4Host host)
11741197
{
11751198
switch (host.CurrentType)

src/GraphODataTemplateWriter/Extensions/OdcmModelExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,8 @@ public static string AddPrefix(this string @namespace)
433433
if (string.IsNullOrEmpty(ConfigurationService.Settings.NamespaceOverride))
434434
{
435435
var name = string.Format("{0}.{1}", ConfigurationService.Settings.NamespacePrefix, @namespace).ToLower();
436+
437+
// special case com.edm happens when we reach here from a property and property is an edm type, e.g. Stream.
436438
return name == "com.edm" ? "com.microsoft.graph" : name;
437439
}
438440
return ConfigurationService.Settings.NamespaceOverride;

0 commit comments

Comments
 (0)