diff --git a/src/Miru/Urls/DefaultPropertyNameModfier.cs b/src/Miru/Urls/DefaultPropertyNameModfier.cs deleted file mode 100644 index 2f64dd07..00000000 --- a/src/Miru/Urls/DefaultPropertyNameModfier.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Linq; -using System.Reflection; -using Microsoft.AspNetCore.Mvc; - -namespace Miru.Urls -{ - public class DefaultPropertyNameModfier - { - public virtual string GetModifiedPropertyName(PropertyInfo propertyInfo, Attribute[] attributes) - { - var fromQueryAttributes = attributes.OfType().ToArray(); - - if (fromQueryAttributes.Length > 0) - { - return fromQueryAttributes[0].Name; - } - - return propertyInfo.Name; - } - } -} \ No newline at end of file diff --git a/src/Miru/Urls/DefaultPropertyNameModifier.cs b/src/Miru/Urls/DefaultPropertyNameModifier.cs new file mode 100644 index 00000000..3098dfa4 --- /dev/null +++ b/src/Miru/Urls/DefaultPropertyNameModifier.cs @@ -0,0 +1,20 @@ +using System.Linq; +using System.Reflection; +using Microsoft.AspNetCore.Mvc; + +namespace Miru.Urls; + +public class DefaultPropertyNameModifier +{ + public virtual string GetModifiedPropertyName(PropertyInfo propertyInfo, Attribute[] attributes) + { + var fromQueryAttributes = attributes.OfType().ToArray(); + + if (fromQueryAttributes.Length > 0) + { + return fromQueryAttributes[0].Name; + } + + return propertyInfo.Name; + } +} \ No newline at end of file diff --git a/src/Miru/Urls/PropertyHelper.cs b/src/Miru/Urls/PropertyHelper.cs index 5cebb9dc..4c0712cc 100644 --- a/src/Miru/Urls/PropertyHelper.cs +++ b/src/Miru/Urls/PropertyHelper.cs @@ -7,9 +7,11 @@ using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using System.Linq; using System.Reflection; using System.Reflection.Metadata; using System.Runtime.CompilerServices; +using Microsoft.AspNetCore.Mvc; using Miru.Urls; [assembly: MetadataUpdateHandler(typeof(PropertyHelper.MetadataUpdateHandler))] @@ -54,7 +56,10 @@ internal sealed class PropertyHelper public PropertyHelper(PropertyInfo property) { Property = property ?? throw new ArgumentNullException(nameof(property)); - Name = property.Name; + + var attr = property.GetCustomAttribute(); + + Name = attr?.Name ?? property.Name; } ///