Saturday, March 3, 2018

Type of parameter is not CLS-compliant

So it's just another normal day, I am coding and coding and coding and suddenly this squiggly line shows up!
Oh no! The squiggly line of death you ask?? Not quite it's like a caterpillar and not much more than that really. It's not dreaded, deceitful or deadly. So I am pretty sure I won't die and neither would my laptop.


This squiggly line appeared below a function parameter. On closer inspection, as I hover my mouse over the caterpillar,  a message pops up saying that "Type of parameter 'someVariableName' is not CLS compliant. "
First time I have seen that error. Now if you'll want more details of the error you can find it here
In my specific case, this was caused because 'Unsigned types should not be part of the public interface of the class'. This particular function was being made public and the parameter in question was a enumerator type.
Which means ..... (drum roll)...........
Enums are stored as unsigned integers by default!
No, no they are not. Actually, here is the real reason why I got the compiler warning:
"The method was being publicly exposing from an assembly marked as CLS-Compliant a type that is from an assembly that is not CLS-Compliant.
This post on SO helped


No comments:

Post a Comment