Skip to content

Commit

Permalink
Removing warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
joaofx committed Mar 1, 2024
1 parent 474c4bd commit b868e0a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
22 changes: 0 additions & 22 deletions src/Miru/Urls/DefaultPropertyNameModfier.cs

This file was deleted.

20 changes: 20 additions & 0 deletions 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<FromQueryAttribute>().ToArray();

if (fromQueryAttributes.Length > 0)
{
return fromQueryAttributes[0].Name;
}

return propertyInfo.Name;
}
}
7 changes: 6 additions & 1 deletion src/Miru/Urls/PropertyHelper.cs
Expand Up @@ -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))]
Expand Down Expand Up @@ -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<FromQueryAttribute>();

Name = attr?.Name ?? property.Name;
}

/// <summary>
Expand Down

0 comments on commit b868e0a

Please sign in to comment.