Using the CLSCompliant attribute
I'm out of the office this week doing some .NET mentoring at a client's site. This sort of work always ends up evolving MM .NET since I get a chance to see how developers are using it in building real-world applications. One of the new features in MM .NET that will come from this visit is pick lists for Windows Forms...stay tuned for more information!
Did you know...
You can apply the CLSCompliant attribute on an assembly (or just about any other program element) and have the compiler check if your code is CLS (Common Language System) compliant (which means it works properly when consumed by other .NET languages). For example, we place the following attribute in all MM .NET AssemblyInfo.cs files:
Here are some of the things the compiler checks:
- Class and member names cannot differ only by case. For example, you can't have one property named Counter and another named counter. This is important for cross-language compatibility since VB .NET isn't case sensitive.
- Overloaded class methods cannot differ only by out or ref parameter designations.
- Publicly exposed members cannot start with an underscore ( _ ).
- Operators can't be overloaded
- Unsigned types can't be part of the public interface of a class
Unfortunately, although you can apply the CLSCompliant attribute in VB .NET, the VB .NET compiler doesn't check for CLS compliance.
Microsoft .NET/C# MVP