0

I recently started a new job with a new code base, and much to my horror the first time I compiled the new code I discovered that there were more than 1200 warnings present in the compiler output. Previously, I was working on medical device software, where we were not permitted to have any warnings at all (compiled with /werr) so these warnings are disgusting and uncomfortable to me.

In my experience, warnings often indicate potential bugs, or at least code that doesn't actually do what it looks like it should do after a cursory glance, plus with this many warnings it is hard to spot new ones that crop up while we are developing.

I'm currently working on a report that I hope to use to convince the project manager that spending time to fix these warnings is worth our effort. As a part of this I have been assigning a "danger value" (between 1 and 10) to each different CS level warning code. I have no experience with the warnings regarding CLS Non-Compliance though, so I'm not sure how I should classify them.

Can anyone explain how dangerous the CLS Non-Compliance warnings are?

Catachan
  • 190
  • 2
  • 12
  • If you are only using C#, then there is no big problem. The problems would arise if you are supplying assemblies to be consumed by other languages. As an example, if you declare a `uint` parameter type, then Visual Basic won't be able to use it properly. – Matthew Watson Sep 19 '19 at 13:33
  • I would consider rewording a bit your question to ask fot the impact/consecuences of CLS Non-Compilance. That way you will avoid "too broad" flags. That being said, it is an interesting question. – Cleptus Sep 19 '19 at 13:35
  • 1
    If the assembly is not intended to be consumed from other .NET languages, adding an `[assembly: CLSCompliant(false)]` explicitly marks it as non-compliant and will remove the warnings. Of course, this may mean interop issues if it *is* intended to be consumed from other languages. – Jeroen Mostert Sep 19 '19 at 13:35
  • @JeroenMostert And that would lead in the big question. Does the company allow mixed languages codebase? If they some API's in `c#` and others in `vb.net`, then those warning should have a nice severity in your 1-10 point system. – Cleptus Sep 19 '19 at 13:47
  • It was important in the previous decade, back when there was still a realistic chance that somebody might use VB.NET or JScript to use your library. But the VB.NET restrictions were removed in 2005 and JScript is dead. The odds that somebody uses Java are pretty low, IKVM is not that popular. Just ask somebody that's been around for a while. Well, it is not compliant so you don't really have to ask :) – Hans Passant Sep 19 '19 at 13:54
  • @Hans Passant, I believe the intent is for some of these libraries that have the warnings to be used with Angular code in the future, but I'm not entirely sure. Also, some of the other projects at the company are using VB.NET. – Catachan Sep 19 '19 at 13:57
  • I'm not sure either. Ask your supervisor. The odds that they want you to fix 1200 problems right now are not that high, those fixes are going to break somebody else's code. – Hans Passant Sep 19 '19 at 14:06
  • 1
    you can always use flowers, you know https://imgur.com/a/GSNk0ZX /s – mcy Sep 19 '19 at 14:50

0 Answers0