-2

How do I find all the non CLS-compliant statements in my .NET code?

Can Visual Studio 2015 compiler do it? How do I find non CLS-compliant warnings?

I've checked StyleCop ReSharper extension and ndepend without success.

What I am after is to find all the non CLS-compliant statements in my C# code Visual Studio project. The final goal is to add the [assembly: CLSCompliant(true)] tag to it.

Thanks.

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
abenci
  • 8,422
  • 19
  • 69
  • 134
  • 1
    Using `[assembly: CLSCompliant(true)]` would make the c# compiler to show warnings on not CLS-compliant code. So what else do you need? – Pikoh Feb 15 '17 at 10:31
  • I've many warnings and don't know how to identify the CLS-compliant ones. – abenci Feb 15 '17 at 10:34
  • Well, they are (i think all of them) in the `CS3000` range – Pikoh Feb 15 '17 at 10:45
  • I didn't have the Code column visible in my Error List window. Now I can see them and sort by Code, many `CS3000` warning appeared. Thanks so much, please add and answer so I can mark the post answered. – abenci Feb 15 '17 at 10:49
  • Glad it helped Alberto – Pikoh Feb 15 '17 at 10:53

2 Answers2

1

Using [assembly: CLSCompliant(true)] would make the c# compiler to show warnings on not CLS-compliant code. The code for CLSCompliant warnings is usually in the CS3000 range, so you can order by code to check all of them.

Pikoh
  • 7,582
  • 28
  • 53
0

For VB.NET use this:

<Assembly: CLSCompliant(True)>

Also, don't forget to Build-Clean Solution and Build-Rebuild Solution after adding the above to the AssemblyInfo.vb file.

ajr
  • 73
  • 1
  • 9
  • I'd like to think that a VB.NET developer, particularly one cognizant of CLS compliance issues, would know how to perform the minimal transformation from the accepted C# answer to their own language. – Lance U. Matthews Dec 02 '19 at 19:32
  • @BACON - Why not make it easy? – ajr Dec 02 '19 at 20:17
  • I've seen the "Why not make it easy?" argument made on these C#-to-VB.NET translation answers before, or even answers that just take another answer and repackage it as an extension method. The point is that this is derivative of and barely different than another answer, which I don't think justifies bumping a nearly three-year-old question to the top of the front page. If the code was wildly different between the two languages you'd certainly have a case, but here the only difference is the type of brackets used; I know VB.NET will accept a lowercase `true` and maybe even the `assembly:`, too. – Lance U. Matthews Dec 02 '19 at 21:02