Skip to content

Commit

Permalink
avoid null reference (#457)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiyuanliang-ms authored Jun 1, 2024
1 parent d9ff1af commit d90fa76
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Microsoft.FeatureManagement/Targeting/TargetingEvaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public static bool IsTargeted(
if (sourceGroups != null)
{
IEnumerable<string> normalizedGroups = ignoreCase ?
sourceGroups.Select(g => g.ToLower()) :
sourceGroups.Select(g => g?.ToLower()) :
sourceGroups;

foreach (string group in normalizedGroups)
Expand Down Expand Up @@ -232,13 +232,13 @@ public static bool IsTargeted(
}

string userId = ignoreCase ?
targetingContext.UserId.ToLower() :
targetingContext.UserId?.ToLower() :
targetingContext.UserId;

if (targetingContext.Groups != null)
{
IEnumerable<string> normalizedGroups = ignoreCase ?
targetingContext.Groups.Select(g => g.ToLower()) :
targetingContext.Groups.Select(g => g?.ToLower()) :
targetingContext.Groups;

foreach (string group in normalizedGroups)
Expand Down Expand Up @@ -280,7 +280,7 @@ public static bool IsTargeted(
}

string userId = ignoreCase ?
targetingContext.UserId.ToLower() :
targetingContext.UserId?.ToLower() :
targetingContext.UserId;

string defaultContextId = $"{userId}\n{hint}";
Expand Down Expand Up @@ -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}";
Expand Down

0 comments on commit d90fa76

Please sign in to comment.