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
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,457
  • 8
  • 50
  • 69
5
votes
2 answers

Reference Name case is not CLS Compliant

I have a .NET 3.5 C# project that has a namespace of SampleNamespace.Tools.Sample. If I add an assembly called "Samplenamespace.Utils.Example" to my project I get the following warning: Identifier 'Samplenamespace' differing only in case is not…
user115909
  • 51
  • 1
  • 2
5
votes
4 answers

What C# naming scheme can be used for Property & Member that is CLS compliant?

Consider the following code that is not CLS Compliant (differs only in case): protected String username; public String Username { get { return username;} set { username = value; } } So i changed it to: protected String _username; public String…
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
5
votes
1 answer

CS3016 - How do we get around this when working with Prism + MEF ExportModule?

[assembly: CLSCompliant(true)] //CS3016: Arrays as attribute arguments is not CLS-compliant. [ModuleExport(typeof(ModuleA), DependsOnModuleNames = new [] { "ModuleB" })] public class ModuleA : IModule { } The only thing I can think of is to mark…
myermian
  • 31,823
  • 24
  • 123
  • 215
5
votes
1 answer

Looking for the exact list of possible MethodAttributes.SpecialName

I am aware of ctor, cctor, property/indexer prefix: get_, set_, event management prefix: add_, remove_. I have seen a raise_ prefix once or twice (do not remember where). Does a definitive list exists at the .Net level (ECMA spec.)? If yes where is…
Spi
  • 686
  • 3
  • 18
5
votes
2 answers

Cleaning up C# compiler warning CS3016: Arrays as attribute arguments is not CLS-compliant

Possible Duplicate: ‘Arrays as attribute arguments is not CLS-compliant’ warning, but no type information given I have some code, which generates this warning in several places. I want to fix them, but I do not know where they are because the C#…
mark
  • 59,016
  • 79
  • 296
  • 580
4
votes
1 answer

Is there any reason to mark a .NET Standard or a .NET Core library as CLS compliant

Is there any reason to mark a .NET Standard or a .NET Core library as CLS compliant? As I understand it: If I build a .NET Framework library with C-sharp and make it totally CLS-compliant all the types/members can be used and called from a .NET…
Hans Kindberg
  • 510
  • 5
  • 10
4
votes
1 answer

How to use CallerMemberName in a CLS compliant assembly

I have used the CallerMemberName attribute in a class's implementation of INotifyPropertyChanged as described on MSDN as follows: public event PropertyChangedEventHandler PropertyChanged; // This method is called by the Set accessor of each…
Toby
  • 9,696
  • 16
  • 68
  • 132
4
votes
1 answer

Why isn't this CLS compatible?

I have the following Interfaces: public interface ITemplateItem { int Id { get; set; } String Name { get; set; } String Text { get; set; } int CategoryId { get; set; } int Typ { get; set; } } public interface…
Jürgen Steinblock
  • 30,746
  • 24
  • 119
  • 189
3
votes
1 answer

Is warning CS3006 valid in this case?

The code below generates a warning CS3006 "Overloaded method MyNamespace.Sample.MyMethod(int[])' differing only in ref or out, or in array rank, is not CLS-compliant". Is this warning valid, i.e. is this genuinely not CLS-compliant? I'd have…
Joe
  • 122,218
  • 32
  • 205
  • 338
3
votes
3 answers

Why are my identifiers marked as not CLS-compliant?

I have a some class, which contains three fields: protected bool _isRunning = false; protected readonly ParameterCollection _parameters = null; protected readonly ParameterCollection _defaultParameters = null; The assembly it is in is marked as…
Tadeusz
  • 6,453
  • 9
  • 40
  • 58
3
votes
3 answers

Understanding CLS compliance and correct code

I've attempted to create an abstracted control to manage some of the state in our application. However, I have run a foul of some CLS issues and was hoping that someone could provide some insight. I have an enumeration as such: _ Public…
Gavin Miller
  • 43,168
  • 21
  • 122
  • 188
3
votes
2 answers

CLS-compliant alternative for ulong property

Background I am writing a managed x64 assembler (which is also a library), so it has multiple classes which define an unsigned 64-bit integer property for use as addresses and offsets. Some are file offsets, others are absolute addresses (relative…
Daniel A.A. Pelsmaeker
  • 47,471
  • 20
  • 111
  • 157
3
votes
3 answers

How to hide Non-CLS compliant code from projects using other languages?

This question is more out of curiosity than a project requirement or a problem. I have a Non-CLS compliant code in one language (say C#), and I need to use it like that only in my current language (across projects, so making internal is not a…
Manish Basantani
  • 16,931
  • 22
  • 71
  • 103
3
votes
1 answer

Why is my MEF usage not CLS-compliant?

When I compile my Silverlight application, all of the elements that are decorated with MEF attributes are warning of CLS-noncompliance. When I compile again, the warnings do not return, and my application seems to run fine. Is this something that I…
Jordan
  • 9,642
  • 10
  • 71
  • 141