Violation of CLS rule C# with Example



Violation of CLS rule C# with Example

using System; 
[assembly:CLSCompliant(true)] 
namespace CLSDoc 
{ 
public class Car 
{ 
internal UInt16 _yearOfCreation = 0; 
//Warning CS3008 Identifier '_numberOfDoors' is not CLS-compliant 
//Warning CS3003 Type of 'Car._numberOfDoors' is not CLS-compliant 
public UInt32 _numberOfDoors = 0; 
 

//Warning CS3003 Type of 'Car.YearOfCreation' is not CLS-compliant 
public UInt16 YearOfCreation 
{ 
get { return _yearOfCreation; } 
} 
//Warning CS3002 Return  type  of  'Car.CalculateDistance()'  is  not  CLS-compliant 
public UInt64 CalculateDistance() 
{ 
return 0; 
} 
//Warning CS3002 Return type of 'Car.TestDummyUnsignedPointerMethod()' is not CLS-compliant 
public UIntPtr TestDummyUnsignedPointerMethod() 
{ 
int[] arr = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; 
UIntPtr ptr = (UIntPtr)arr[0]; 
return ptr; 
} 
//Warning CS3003 Type of 'Car.age' is not CLS-compliant 
public sbyte age = 120; 
} 
} 

0 Comment's

Comment Form