Radek Micek
Radek Micek

Reputation: 457

.NET Capitalization Rules for Identifiers and property System.Text.Encoding.UTF8

Why is the name of the property System.Text.Encoding.UTF8 all uppercase? According to Capitalization Rules for Identifiers and the fact that UTF is an acronym longer than 2 characters the property should be named System.Text.Encoding.Utf8 or am I wrong?

Upvotes: 1

Views: 131

Answers (1)

Jeroen Mostert
Jeroen Mostert

Reputation: 28789

It's all uppercase because it was authored that way.

The design and implementation of .NET 1.0 (and Encoding.UTF8 goes all the way back to there) well precedes the Framework Design Guidelines in their current form, let alone their enforcement. As a result, you can find plenty of violations in the framework of those guidelines. A small sample:

  • System.Security.Cryptography.RNGCryptoServiceProvider (and plenty of other classes in System.Security.Cryptography)
  • System.Text.ASCIIEncoding
  • System.Runtime.InteropServices.COMException

And a systematic search would probably show up many more.

This isn't as silly as it looks: the whole reason people come up with guidelines in the first place is because they notice inconsistencies like this, and then sit down and come up with a set of rules that best reflects current practices. Going back to change capitalization on current classes (and breaking existing software in the process) isn't worth it, however.

Upvotes: 1

Related Questions