λ1002: Use of Enumerable.Repeat with no element
Enumerable.Repeat(value, 0) should be replaced with Enumerable.Empty<T>().
Cause
Enumerable.Repeat is called with a constant count of 0.
Reason for rule
Repeating a value zero times always yields an empty sequence, and the value is never used.
Enumerable.Empty<T>() expresses that directly, does not evaluate an unused argument, and returns a cached singleton instance.
How to fix violations
Replace the call with Enumerable.Empty<T>(), where T is the type of the repeated value. A code fix is available.
Examples
Disallowed
IEnumerable<string> nothing = Enumerable.Repeat("hello", 0);
Allowed
IEnumerable<string> nothing = Enumerable.Empty<string>();