Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "Flagsmith.EngineTest/EngineTestData"]
path = Flagsmith.EngineTest/EngineTestData
url = git@github.com:Flagsmith/engine-test-data.git
branch = v3.5.0
branch = v3.7.0
24 changes: 23 additions & 1 deletion Flagsmith.Engine/Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,29 @@ private static bool ContextMatchesRule<_, __>(EvaluationContext<_, __> context,
break;
}

return matchesConditions && (rule.Rules?.All(r => ContextMatchesRule(context, r, segmentKey)) ?? true);
if (!matchesConditions)
return false;

if (rule.Rules is null || !rule.Rules.Any())
return true;

bool matchesSubRules;
switch (rule.Type)
{
case TypeEnum.All:
matchesSubRules = rule.Rules.All(r => ContextMatchesRule(context, r, segmentKey));
break;
case TypeEnum.Any:
matchesSubRules = rule.Rules.Any(r => ContextMatchesRule(context, r, segmentKey));
break;
case TypeEnum.None:
matchesSubRules = !rule.Rules.Any(r => ContextMatchesRule(context, r, segmentKey));
break;
default:
matchesSubRules = false;
break;
}
return matchesSubRules;
}

private static bool ContextMatchesCondition<_, __>(EvaluationContext<_, __> context, Condition condition, string segmentKey)
Expand Down
Loading