C# Naming – Namespaces with Version Suffix in C#

cnamespacenamingnetversioning

In official Microsoft docs:

✓ DO use a stable, version-independent product name at the second
level of a namespace name.

But in Reference Source, the following namespaces ends with Version:

Microsoft.Build.Tasks.v4.0
Microsoft.Build.Utilities.v4.0
Microsoft.Build.Utilities.v3.5

So is Microsoft violating its own guidelines? Is it good idea to add version suffix to API/SDK namespace?

Best Answer

When the documents mention second-level, they're referring to the section of the namespace indicated as (<Product>|<Technology>). The product or technology should be version independent.

So no, technically Microsoft isn't violating its own guidelines, however admittedly using versions in namespaces is probably not a great idea. The proper way to update your library is to deprecate methods and classes which will not be available in the next release of the library, with a clear reference to a replacement to be used instead in the documentation and/or in the code itself as a comment.