Solarion
Honorary Master
- Joined
- Nov 14, 2012
- Messages
- 21,885
I am working through C# 6.0 and the .NET 4.6 Framework and I came across this topic. Thought it might be of some interest to you guys.
Full Article
If you are writing .Net classes, which will be used by other .Net classes irrespective of the language they are implemented, then your code should conform to the CLS [Common Language Specification]. This means that your class should only expose features that are common across all .Net languages. The following are the basic rules that should be followed when writing a CLS complaint C# code.
1. Unsigned types should not be part of the public interface of the class. What this means is public fields should not have unsigned types like uint or ulong, public methods should not return unsigned types, parameters passed to public function should not have unsigned types. However unsigned types can be part of private members.
2. Unsafe types like pointers should not be used with public members. However they can be used with private members.
3. Class names and member names should not differ only based on their case. For example we cannot have two methods named MyMethod and MYMETHOD.
4. Only properties and methods may be overloaded, Operators should not be overloaded.
The above-mentioned rules should be followed only for the types and member that are publicly exposed by your program. Private classes, private methods and local variables need to follow the rules.
Full Article