in src/Microsoft.VisualStudio.Validation/Requires.cs [577:599]
public static void ValidElements<T>([ValidatedNotNull] IEnumerable<T> values, Predicate<T> predicate, string? parameterName, string? message)
{
// 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(message, parameterName);
}
}
}