tags:

views:

216

answers:

3

I was wondering which edge cases exist that could make Common Language Specification compliance acceptable. Even when not intending to be accessed from other languages, I think that the tenets asserted by the CLSCompliantAttribute are good best practices.

Do you have encountered / know of cases where YAGNI outweighs the best practices?

+3  A: 

I think it's acceptable for library internal to a product when working with legacy layers that require that kind of features or for performance reasons.

But these non conformant interface should then be reencapsulated at a higher level.

Think Before Coding
I agree. As long as the library is for internal use and you have control of its usage this should not be a problem.
Rune Grimstad
+3  A: 

Well, "params" arrays on attributes are sometimes just so tempting (but non-compliant). But I'd recommend using CLS-compliant approaches whenever possible.

Marc Gravell
+2  A: 

"[sic] what use is there for being CLS compliant?"

Medium Trust, ClickOnce, running from a shared network drive, guest profiles in a domain setting, etc. There are lots of security situations where your code cannot run if you break the CLS Compliance.

Have personally seen a lot of situations where users are trying to run their app from a shared network drive and can't because the local admin has killed non CLS compliant apps in the security profile.

In general there are usually ways to work around the issue anyway. I would take the opposite approach to the comments above, why break it? You are writing managed code, why would you want to limit your application on purpose?

I would say that if you are building an API assembly, or component you should always adhere to them. Too many third party components take the easy way out and just flag them as broken when attempting to run from Medium Trust. In some cases this is the only reason they can't run. If they had taken a little more time to adhere to the guidelines users would not be limited as to how they can use their component.

Jason Short