The CLS (Common Language Specification) is a set of constraints on APIs and a complementary set of requirements on languages. If a library is CLS-compliant (i.e. adheres to all the constraints), then any CLS-compliant language can use that API. Conversely, a CLS-compliant language is guaranteed to be able to use any CLS-compliant library. (Int32 is an example of a CLS-compliant type, so CLS guarantees it's safe for library writers to use it in their APIs.)
Questions tagged [cls-compliant]
99 questions
10
votes
4 answers
C#: Nonzero-based arrays are not CLS-compliant
I am currently reading Albahari's C# 3.0 in a Nutshell and on pg. 241, whilst talking about Array indexing, he says this:
Nonzero-based arrays are not
CLS (Common Language Specification)-compliant
What does it mean exactly, for nonzero arrays…
Andreas Grech
- 98,643
- 98
- 284
- 354
10
votes
2 answers
Can an assembly that includes a non-CLS-compliant reference be CLS-compliant?
I have an existing DLL that is not CLS-compliant that I reference from my own project. When I mark my assembly as CLS-compliant, I get compiler warnings that names in the referenced assembly are not CLS-compliant.
Is there a way I can keep my…
ide
- 17,118
- 4
- 56
- 101
10
votes
3 answers
'Arrays as attribute arguments is not CLS-compliant' warning, but no type information given
When compiling my solution, I get several warnings of the following:
warning CS3016: Arrays as attribute arguments is not CLS-compliant
No other information on what type is not compliant is given. In my projects I have some attributes that take…
thecoop
- 42,842
- 15
- 122
- 181
9
votes
2 answers
ANTLR for C# and CLSCompliant attribute
I'm using ANTLR V3 to produce C# code for DSL language.
The produced code contain the attribute CLSCompliant on both laxer and parser classes which cause a warning to be generated because my project is not CLS compliant.
How can I make ANTLR…
Ido Ran
- 9,010
- 11
- 73
- 129
9
votes
3 answers
Any reason not to mark a DLL as CLSCompliant?
I am currently testing out Ndepend, and it gives me a warning that assemblies should be marked as CLSCompliant.
Our project is all C#, so it is not really needed.
What I am wondering is: are there any negative effects of marking a dll as…
Shiraz Bhaiji
- 60,773
- 31
- 133
- 239
9
votes
7 answers
Why does C# include programming constructs that are not CLS-compliant?
It seems strange that the flagship language of .NET would include programming constructs that are not CLS-compliant. Why is that?
Example (from here): Two or more public / protected / protected internal members defined with only case…
richard
- 10,572
- 20
- 83
- 144
8
votes
5 answers
Is it a good idea to compare double.MaxValue for equality?
Same question can be asked of float... or of MinValue.
I am thinking of using it as a special value. Will i see bugs due to precision? I don't expect to do arithmetic with these numbers, just set them and that's it.
Clarification: I am using this…
GregC
- 7,517
- 2
- 48
- 63
8
votes
1 answer
Why is this parameter not CLS-compliant?
I am trying to eliminate all the CLS-compliant errors that we have throughout out solution. While I have managed to sort out several (e.g. public variables beginning with an underscore and using unsigned integers), there are a few which I can't seem…
XN16
- 5,029
- 13
- 40
- 68
8
votes
1 answer
Why is my class not CLS-compliant?
This really baffles me. I've tried removing the readonly, changing names.. What am I doing wrong here?
public abstract class CatalogBase where T : class
{
protected readonly String DataPath;
protected readonly XmlSerializer Serializer;
…
Pavel Matuska
- 776
- 9
- 22
7
votes
2 answers
Disable CLS compliance checking in C#
I'm working on code that have the following attributes on some of its methods:
[CLSCompliantAttribute(false)]
How is it that when I build the code as is, I see that the compliance checking is being performed, and when I comment it out, it seems…
user429400
- 2,841
- 11
- 43
- 65
7
votes
2 answers
How can I disable CLS compliance checking using C#
How do I disable CLS compliance checking?
How can I do it for:
The entire assembly
A smaller scope, maybe one file or one class...
user429400
- 2,841
- 11
- 43
- 65
7
votes
1 answer
CIL, CLS, and CTS in .NET
What is the CIL, CTS, and CLS in .NET and what is the difference between them?
Domnic
- 3,397
- 9
- 32
- 59
7
votes
2 answers
Why is overloaded method differing in ref only CLS compliant
Common Language Specification is quite strict on method overloads.
Methods are allowed to be overloaded only based on the number and types of their parameters, and in the case of generic methods, the number of their generic parameters.
Why is this…
Marek Safar
- 600
- 3
- 8
6
votes
2 answers
CLS compliant attributes and array parameters
I have created an attribute that accepts a (params) array in its constructor.
internal class MyTestAttribute : Attribute
{
public MyTestAttribute (params Options[] options)
{
....
}
}
Option here is an enum (with lots of…
SWeko
- 28,824
- 9
- 68
- 102
6
votes
3 answers
Is there a tool for checking CLS compliance?
Is there a tool that can analyse my .NET code (C# and VB.NET) and tell me why things are not CLS Compliant?
Visual Studio is happy to tell me a parameter is not CLS compliant, but it doesn't get me any closer to fixing the problem as I don't know…
Pondidum
- 11,119
- 8
- 45
- 67