Skip to content

Commit 88496b9

Browse files
Assert instead of ! for nullable (#11545)
1 parent 0a41c5f commit 88496b9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Build/Utilities/EngineFileUtilities.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Collections.Concurrent;
66
using System.Collections.Generic;
7+
using System.Diagnostics;
78
using System.IO;
89
using System.Linq;
910
using System.Text.RegularExpressions;
@@ -588,7 +589,9 @@ private static List<Regex> PopulateRegexFromEnvironment()
588589

589590
private static bool MatchesLazyWildcard(string fileSpec)
590591
{
591-
return _regexMatchCache.Value.GetOrAdd(fileSpec, file => s_lazyWildCardExpansionRegexes!.Any(regex => regex.IsMatch(fileSpec)));
592+
Debug.Assert(s_lazyWildCardExpansionRegexes is not null, $"If the user provided lazy wildcard regexes, {nameof(s_lazyWildCardExpansionRegexes)} should be populated");
593+
594+
return _regexMatchCache.Value.GetOrAdd(fileSpec, file => s_lazyWildCardExpansionRegexes.Any(regex => regex.IsMatch(fileSpec)));
592595
}
593596

594597
/// <summary>

0 commit comments

Comments
 (0)