Skip to content

Commit

Permalink
Optimized GetPropertyName for the common case.
Browse files Browse the repository at this point in the history
  • Loading branch information
tritao committed Feb 29, 2016
1 parent 62d5f00 commit 3dc9159
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Generator/Generators/CSharp/CSharpTextTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1217,14 +1217,16 @@ private void GenerateProperties(Class @class)
private string GetPropertyName(Property prop)
{
var isIndexer = prop.Parameters.Count != 0;
if (!isIndexer)
return prop.Name;

var @params = prop.Parameters.Select(param => {
var p = new Parameter(param);
if (isIndexer)
p.Usage = ParameterUsage.In;
p.Usage = ParameterUsage.In;
return p;
});
return !isIndexer ? prop.Name
: string.Format("this[{0}]", FormatMethodParameters(@params));

return string.Format("this[{0}]", FormatMethodParameters(@params));
}

private void GenerateVariable(Class @class, Type type, Variable variable)
Expand Down

0 comments on commit 3dc9159

Please sign in to comment.