in src/Microsoft.VisualStudio.Validation/Requires.cs [615:637]
public static void ValidElements<T>([ValidatedNotNull] IEnumerable<T> values, Predicate<T> predicate, string? parameterName, string unformattedMessage, params object?[] args)
{
// To whoever is doing random code cleaning:
// Consider the performance when changing the code to delegate to NotNull.
// In general do not chain call to another function, check first and return as early as possible.
if (values is null)
{
throw new ArgumentNullException(nameof(values));
}
if (predicate is null)
{
throw new ArgumentNullException(nameof(predicate));
}
foreach (T value in values)
{
if (!predicate(value))
{
throw new ArgumentException(PrivateErrorHelpers.Format(unformattedMessage, args), parameterName);
}
}
}