51 lines
1.4 KiB
Plaintext
Raw Permalink Normal View History

== Why is this an issue?
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
2020-06-30 12:47:33 +02:00
2022-02-04 17:28:24 +01:00
[source,csharp]
2020-06-30 12:47:33 +02:00
----
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
2020-06-30 12:47:33 +02:00
2022-02-04 17:28:24 +01:00
[source,csharp]
2020-06-30 12:47:33 +02:00
----
public string GetValue(string s) { return s; }
...
public string Hello { get { return "World!"; } }
...
Console.WriteLine(GetValue(Hello));
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
'''
== Comments And Links
(visible only on this page)
=== on 1 Mar 2017, 15:50:46 Valeri Hristov wrote:
It seems that not all C#/VB/{cpp} keywords are reported by this rule and there is no list of the keywords FxCop matches.
We are postponing the development of this rule because of its small target audience (it is best suited for library developers, who's products will be used in different languages).
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]