rspec/rules/S927/csharp/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
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.
2023-05-25 14:18:12 +02:00

121 lines
2.5 KiB
Plaintext

== Why is this an issue?
The name of a parameter in an externally visible. This rule raises an issue when method override does not match the name of the parameter in the base declaration of the method, or the name of the parameter in the interface declaration of the method or the name of any other ``++partial++`` definition.
=== Noncompliant code example
[source,csharp]
----
partial class Point
{
partial void MoveVertically(int z);
}
partial class Point
{
int x = 0;
int y = 0;
int z = 0;
partial void MoveVertically(int y) // Noncompliant
{
this.y = y;
}
}
interface IFoo
{
void Bar(int i);
}
class Foo : IFoo
{
void Bar(int z) // Noncompliant, parameter name should be i
{
}
}
----
=== Compliant solution
[source,csharp]
----
partial class Point
{
partial void MoveVertically(int z);
}
partial class Point
{
int x = 0;
int y = 0;
int z = 0;
partial void MoveVertically(int z)
{
this.z = z;
}
}
interface IFoo
{
void Bar(int i);
}
class Foo : IFoo
{
void Bar(int i)
{
}
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
'''
== Comments And Links
(visible only on this page)
=== on 13 May 2015, 19:41:54 Ann Campbell wrote:
\[~tamas.vajk], please provide R# id if one exists
=== on 13 May 2015, 19:42:01 Ann Campbell wrote:
consulted \https://msdn.microsoft.com/en-us/library/vstudio/6b0scde8%28v=vs.110%29.aspx
=== on 13 May 2015, 19:42:23 Ann Campbell wrote:
\[~evgeny.mandrikov] note that this seemed familiar to me, but I couldn't find a relevant C-Family rule.
=== on 13 May 2015, 21:03:05 Evgeny Mandrikov wrote:
\[~ann.campbell.2] I suppose that you have in mind RSPEC-927
=== on 14 May 2015, 11:12:14 Ann Campbell wrote:
Thanks [~evgeny.mandrikov]
=== on 22 May 2015, 09:44:25 Tamas Vajk wrote:
Could you run through it one more time? There were minor modifications in the sample code.
=== on 22 May 2015, 12:14:06 Ann Campbell wrote:
\[~tamas.vajk] I'm not sure why you swapped the parameter order. I feel like reversing the names is a better illustration of the confusion that could result in param names that don't match...?
=== on 22 May 2015, 12:48:42 Tamas Vajk wrote:
\[~ann.campbell.2] I changed it because ``++yk++`` was not used in the method body, so it already just looked like a typo.
I've changed the sample code.
=== on 22 May 2015, 14:35:14 Ann Campbell wrote:
Thanks [~tamas.vajk]. Looks good
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]