== Why is this an issue?

Creating an array or using a collection expression solely for the purpose of passing it to a `params` parameter is unnecessary. Simply pass the elements directly, and they will be automatically consolidated into the appropriate collection type.

== How to fix it

=== Code examples

==== Noncompliant code example

[source,csharp,diff-id=1,diff-type=noncompliant]
----
public void Base() 
{
    Method(new string[] { "s1", "s2" }); // Noncompliant: resolves to string[] overload
    Method(new string[] { });            // Noncompliant: resolves to string[] overload
    Method(["s3", "s4"]);                // Noncompliant: resolves to ReadOnlySpan overload
    Method(new string[12]);              // Compliant: resolves to string[] overload 
}

public void Method(params string[] args)
{
    // ...
}

public void Method(params ReadOnlySpan<string> args) // C# 13 params collections
{
    // C# 13 params collection
}
----

==== Compliant solution

[source,csharp,diff-id=1,diff-type=compliant]
----
public void Base()
{
    Method("s1", "s2");     // resolves to ReadOnlySpan overload
    Method();               // resolves to ReadOnlySpan overload
    Method("s3", "s4");     // resolves to ReadOnlySpan overload
    Method(new string[12]); // resolves to string[]  overload
}

public void Method(params string[] args)
{
    // ..
}

public void Method(params ReadOnlySpan<string> args) // C# 13 params collections
{
    // ..
}
----

== Resources

=== Documentation

* Microsoft Learn - https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/method-parameters#params-modifier[`params` modifier]
* Microsoft Learn - C# 13 https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-13#params-collections[`params` collections]
* Microsoft Learn - https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/collection-expressions[Collection expressions]
