diff --git a/GrowthBook/Api/FeatureRefreshWorker.cs b/GrowthBook/Api/FeatureRefreshWorker.cs index 56f2cbd..c8253a5 100644 --- a/GrowthBook/Api/FeatureRefreshWorker.cs +++ b/GrowthBook/Api/FeatureRefreshWorker.cs @@ -188,7 +188,7 @@ private IDictionary GetFeaturesFrom(string json) { var featuresResponse = JsonConvert.DeserializeObject(json); - if (featuresResponse.EncryptedFeatures.IsMissing()) + if (featuresResponse.EncryptedFeatures.IsNullOrWhitespace()) { _logger.LogInformation($"API response JSON contained no encrypted features, returning '{featuresResponse.FeatureCount}' unencrypted features"); return featuresResponse.Features; diff --git a/GrowthBook/Extensions/ValidationExtensions.cs b/GrowthBook/Extensions/ValidationExtensions.cs index e0b01ce..bedb81f 100644 --- a/GrowthBook/Extensions/ValidationExtensions.cs +++ b/GrowthBook/Extensions/ValidationExtensions.cs @@ -15,6 +15,6 @@ internal static class ValidationExtensions /// /// The string to verify. /// True if null, empty, or whitespace, false otherwise. - public static bool IsMissing(this string value) => string.IsNullOrWhiteSpace(value); + public static bool IsNullOrWhitespace(this string value) => string.IsNullOrWhiteSpace(value); } } diff --git a/GrowthBook/FeatureResult.cs b/GrowthBook/FeatureResult.cs index 88eb75a..8fd5536 100644 --- a/GrowthBook/FeatureResult.cs +++ b/GrowthBook/FeatureResult.cs @@ -12,7 +12,7 @@ public class FeatureResult /// /// Represents possible values for the source of a feature result. /// - public static class SourceIs + public static class SourceId { public const string UnknownFeature = "unknownFeature"; public const string DefaultValue = "defaultValue"; diff --git a/GrowthBook/GrowthBook.cs b/GrowthBook/GrowthBook.cs index ded7463..885aab0 100644 --- a/GrowthBook/GrowthBook.cs +++ b/GrowthBook/GrowthBook.cs @@ -190,7 +190,7 @@ public FeatureResult EvalFeature(string featureId) { if (!Features.TryGetValue(featureId, out Feature feature)) { - return GetFeatureResult(null, FeatureResult.SourceIs.UnknownFeature); + return GetFeatureResult(null, FeatureResult.SourceId.UnknownFeature); } foreach (FeatureRule rule in feature?.Rules ?? Enumerable.Empty()) @@ -227,7 +227,7 @@ public FeatureResult EvalFeature(string featureId) } } - return GetFeatureResult(rule.Force, FeatureResult.SourceIs.Force); + return GetFeatureResult(rule.Force, FeatureResult.SourceId.Force); } var experiment = new Experiment @@ -253,10 +253,10 @@ public FeatureResult EvalFeature(string featureId) continue; } - return GetFeatureResult(result.Value, FeatureResult.SourceIs.Experiment, experiment, result); + return GetFeatureResult(result.Value, FeatureResult.SourceId.Experiment, experiment, result); } - return GetFeatureResult(feature.DefaultValue ?? null, FeatureResult.SourceIs.DefaultValue); + return GetFeatureResult(feature.DefaultValue ?? null, FeatureResult.SourceId.DefaultValue); } catch(Exception ex) { @@ -264,10 +264,10 @@ public FeatureResult EvalFeature(string featureId) if (!Features.TryGetValue(featureId, out Feature feature)) { - return GetFeatureResult(null, FeatureResult.SourceIs.UnknownFeature); + return GetFeatureResult(null, FeatureResult.SourceId.UnknownFeature); } - return GetFeatureResult(feature.DefaultValue ?? null, FeatureResult.SourceIs.DefaultValue); + return GetFeatureResult(feature.DefaultValue ?? null, FeatureResult.SourceId.DefaultValue); } } @@ -343,7 +343,7 @@ private ExperimentResult RunExperiment(Experiment experiment, string featureId) // 3. Use the override value from the query string if one is specified. - if (!Url.IsMissing()) + if (!Url.IsNullOrWhitespace()) { var overrideValue = ExperimentUtilities.GetQueryStringOverride(experiment.Key, Url, experiment.Variations.Count); @@ -374,7 +374,7 @@ private ExperimentResult RunExperiment(Experiment experiment, string featureId) var hashValue = Attributes.GetHashAttributeValue(experiment.HashAttribute); - if (hashValue.IsMissing()) + if (hashValue.IsNullOrWhitespace()) { _logger.LogDebug($"Aborting experiment, unable to locate a value for the experiment hash attribute '{experiment.HashAttribute}'"); return GetExperimentResult(experiment, featureId: featureId); @@ -462,7 +462,7 @@ private bool IsFilteredOut(IEnumerable filters) { var hashValue = Attributes.GetHashAttributeValue(filter.Attribute); - if (hashValue.IsMissing()) + if (hashValue.IsNullOrWhitespace()) { _logger.LogDebug($"Attributes are missing a filter's hash attribute of '{filter.Attribute}', marking as filtered out"); return true; diff --git a/GrowthBook/Utilities/ExperimentUtilities.cs b/GrowthBook/Utilities/ExperimentUtilities.cs index 7da35d5..f1ca3c7 100644 --- a/GrowthBook/Utilities/ExperimentUtilities.cs +++ b/GrowthBook/Utilities/ExperimentUtilities.cs @@ -19,14 +19,14 @@ internal static class ExperimentUtilities /// The overridden variation id, or null if not found. public static int? GetQueryStringOverride(string id, string url, int numVariations) { - if (url.IsMissing()) + if (url.IsNullOrWhitespace()) { return null; } var res = new Uri(url); - if (res.Query.IsMissing()) + if (res.Query.IsNullOrWhitespace()) { return null; } @@ -34,7 +34,7 @@ internal static class ExperimentUtilities NameValueCollection qs = HttpUtility.ParseQueryString(res.Query); var variation = qs.Get(id); - if (variation.IsMissing()) + if (variation.IsNullOrWhitespace()) { return null; }