diff --git a/.gitmodules b/.gitmodules index 4897e31..737b0aa 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/Flagsmith.Engine/Engine.cs b/Flagsmith.Engine/Engine.cs index 4cabe8d..f2567bb 100644 --- a/Flagsmith.Engine/Engine.cs +++ b/Flagsmith.Engine/Engine.cs @@ -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) diff --git a/Flagsmith.EngineTest/EngineTestData b/Flagsmith.EngineTest/EngineTestData index 7840a13..4b29dc7 160000 --- a/Flagsmith.EngineTest/EngineTestData +++ b/Flagsmith.EngineTest/EngineTestData @@ -1 +1 @@ -Subproject commit 7840a1349b601df3b6b4a089f40864f659801afb +Subproject commit 4b29dc772a764364af2dd504ecefbdf74cf5473f