All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.plugins.csharp.S2306.html Maven / Gradle / Ivy

There is a newer version: 10.2.0.105762
Show newest version

Why is this an issue?

Since C# 5.0, async and await are contextual keywords. Contextual keywords do have a particular meaning in some contexts, but are not reserved and therefore can be used as variable names.

int await = 42; // Noncompliant, but compiles
int async = 42; // Noncompliant, but compiles

Keywords, on the other hand, are always reserved and therefore are not valid variable names.

int abstract = 42; // Error CS1585: Member modifier 'abstract' must precede the member type and name
int foreach = 42; // Error CS1519: Invalid token 'foreach' in class, struct, or interface member declaration

To avoid any confusion, it is best to not use async and await as identifiers.

int someVariableName = 42;
int someOtherVariableName = 42;

Resources

Documentation





© 2015 - 2024 Weber Informatics LLC | Privacy Policy