rspec/rules/S4059/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

74 lines
1.2 KiB
Plaintext

== Why is this an issue?
Properties and Get method should have names that makes them clearly distinguishable.
This rule raises an issue when the name of a public or protected member starts with 'Get' and otherwise matches the name of a public or protected property.
=== Noncompliant code example
[source,csharp]
----
using System;
namespace MyLibrary
{
public class Foo
{
public DateTime Date
{
get { return DateTime.Today; }
}
public string GetDate() // Noncompliant
{
return this.Date.ToString();
}
}
}
----
=== Compliant solution
[source,csharp]
----
using System;
namespace MyLibrary
{
public class Foo
{
public DateTime Date
{
get { return DateTime.Today; }
}
public string GetDateAsString()
{
return this.Date.ToString();
}
}
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Change either the name of the property "XXX" or the name of the method "GetXXX" to make them distinguishable.
=== Highlighting
Primary: Property declaration
Secondary: Getxxx method
endif::env-github,rspecator-view[]