62 lines
1.1 KiB
Plaintext
62 lines
1.1 KiB
Plaintext
== Why is this an issue?
|
|
|
|
Adding https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/params[params] to a method override has no effect. The compiler accepts it, but the callers won't be able to benefit from the added modifier.
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,csharp,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
class Base
|
|
{
|
|
public virtual void Method(int[] numbers)
|
|
{
|
|
...
|
|
}
|
|
}
|
|
class Derived : Base
|
|
{
|
|
public override void Method(params int[] numbers) // Noncompliant, method can't be called with params syntax.
|
|
{
|
|
...
|
|
}
|
|
}
|
|
----
|
|
|
|
=== Compliant solution
|
|
|
|
[source,csharp,diff-id=1,diff-type=compliant]
|
|
----
|
|
class Base
|
|
{
|
|
public virtual void Method(int[] numbers)
|
|
{
|
|
...
|
|
}
|
|
}
|
|
class Derived : Base
|
|
{
|
|
public override void Method(int[] numbers)
|
|
{
|
|
...
|
|
}
|
|
}
|
|
----
|
|
|
|
== Resources
|
|
|
|
=== Documentation
|
|
|
|
* https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/params[params keyword]
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
"params" should be removed from this override.
|
|
|
|
endif::env-github,rspecator-view[]
|