Home

CLScompliant

CLScompliant refers to adherence to the Common Language Specification (CLS) within the .NET framework. The CLS defines a set of rules intended to ensure that public APIs are usable from any language that targets the .NET platform. When code is CLS-compliant, its public surface can be consumed reliably by languages such as C#, VB.NET, and F#.

In .NET, compliance is indicated by the CLSCompliantAttribute in the System namespace. An assembly can declare

Common sources of non-compliance include exposing unsigned integral types (for example, uint or ulong) in public

CLS conformance affects only public and protected surfaces; private implementation details may freely use non-CLS constructs.

itself
CLS-compliant
by
applying
[assembly:
CLSCompliant(true)].
Individual
types
or
members
can
override
this
with
[CLSCompliant(false)].
If
an
assembly
is
declared
CLS-compliant,
the
compiler
will
warn
about
public
members
that
are
not;
developers
can
then
mark
those
members
as
non-compliant
to
suppress
warnings.
parameters
or
return
types,
since
not
all
CLS
languages
guarantee
support
for
unsigned
types.
Other
issues
can
arise
from
language-specific
features
or
identifiers
that
behave
differently
across
languages.
Non-compliant
members
should
be
annotated
with
[CLSCompliant(false)]
to
indicate
their
exclusion
from
the
CLS
surface.
Achieving
CLS
compliance
promotes
interoperability
across
.NET
languages,
but
it
does
not
guarantee
identical
semantics
or
portability
to
non-.NET
runtimes.
Tools
and
compilers
can
emit
warnings
to
help
enforce
compliance,
aiding
library
authors
who
aim
for
broad
language
compatibility.
See
also
the
Common
Language
Specification
and
the
System.CLSCompliantAttribute
type
for
more
details.