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

99 questions
233
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
  • 94,882
  • 25
  • 209
  • 280
180
votes
5 answers

What is the 'CLSCompliant' attribute in .NET?

What is the CLSCompliant attribute?
Praveen Sharma
  • 4,291
  • 7
  • 24
  • 17
116
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
  • 17,528
  • 19
  • 61
  • 80
72
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
  • 10,886
  • 10
  • 64
  • 120
55
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
  • 29,993
  • 30
  • 102
  • 160
39
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,702
  • 2
  • 21
  • 31
31
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
  • 28,342
  • 21
  • 95
  • 123
30
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 崔鹏飞
  • 7,124
  • 4
  • 38
  • 79
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
  • 209,566
  • 41
  • 390
  • 671
15
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
  • 9,088
  • 5
  • 38
  • 72
14
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
  • 6,422
  • 19
  • 61
  • 99
13
votes
1 answer

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
  • 155,475
  • 189
  • 518
  • 818
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
  • 33,720
  • 18
  • 99
  • 158
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
  • 8,477
  • 8
  • 47
  • 119
11
votes
2 answers

Why is my code not CLS-compliant?

I've got errors when I build my project: Warning as Error: Type of 'OthersAddresses.AddresseTypeParameter' is not CLS-compliant C:...\Units\OthersAddresses.ascx.cs public Address.AddressTypeEnum AddressTypeParameter { get …
Evilduky
  • 131
  • 1
  • 2
  • 8
1
2 3 4 5 6 7