Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions src/Microsoft.TestPlatform.Filter.Source/FastFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,15 @@ internal bool Evaluate(Func<string, object?> propertyValueProvider)
#endif

bool matched = false;
foreach (var name in FilterProperties.Keys)
foreach (var kvp in FilterProperties)
{
var filterValues = kvp.Value;

// Reserved keyword: "None" matches tests with no value for this property (uncategorized).
bool hasNoneFilter = FilterProperties[name].Contains(Condition.NoneFilterValue);
bool hasNoneFilter = filterValues.Contains(Condition.NoneFilterValue);

// If there is no value corresponding to given name, treat it as unmatched unless filtering for "None".
if (!TryGetPropertyValue(name, propertyValueProvider, out var singleValue, out var multiValues))
if (!TryGetPropertyValue(kvp.Key, propertyValueProvider, out var singleValue, out var multiValues))
{
if (hasNoneFilter)
{
Expand All @@ -100,12 +102,33 @@ internal bool Evaluate(Func<string, object?> propertyValueProvider)
if (singleValue != null)
{
var value = PropertyValueRegex == null ? singleValue : ApplyRegex(singleValue);
matched = value != null && FilterProperties[name].Contains(value);
matched = value != null && filterValues.Contains(value);
}
else if (multiValues is { Length: > 0 })
{
var values = PropertyValueRegex == null ? multiValues : multiValues?.Select(value => ApplyRegex(value));
matched = values?.Any(result => result != null && FilterProperties[name].Contains(result)) == true;
if (PropertyValueRegex == null)
{
foreach (var result in multiValues)
{
if (result != null && filterValues.Contains(result))
{
matched = true;
break;
}
}
}
else
{
foreach (var result in multiValues)
{
var transformed = ApplyRegex(result);
if (transformed != null && filterValues.Contains(transformed))
{
matched = true;
break;
}
}
}
}
else if (hasNoneFilter)
{
Expand Down
Loading