CLSCompliant not set?

Jul 30, 2010 at 3:48 PM


I was wondering if there is a specific reason why the assemblies haven't gotten a CLSCompliant attribute set to true at the assembly level. It seems like a no-brainer to me to have this set at all times, IMHO it should be set to true by default in any AssemblyInfo.cs file already from the template. Tools like FxCop will start nagging about this setting right away.

If there is a compelling reason however I would understand. But otherwise the settings ought to be there. Any class, interface or otherwise that would not be CLSCompliant should be marked as such, but at the assembly level I'ld expect the settings to enclose the CLSCompliant(true) setting.

Meile Zetstra

Jul 30, 2010 at 4:19 PM

Hi Meile

Since CCI is targetted towards a small set of advanced developers, we early on made the decision not to limit the CCI API to the Common Language Subset, but to use the full power of C# as appropriate. It did not seem worthwhile to individually call out every method in the API that does not belong to the CLS.

Until now this has been a non issue. I'd be interested to know how this became an issue for you and which scenarios will work better if we had an explicit list of API calls that do not fit into the CLS.



Jul 31, 2010 at 7:02 PM

Hi Herman,

Thanks for the clarification. It's not so much an issue to me. It was more something I was wondering about. Suppose I would be making some sort of application which I would like to be CLS compliant, and that would internally use the CCI, how would I g about that then? Would it be worthwile for me to go through all the API that touch on the CCI and mark them as being non CLSCompliant? Or would it just be a better choice to just skip the CLSCompliant part at all?

Just a thought, as I have some idea's to build an application that would use the CCI, and also offer an option for extensibility through the Microsoft Extensibility Framework. Would it be wise to go for a CLSCompliant app and libraries in that case or not? I'm not sure yet whether I would expose CCI to the outside world, as seen from the applications point of view.

Meile Zetstra

Aug 2, 2010 at 7:00 AM

If you are going to use CCI only as an implementation detail, then it really doesn't matter whether or not it is CLS compliant. If you are going to expose CCI types in you API, for example as part of your extensibility interfaces, then you have to make a choice on whether you are going to target the CLS or not. If you are going to target it, then it might be helpful to have the CCI types annotated (probably implicitly) as being CLS compliant (in those cases where they actually are CLS compliant.

However, CLS compliance might not be worth it. If all of your clients are using C# to write their extensions, then they will not be affected by any APIs that are not CLS compliant. This really only becomes a problem if you want to allow your clients to use languages that do not support things like unsigned types.

Aug 2, 2010 at 7:08 AM

Thanks for the additional comments. It makes things clear to me now.