λ1004: Use ConcatToString instead of JoinToString(string.Empty)

Joining a sequence with an empty separator should be expressed as ConcatToString.

Cause

JoinToString is called with "" or string.Empty as the separator.

Reason for rule

JoinToString with an empty separator does not join anything, it concatenates. ConcatToString says exactly that and avoids the reader having to inspect the separator argument.

How to fix violations

Replace .JoinToString(string.Empty) with .ConcatToString(). A code fix is available.

Examples

Disallowed

IEnumerable<string> words = ["fun", "cky"];
string result = words.JoinToString(string.Empty);

Allowed

IEnumerable<string> words = ["fun", "cky"];
string result = words.ConcatToString();

// Any other separator is fine.
string csv = words.JoinToString(", ");