Fixing “CS891: The Type Name Only Contains Lower-Cased ASCII Characters”

If you’ve been an early adopter of .NET 7, you may have come across the following error in your travels when compiling an existing .NET 6 project :

Warning CS8981: The type name only contains lower-cased ascii characters. Such names may become reserved for the language.

While the warning is somewhat descriptive, it doesn’t really go into depth about why it’s showing. Especially when in .NET 6 the code compiled just fine!

Let’s look at a dead simple example of why this warning has been added.

Let’s imagine you are writing C# code many years ago in .NET 2.0, and you have code that looks like so :

class async {

At this time, async/await did not exist in .NET and you would have been fine to create a class named using either of those keywords, even if they didn’t necessarily confine to your traditional PascalCase naming standards.

Our rolls C# 5 and with it, the async/await keywords. Now we have issues because your own class has a naming clash. Ugh!

Remembering that Microsoft is on a roll with yearly releases of .NET/C#, it stands to reason that they may add additional reserved keywords in the future of C#, but until that time, Microsoft obviously can’t reserve every possible combination of keywords they might need in the future.

With all of that in mind, Microsoft have instead called out the fact that all reserved keywords are completely lowercase, if you avoid naming conventions that avoid naming everything in lowercase, then you can be sure in the future there will be no clash. Remembering that C# itself is case sensitive!

Again, this is only a warning, and you can choose to ignore it, but do so at your own peril.

Leave a Comment