Questions tagged [cls-compliant]

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.)

103 questions
244
votes
17 answers

A definitive guide to API-breaking changes in .NET

I would like to gather as much information as possible regarding API versioning in .NET/CLR, and specifically how API changes do or do not break client applications. First, let's define some terms: API change - a change in the publicly visible…
Pavel Minaev
  • 99,783
  • 25
  • 219
  • 289
194
votes
5 answers

What is the 'CLSCompliant' attribute in .NET?

What is the CLSCompliant attribute?
Praveen Sharma
  • 4,511
  • 7
  • 27
  • 17
123
votes
4 answers

Why are unsigned int's not CLS compliant?

Why are unsigned integers not CLS compliant? I am starting to think the type specification is just for performance and not for correctness.
doekman
  • 18,750
  • 20
  • 65
  • 86
78
votes
4 answers

Why should I write CLS compliant code?

I've found a lot of pages about CLS compliance. I've understood that CLS compliance: Is a way to guarantee different assembly compatibility. Is a way to declare the high security code Many peolple write that "if you write code, you should write it…
Luca
  • 11,646
  • 11
  • 70
  • 125
56
votes
8 answers

Why is this name with an underscore not CLS Compliant?

Why do I get the compiler warning Identifier 'Logic.DomainObjectBase._isNew' is not CLS-compliant for the following code? public abstract class DomainObjectBase { protected bool _isNew; }
MatthewMartin
  • 32,326
  • 33
  • 105
  • 164
42
votes
4 answers

Base type is not CLS-compliant, what reasons of this warning?

I have got warning from subject on one of my classes. Actually class is very simple, just an inheritor of my generic base type. Also I have some other inheritors from that generic class across the solution, and there are no such warnings. What could…
DarkDeny
  • 1,750
  • 2
  • 21
  • 31
32
votes
2 answers

Setting CLS compliance for a .NET assembly

Setting CLS compliance for an entire .NET assembly is possible. But how is it actually done? E.g. with Visual Studio 2008?
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
31
votes
3 answers

Is the new feature of C# 4.0 - "Optional Parameters" CLS-Compliant?

This new feature is really convenient. Lately I read the document of the "Microsoft All-In-One Code Framework", and it mentions that "Optional Parameters" is not CLS-Compliant. So I tested it by using "Optional Parameters" in a public API, and…
Cui Pengfei 崔鹏飞
  • 8,017
  • 6
  • 46
  • 87
29
votes
3 answers

CLSCompliant(true) drags in unused references

Can anyone explain the following behavior? In summary, if you create multiple CLS compliant libraries in Visual Studio 2008 and have them share a common namespace root, a library referencing another library will require references to that library's…
Mark Seemann
  • 225,310
  • 48
  • 427
  • 736
20
votes
1 answer

How to mark .NET Standard code as CLS-compliant?

The title says it all - how do I flag a .NET standard library as CLS-compliant? I wrote a simple library in C# targeting .NET Standard 1.0 framework. It includes two enums: public enum Alignments { Left, Center, Right } public enum Actions { None,…
Quango
  • 12,338
  • 6
  • 48
  • 83
17
votes
2 answers

CA1014 Mark 'some.dll' with CLSCompliant(true) error message with StyleCop of VS2010

When I run StyleCop, I got this error message saying that I need to Mark the dll with CLSCompliant(true). What is this? How can I set the Mark the dll with CLSCompliant(true)? Error 4 CA1014 : Microsoft.Design : Mark 'SOMETHING.dll' with…
prosseek
  • 182,215
  • 215
  • 566
  • 871
15
votes
1 answer

Why is my function not CLS-compliant?

I'm getting the following warning message... Return type of function 'ConnectionNew' is not CLS-compliant. ...for this function: Public Function ConnectionNew(ByVal DataBaseName As String) As MySqlConnection Dim connection As…
Urbycoz
  • 7,247
  • 20
  • 70
  • 108
13
votes
2 answers

What are the consequences of NON-CLS Compliant code in .NET?

I have a couple of nagging compiler warnings for an app that I ported from VB6 a while back regarding CLS-Compliance including: Name '_AnIdentifier' is not CLS-Compliant. Type of parameter 'myType' is not CLS-Compliant. Despite this, my app seems…
JohnFx
  • 34,542
  • 18
  • 104
  • 162
12
votes
3 answers

Why does Stream.Write not take a UInt?

It seems highly illogical to me that Stream.Write uses int, instead of UInt... Is there an explanation other than "legacy" code for this fact? Would any one want to write -1 bytes?!?
Leonardo
  • 10,737
  • 10
  • 62
  • 155
11
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
  • 105,982
  • 98
  • 297
  • 360
1
2 3 4 5 6 7