diff --git a/src/Microsoft.FeatureManagement/Targeting/TargetingEvaluator.cs b/src/Microsoft.FeatureManagement/Targeting/TargetingEvaluator.cs index 726ac185..e642c01c 100644 --- a/src/Microsoft.FeatureManagement/Targeting/TargetingEvaluator.cs +++ b/src/Microsoft.FeatureManagement/Targeting/TargetingEvaluator.cs @@ -190,7 +190,7 @@ public static bool IsTargeted( if (sourceGroups != null) { IEnumerable normalizedGroups = ignoreCase ? - sourceGroups.Select(g => g.ToLower()) : + sourceGroups.Select(g => g?.ToLower()) : sourceGroups; foreach (string group in normalizedGroups) @@ -232,13 +232,13 @@ public static bool IsTargeted( } string userId = ignoreCase ? - targetingContext.UserId.ToLower() : + targetingContext.UserId?.ToLower() : targetingContext.UserId; if (targetingContext.Groups != null) { IEnumerable normalizedGroups = ignoreCase ? - targetingContext.Groups.Select(g => g.ToLower()) : + targetingContext.Groups.Select(g => g?.ToLower()) : targetingContext.Groups; foreach (string group in normalizedGroups) @@ -280,7 +280,7 @@ public static bool IsTargeted( } string userId = ignoreCase ? - targetingContext.UserId.ToLower() : + targetingContext.UserId?.ToLower() : targetingContext.UserId; string defaultContextId = $"{userId}\n{hint}"; @@ -319,7 +319,7 @@ public static bool IsTargeted(ITargetingContext targetingContext, double from, d } string userId = ignoreCase ? - targetingContext.UserId.ToLower() : + targetingContext.UserId?.ToLower() : targetingContext.UserId; string contextId = $"{userId}\n{hint}";