From 8573bd754fcbc396185086964d73a118be74549d Mon Sep 17 00:00:00 2001 From: Adam Simon Date: Wed, 25 Oct 2023 19:59:42 +0200 Subject: [PATCH] Fix typos & minor code style improvements --- .../Evaluation/EvaluateLogHelper.cs | 3 +-- .../Evaluation/RolloutEvaluator.cs | 17 +++++++---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/ConfigCatClient/Evaluation/EvaluateLogHelper.cs b/src/ConfigCatClient/Evaluation/EvaluateLogHelper.cs index 30a90c8c..c79f9b66 100644 --- a/src/ConfigCatClient/Evaluation/EvaluateLogHelper.cs +++ b/src/ConfigCatClient/Evaluation/EvaluateLogHelper.cs @@ -203,11 +203,10 @@ private static IndentedTextBuilder AppendPercentageOptions(this IndentedTextBuil private static IndentedTextBuilder AppendTargetingRuleThenPart(this IndentedTextBuilder builder, TargetingRule targetingRule, bool newLine, bool appendPercentageOptions = false, string? percentageOptionsAttribute = null) { - var percentageOptions = targetingRule.PercentageOptions; - (newLine ? builder.NewLine() : builder.Append(" ")) .Append("THEN"); + var percentageOptions = targetingRule.PercentageOptions; if (percentageOptions is not { Length: > 0 }) { return builder.Append($" '{targetingRule.SimpleValue?.Value ?? default}'"); diff --git a/src/ConfigCatClient/Evaluation/RolloutEvaluator.cs b/src/ConfigCatClient/Evaluation/RolloutEvaluator.cs index 82c12391..5cf6b059 100644 --- a/src/ConfigCatClient/Evaluation/RolloutEvaluator.cs +++ b/src/ConfigCatClient/Evaluation/RolloutEvaluator.cs @@ -62,7 +62,7 @@ public EvaluateResult Evaluate(T defaultValue, ref EvaluateContext context, [ if (context.Setting.SettingType != Setting.UnknownType && context.Setting.SettingType != expectedSettingType) { throw new InvalidOperationException( - "The type of a setting must match the type of the specified default value " + "The type of a setting must match the type of the specified default value. " + $"Setting's type was {context.Setting.SettingType} but the default value's type was {typeof(T)}. " + $"Please use a default value which corresponds to the setting type {context.Setting.SettingType}."); } @@ -159,13 +159,10 @@ private bool TryEvaluateTargetingRules(TargetingRule[] targetingRules, ref Evalu logBuilder?.DecreaseIndent(); return true; } - else - { - logBuilder? - .NewLine(TargetingRuleIgnoredMessage) - .DecreaseIndent(); - continue; - } + + logBuilder? + .NewLine(TargetingRuleIgnoredMessage) + .DecreaseIndent(); } result = default; @@ -237,14 +234,14 @@ private bool TryEvaluatePercentageOptions(PercentageOption[] percentageOptions, continue; } - var percentageOptionValue = percentageOption.Value.GetValue(context.Setting.SettingType, throwIfInvalid: false); + var percentageOptionValue = percentageOption.Value.GetValue(throwIfInvalid: false); logBuilder?.NewLine().Append($"- Hash value {hashValue} selects % option {i + 1} ({percentageOption.Percentage}%), '{percentageOptionValue ?? EvaluateLogHelper.InvalidValuePlaceholder}'."); result = new EvaluateResult(percentageOption, matchedTargetingRule: targetingRule, matchedPercentageOption: percentageOption); return true; } - throw new InvalidOperationException("Sum of percentage option percentages are less than 100)."); + throw new InvalidOperationException("Sum of percentage option percentages are less than 100."); } private bool TryEvaluateConditions(TCondition[] conditions, TargetingRule? targetingRule, string contextSalt, ref EvaluateContext context, out bool result)