Describe the problem you are trying to solve
Avoid unnecessary array allocations if an array is created only to be passed to string.Split method.
Describe suggestions on how to achieve the rule
- If one of the string.Split overloads that takes an array is used, and the array contains only one element, and not used anywhere else, the analyzer should suggest using either Split(char, ...) overload or Split(string, ...) overload.
Additional context
Example from dotnet/sdk:
https://github.com/dotnet/sdk/blob/ab2176b3447e3e7820b5a340408110b6d498f907/src/Tasks/Microsoft.NET.Build.Tasks/CompilationOptionsConverter.cs#L20
Using the following will avoid an unnecessary array allocation:
compilerOptionsItem.GetMetadata("DefineConstants")?.Split(';', StringSplitOptions.RemoveEmptyEntries),
Describe the problem you are trying to solve
Avoid unnecessary array allocations if an array is created only to be passed to string.Split method.
Describe suggestions on how to achieve the rule
Additional context
Example from dotnet/sdk:
https://github.com/dotnet/sdk/blob/ab2176b3447e3e7820b5a340408110b6d498f907/src/Tasks/Microsoft.NET.Build.Tasks/CompilationOptionsConverter.cs#L20
Using the following will avoid an unnecessary array allocation: