Skip to content

Commit 2075c91

Browse files
committed
Add case insensitive comparison for check whether there exists a method called item. Cleaned up the insertion of the IndexerName attribute for renaming a property for the compler.
1 parent 86696b1 commit 2075c91

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

Templates/CSharp/Base/CollectionRequestBuilder.Base.template.tt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ public string GetCollectionIndexRequestBuilder(OdcmProperty odcmProperty)
128128
allMethods.AddRange(method.Overloads);
129129
}
130130
var renameItem = "";
131-
if (allMethods.Exists(x => x.Name.Equals("item")))
131+
if (allMethods.Exists(x => x.Name.ToLower().Equals("item")))
132132
{
133-
renameItem = " [System.Runtime.CompilerServices.IndexerName(\"ThisItem\")]";
133+
renameItem = "\n [System.Runtime.CompilerServices.IndexerName(\"ThisItem\")]";
134134
}
135135

136136
var stringBuilder = new StringBuilder();
@@ -146,12 +146,8 @@ public string GetCollectionIndexRequestBuilder(OdcmProperty odcmProperty)
146146
stringBuilder.AppendFormat(" /// <param name=\"id\">The ID for the {0}.</param>", propTypeName);
147147
stringBuilder.Append(Environment.NewLine);
148148
stringBuilder.AppendFormat(" /// <returns>The <see cref=\"I{0}\"/>.</returns>", entityRequestBuilder);
149+
stringBuilder.Append(renameItem);
149150
stringBuilder.Append(Environment.NewLine);
150-
if (renameItem.Length > 0)
151-
{
152-
stringBuilder.Append(renameItem);
153-
stringBuilder.Append(Environment.NewLine);
154-
}
155151
stringBuilder.AppendFormat(" public I{0} this[string id]", entityRequestBuilder);
156152
stringBuilder.Append(Environment.NewLine);
157153
stringBuilder.Append(

Templates/CSharp/Base/ICollectionRequestBuilder.Base.template.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public string GetCollectionIndexRequestBuilder(OdcmProperty odcmProperty)
3636
allMethods.AddRange(method.Overloads);
3737
}
3838

39-
var hasItemMethod = allMethods.Exists(x => x.Name.Equals("item")) ? true : false;
39+
var hasItemMethod = allMethods.Exists(x => x.Name.ToLower().Equals("item")) ? true : false;
4040

4141
return this.GetIndexRequestBuilder(propTypeName, entityRequestBuilder, hasItemMethod);
4242
}

0 commit comments

Comments
 (0)