Skip to content

Commit

Permalink
build a fieldname once and reuse it (#1442)
Browse files Browse the repository at this point in the history
  • Loading branch information
testfirstcoder authored Sep 16, 2022
1 parent 587bc94 commit 6749851
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/NJsonSchema/Converters/JsonExceptionConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,16 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
}
else
{
field = GetField(objectType, "m_" + property.Value.Substring(0, 1).ToLowerInvariant() + property.Value.Substring(1));
var fieldNameSuffix = property.Value.Substring(0, 1).ToLowerInvariant() + property.Value.Substring(1);

field = GetField(objectType, "m_" + fieldNameSuffix);
if (field != null)
{
field.SetValue(value, propertyValue);
}
else
{
field = GetField(objectType, "_" + property.Value.Substring(0, 1).ToLowerInvariant() + property.Value.Substring(1));
field = GetField(objectType, "_" + fieldNameSuffix);
if (field != null)
{
field.SetValue(value, propertyValue);
Expand Down

0 comments on commit 6749851

Please sign in to comment.