6

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 the cause.

Example Visual Studio error:

Parameter 'xyz' is not CLS-Compliant

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Pondidum
  • 11,457
  • 8
  • 50
  • 69

3 Answers3

4

I can't say I know of a tool, and I tend to use the MSDN page Language Independence and Language-Independent Components to check if the type of the parameter/variable is CLS compliant. See the section of the table named 'Types'.

There was also a fair bit of discussion about this some time ago in the blog post FxCop and CLS Compliance.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Kev
  • 118,037
  • 53
  • 300
  • 385
1

From memory it's not too hard to do. I'm not aware of a tool, but this page here describes what you need to change.

The big ones are using type specific structs (think uint32 instead of uint) and using an "_" in your public members.

Spence
  • 28,526
  • 15
  • 68
  • 103
0

Preemptive rebuttal: to my knowledge, FxCop does not support CLS compliance checks. Perhaps code analysis in VS does but I cannot check at work.

You could just google the warning message you get.

Kent Boogaart
  • 175,602
  • 35
  • 392
  • 393