
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
62 lines
1.9 KiB
Plaintext
62 lines
1.9 KiB
Plaintext
== Why is this an issue?
|
|
|
|
The rules for method resolution are complex and perhaps not properly understood by all coders. The ``++params++`` keyword can make method declarations overlap in non-obvious ways, so that slight changes in the argument types of an invocation can resolve to different methods.
|
|
|
|
|
|
This rule raises an issue when an invocation resolves to a method declaration with ``++params++``, but could also resolve to another non-``++params++`` method too.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,csharp]
|
|
----
|
|
public class MyClass
|
|
{
|
|
private void Format(string a, params object[] b) { }
|
|
|
|
private void Format(object a, object b, object c) { }
|
|
}
|
|
|
|
// ...
|
|
MyClass myClass = new MyClass();
|
|
|
|
myClass.Format("", null, null); // Noncompliant, resolves to the first Format with params, but was that intended?
|
|
----
|
|
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Review this call, which partially matches an overload without "params". The partial match is "XXX".
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== on 1 Jul 2015, 17:56:50 Ann Campbell wrote:
|
|
Note that this spec has been mapped to R# rule PossiblyMistakenUseOfParamsMethod after discussion with [~tamas.vajk] because they attack the same problem from different ends, and because it's not clear what the message should be if it is the invocation that's marked Noncompliant, as with R#.
|
|
|
|
=== on 2 Jul 2015, 07:07:10 Tamas Vajk wrote:
|
|
\[~ann.campbell.2] I would put ``++params++`` somewhere in the description. Because we don't want to report on all method overloads.
|
|
|
|
=== on 2 Jul 2015, 12:59:34 Ann Campbell wrote:
|
|
LGTM [~tamas.vajk]
|
|
|
|
=== on 7 Jul 2015, 12:39:24 Ann Campbell wrote:
|
|
fix message
|
|
|
|
=== on 7 Jul 2015, 14:04:15 Ann Campbell wrote:
|
|
New case added [~tamas.vajk]. Double-check me, please
|
|
|
|
=== on 8 Jul 2015, 08:55:31 Tamas Vajk wrote:
|
|
\[~ann.campbell.2] Looks good
|
|
|
|
endif::env-github,rspecator-view[]
|