views:

34

answers:

2

Hi,

I want to disbale CLS complaiance checking. I'm new in C#, so can you please tell me how to do it for:

  1. The entire assembly
  2. smaller scope, maybe one file or one class...

Thanks, Li

+2  A: 

You could use the [CLSCompliant(false)] attribute.

Quote from the doc:

You can apply the CLSCompliantAttribute attribute to the following program elements: assembly, module, class, struct, enum, constructor, method, property, field, event, interface, delegate, parameter, and return value. However, the notion of CLS compliance is only meaningful for assemblies, modules, types, and members of types, not parts of a member signature. Consequently, CLSCompliantAttribute is ignored when applied to parameter or return value program elements.

There's also possibility to supress compiler warnings.

Darin Dimitrov
+2  A: 

You can use the CLSCompliant attribute to explicitly mark an assembly or type, e.g.

for an assembly add the following line in AssemblyInfo.cs

[assembly:CLSCompliant("false")]

for a class

[CLSCompliant("false")]
public class Foo
{
}

You can also use it for specific type members (methods, properties, etc.) in a similar manner.

AdamRalph