From 402a9c1bc6438dd1a9cd8743bd6c819a0a48f93f Mon Sep 17 00:00:00 2001 From: zhiyuanliang Date: Fri, 31 May 2024 08:58:31 +0800 Subject: [PATCH] avoid null reference --- .../Targeting/TargetingEvaluator.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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}";