CLSCompliant attribut default value

142 Views Asked by At

When the attribute CLSCompliant is not set in AssemblyInfo, whats its default value (True or False)? If possible, please provide a link to some official source where it was defined.

I looked for for it in the microsoft manuals but i couldnt find the definition.

1

There are 1 best solutions below

1
Jon Skeet On BEST ANSWER

The documentation is fairly clear on this:

If no CLSCompliantAttribute is applied to a program element, then by default:

  • The assembly is not CLS-compliant.
  • The type is CLS-compliant only if its enclosing type or assembly is CLS-compliant.
  • The member of a type is CLS-compliant only if the type is CLS-compliant.

If an assembly is marked as CLS-compliant, any publicly exposed type in the assembly that is not CLS-compliant must be marked with CLSCompliantAttribute using a false argument. Similarly, if a class is marked as CLS-compliant, you must individually mark all members that are not CLS-compliant. All non-compliant members must provide corresponding CLS-compliant alternatives.

So basically, the absence of the attribute is equivalent to assembly:CLSCompliant(false).