The SLAR on System.CLSCompliantAttribute

In honor of generics getting into the CLS, I thought I’d get back to the series sharing some of the information in the .NET Framework Standard Library Annotated Reference Vol 1 here is an annotation from the System.CLSCompliantAttribute class.


Brad Abrams:  Unfortunately, we codified the naming convention for acronyms too late to

fix this one. It should have been ClsCompliantAttribute rather than CLSCompliantAttribute.

Notice that this attribute is just a marker intended for compilers to enforce. The runtime

does not enforce any CLS-compliance rules.


Jeffrey Richter: Note that the CLS only applies to publicly exposed members so compilers generally

only check CLS-compliance of types and members that are exposed outside of an assembly.

Internal types and private methods, for example, are not checked for CLS compliance.


Some sample code:

using System;

[assembly: CLSCompliant(true)]


namespace Samples


    public class CLSCompliantSample


        public static void Main()



        public static uint Method1(uint i)


            return i;






The compiler output is:

Microsoft (R) Program Maintenance Utility Version 7.00.9466

Copyright (C) Microsoft Corporation. All rights reserved.

csc /debug CLSCompliantAttribute.cs

Microsoft (R) Visual C# .NET Compiler version 7.00.9466

for Microsoft (R) .NET Framework version 1.0.3705

Copyright (C) Microsoft Corporation 2001. All rights reserved.

CLSCompliantAttribute.cs(12,32): error CS3001: Argument type ‘uint’ is not


CLSCompliantAttribute.cs(12,19): error CS3002: Return type of

‘Samples.CLSCompliantSample.Method1(uint)’ is not CLS-compliant

NMAKE : fatal error U1077: ‘csc’ : return code ‘0x1’



Comments (3)

  1. name says:

    The runtime does [not] enforce

  2. Yup, thanks.. i will fix that.

  3. Anonymous says:

    Why doesn’t the CLSCompliantAttribute allow a version parameter ? Surely if the CLS specifications evolve like they have, and we have different meaning of compliance for 1.n versus 2.0, then the attribute should allow which specification to be indicated.