4

Is there any reason to mark a .NET Standard or a .NET Core library as CLS compliant?

As I understand it: If I build a .NET Framework library with C-sharp and make it totally CLS-compliant all the types/members can be used and called from a .NET Framework library or application written in VB-net, F-sharp etc. (don't know all the CLR-languages), referencing my library.

Is this not relevant anymore when using .NET Standard and .NET Core? What languages other than C-sharp can reference a .NET Standard library?

However, if there are several languages and you want to make the library CLS compliant, it will be hard because many of the .NET Standard types are not CLS compliant.

Some non CLS-compliant types:

  • Microsoft.Extensions.FileProviders.IFileProvider
  • Microsoft.Extensions.Logging.ILogger
  • Microsoft.Extensions.Logging.ILoggerFactory

There are issues about this on GitHub:

But as I understand it, there will be no change:

Ian Kemp
  • 28,293
  • 19
  • 112
  • 138
Hans Kindberg
  • 510
  • 5
  • 10

1 Answers1

-1

Whether you want to build CLS compliant libraries is up to you. We cannot decide that for you.

Please note that the analyzer only requires you to properly mark your assembly. It does not say whether it should be marked as compliant or not. It only says you should be explicit about whether it is compliant, that can be an explicit "no, it's not".

nvoigt
  • 75,013
  • 26
  • 93
  • 142
  • I understand what you mean. Maybe I expressed myself badly. What I mean is that it will be very hard to build CLS compliant assemblies (.NET Standard / .NET Core) when many types in those libraries are not CLS compliant. – Hans Kindberg Oct 11 '18 at 09:46
  • That's true. But again: we cannot decide if it's worth it for you. You seem to know the technical facts, you are way more qualified to decide whether your target audience needs it, it's your decision to make. – nvoigt Oct 11 '18 at 09:49
  • 1
    I have rephrased my question. As I understand I expressed it wrong. My question is not if I should but if there is any reason at all. – Hans Kindberg Oct 11 '18 at 10:24