rspec/rules/S1669/csharp/rule.adoc

25 lines
735 B
Plaintext
Raw Normal View History

2020-06-30 12:47:33 +02:00
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.
2021-02-02 15:02:10 +01:00
2021-01-26 14:30:57 +01:00
This rule raises an issue when a keyword from {cpp}/CLI, C# or Visual Basic is used as an identifier.
2020-06-30 12:47:33 +02:00
== 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));
----