Skip to content

Commit

Permalink
fix: Be less strict with property names (#8)
Browse files Browse the repository at this point in the history
Co-authored-by: Konstantin <konstantin.klein+github@hochfrequenz.de>
  • Loading branch information
hf-kklein and Konstantin authored Sep 9, 2024
1 parent 562ccea commit 5860e21
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ private string GetJsonPathOfAnnotatedProperty(
if (
newtonsoftJsonPropertyAttribute is not null
&& systemTextJsonPropertyNameAttribute is null
&& newtonsoftJsonPropertyAttribute.PropertyName?.ToLower()
!= propertyInfo.Name.ToLower()
)
{
throw new InconsistentPropertyNamesException(
Expand All @@ -98,6 +100,11 @@ newtonsoftJsonPropertyAttribute is not null
if (
systemTextJsonPropertyNameAttribute is not null
&& newtonsoftJsonPropertyAttribute is null
&& !string.Equals(
systemTextJsonPropertyNameAttribute.Name,
propertyInfo.Name,
StringComparison.CurrentCultureIgnoreCase
)
)
{
throw new InconsistentPropertyNamesException(
Expand All @@ -110,19 +117,15 @@ systemTextJsonPropertyNameAttribute is not null
if (
newtonsoftJsonPropertyAttribute is not null
&& systemTextJsonPropertyNameAttribute is not null
&& newtonsoftJsonPropertyAttribute.PropertyName?.ToLower()
!= systemTextJsonPropertyNameAttribute.Name.ToLower()
)
{
if (
newtonsoftJsonPropertyAttribute.PropertyName
!= systemTextJsonPropertyNameAttribute.Name
)
{
throw new InconsistentPropertyNamesException(
propertyInfo.Name,
newtonsoftJsonPropertyAttribute.PropertyName,
systemTextJsonPropertyNameAttribute.Name
);
}
throw new InconsistentPropertyNamesException(
propertyInfo.Name,
newtonsoftJsonPropertyAttribute.PropertyName,
systemTextJsonPropertyNameAttribute.Name
);
}
}

Expand Down

0 comments on commit 5860e21

Please sign in to comment.