rspec/rules/S1669/csharp/rule.adoc

33 lines
896 B
Plaintext

The ability to target the common language runtime from several languages means that clashes are possible when a word that is reserved in one language is used as the name of a namespace, type or member in another.
This rule raises an issue when a keyword from {cpp}/CLI, C# or Visual Basic is used as an identifier.
== Noncompliant Code Example
----
public string nameof(string s) { return s; } // Noncompliant
...
public string Hello { get { return "World!"; } }
...
Console.WriteLine(nameof(Hello)); // prints "World!" instead of "Hello" as expected
----
== Compliant Solution
----
public string GetValue(string s) { return s; }
...
public string Hello { get { return "World!"; } }
...
Console.WriteLine(GetValue(Hello));
----
ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]