diff --git a/src/Lidarr.Http/ClientSchema/SchemaBuilder.cs b/src/Lidarr.Http/ClientSchema/SchemaBuilder.cs index 3c3c4c777..f6f9a1557 100644 --- a/src/Lidarr.Http/ClientSchema/SchemaBuilder.cs +++ b/src/Lidarr.Http/ClientSchema/SchemaBuilder.cs @@ -107,7 +107,7 @@ namespace Lidarr.Http.ClientSchema Placeholder = fieldAttribute.Placeholder }; - if (fieldAttribute.Type == FieldType.Select || fieldAttribute.Type == FieldType.TagSelect) + if (fieldAttribute.Type is FieldType.Select or FieldType.TagSelect) { if (fieldAttribute.SelectOptionsProviderAction.IsNotNullOrWhiteSpace()) { @@ -154,33 +154,40 @@ namespace Lidarr.Http.ClientSchema private static List GetSelectOptions(Type selectOptions) { - var options = selectOptions.GetFields().Where(v => v.IsStatic).Select(v => + if (selectOptions.IsEnum) { - var name = v.Name.Replace('_', ' '); - var value = Convert.ToInt32(v.GetRawConstantValue()); - var attrib = v.GetCustomAttribute(); - if (attrib != null) - { - return new SelectOption - { - Value = value, - Name = attrib.Label ?? name, - Order = attrib.Order, - Hint = attrib.Hint ?? $"({value})" - }; - } - else - { - return new SelectOption + var options = selectOptions + .GetFields() + .Where(v => v.IsStatic && !v.GetCustomAttributes(false).OfType().Any()) + .Select(v => { - Value = value, - Name = name, - Order = value - }; - } - }); + var name = v.Name.Replace('_', ' '); + var value = Convert.ToInt32(v.GetRawConstantValue()); + var attrib = v.GetCustomAttribute(); + + if (attrib != null) + { + return new SelectOption + { + Value = value, + Name = attrib.Label ?? name, + Order = attrib.Order, + Hint = attrib.Hint ?? $"({value})" + }; + } + + return new SelectOption + { + Value = value, + Name = name, + Order = value + }; + }); + + return options.OrderBy(o => o.Order).ToList(); + } - return options.OrderBy(o => o.Order).ToList(); + throw new NotSupportedException(); } private static Func GetValueConverter(Type propertyType)