An array of constants is created anew as an argument on every call, where a static field would create it once
What it finds
text.Split(new[] { ',', ';' }) allocates the same array each time the line runs. A static readonly field holds it once; for Split and Trim, the params overloads or a SearchValues instance do the same. The rule reports array creations with only literal elements passed as arguments.
From the rule's source, constant_array_argument.rs.
class Csv{ string[] Cells(string line) => line.Split(new[] { ',', ';' });tx0 reports: this array of constants is allocated on every call} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/csharp:constant-array-argument" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/csharp:constant-array-argument] reason="..."tx0 explain tx0/csharp:constant-array-argument shows the same in the terminal. Found a false positive? Report it.