Skip to content

Commit

Permalink
Switch from ContainsKey to TryGetValue per pull request comment
Browse files Browse the repository at this point in the history
  • Loading branch information
gregwinterstein committed Sep 25, 2023
1 parent d83eeb6 commit 83cb640
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/Microsoft.OData.CodeGen/Templates/ODataT4CodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2444,8 +2444,15 @@ internal void WritePropertiesForSingleType(IEnumerable<IEdmProperty> properties)
foreach (IEdmProperty property in properties.Where(i => i.PropertyKind == EdmPropertyKind.Navigation))
{
string propertyType;
string propertyName = IdentifierMappings.ContainsKey(property.Name) ?
IdentifierMappings[property.Name] : (this.context.EnableNamingAlias ? Customization.CustomizeNaming(property.Name) : property.Name);
string propertyName;
if (IdentifierMappings.TryGetValue(property.Name, out var mappedPropertyName))
{
propertyName = mappedPropertyName;
}
else
{
propertyName = this.context.EnableNamingAlias ? Customization.CustomizeNaming(property.Name) : property.Name;
}

if (property.Type is Microsoft.OData.Edm.EdmCollectionTypeReference)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2302,8 +2302,15 @@ public abstract class ODataClientTemplate : TemplateBase
foreach (IEdmProperty property in properties.Where(i => i.PropertyKind == EdmPropertyKind.Navigation))
{
string propertyType;
string propertyName = IdentifierMappings.ContainsKey(property.Name) ?
IdentifierMappings[property.Name] : (this.context.EnableNamingAlias ? Customization.CustomizeNaming(property.Name) : property.Name);
string propertyName;
if (IdentifierMappings.TryGetValue(property.Name, out var mappedPropertyName))
{
propertyName = mappedPropertyName;
}
else
{
propertyName = this.context.EnableNamingAlias ? Customization.CustomizeNaming(property.Name) : property.Name;
}

if (property.Type is Microsoft.OData.Edm.EdmCollectionTypeReference)
{
Expand Down

0 comments on commit 83cb640

Please sign in to comment.