Add filter tests, fix issues found

This commit is contained in:
Matt Nadareski
2024-03-05 09:17:00 -05:00
parent 07dad00845
commit 8875948946
5 changed files with 167 additions and 6 deletions

View File

@@ -48,7 +48,7 @@ namespace SabreTools.Filter
if (itemName == null || fieldName == null)
throw new ArgumentOutOfRangeException(nameof(filterString));
this.Key = new string[] { itemName, fieldName };
this.Key = [itemName, fieldName];
this.Value = value;
this.Operation = operation;
}
@@ -59,7 +59,7 @@ namespace SabreTools.Filter
if (itemName == null || fieldName == null)
throw new ArgumentOutOfRangeException(nameof(value));
this.Key = new string[] { itemName, fieldName };
this.Key = [itemName, fieldName];
this.Value = value;
this.Operation = GetOperation(operation);
}
@@ -70,7 +70,7 @@ namespace SabreTools.Filter
if (itemName == null || fieldName == null)
throw new ArgumentOutOfRangeException(nameof(value));
this.Key = new string[] { itemName, fieldName };
this.Key = [itemName, fieldName];
this.Value = value;
this.Operation = operation;
}

View File

@@ -30,7 +30,7 @@ namespace SabreTools.Filter
#else
return fields
.Where(f => f.IsLiteral && !f.IsInitOnly)
.Where(f => f.CustomAttributes.Any(a => a.AttributeType == typeof(NoFilterAttribute)))
.Where(f => !f.CustomAttributes.Any(a => a.AttributeType == typeof(NoFilterAttribute)))
.Select(f => f.GetRawConstantValue() as string)
.Where(v => v != null)
.ToArray()!;
@@ -47,8 +47,8 @@ namespace SabreTools.Filter
return AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(a => a.GetTypes())
.Where(t => t.IsAssignableFrom(typeof(DatItem)) && t.IsClass)
.FirstOrDefault(t => GetXmlRootAttributeElementName(t) == itemType);
.Where(t => typeof(DatItem).IsAssignableFrom(t) && t.IsClass)
.FirstOrDefault(t => string.Equals(GetXmlRootAttributeElementName(t), itemType, StringComparison.OrdinalIgnoreCase));
}
/// <summary>