开发者

How does the BCL relate to the CLS?

开发者 https://www.devze.com 2023-02-18 23:19 出处:网络
Some .net Theory question: Which libraries are actually standardized? I know that there is the Common Type System which specifies things like 32-Bit Integers and all this low level info, but I\'m conf

Some .net Theory question: Which libraries are actually standardized? I know that there is the Common Type System which specifies things like 32-Bit Integers and all this low level info, but I'm confused about the status/relation of the Common Language Specification and the Base Class Libraries.

There are some fundamental types in the system: System.Object, System.ValueType, System.Exception. But what about things like System.String and it's methods/properties like .Length, .StartsWith or string.IsNullOrEmpty?

Are these part of any standard? Is ECMA-335 enough to imp开发者_如何学编程lement a CLS-compliant .net Runtime?

PS: I know that many functions that people use everyday are not standards-compliant but part of Microsofts proprietary .net Framework implementation. This is not about running existing Apps under some unsupported Operating System, I would look at Mono for that. This is really a theoretical question about what makes the core of .net, what is the .net Standard Library.


Check out Partition IV of the Ecma spec. It defines the "standard runtime library". However, there isn't a single "standard library". It defines 2 profiles: a kernel profile and a compact profile, and 7 libraries. The compact profile is a super set of the kernel profile. Several of the libraries it defines are "optional" and are not associated with either profile. It also identifies some CLR features that are "optional" and may not be covered by all implementations.

The BCL (base class library) as defined in the Ecma spec is just one of the 7 libraries it defines.

The CLS, or common language specification, is a set of guidelines for API design that promotes maximal language interoperability.

As defined in Section 7.2 in partition I of the ecma spec there are 3 views of CLS compliance:

  1. A CLS compliant framework is a library containing CLS compliant code
  2. A CLS consumer is a language (or other tool) that allows access to any feature defined in any CLS compliant framework.
  3. A CLS extender is a language (or other tool) that allows programmers to both use and extend CLS compliant frameworks.

The exact requirements for each of these are listed in the ECMA spec.

In any case, there is no concept of a "CLS Compliant .NET Runtime". The ".NET Runtime" consists of everything in the runtime system. CLS compliance, however, is only concerned with the interface of publicly visible items.


AFAIK the core is everything that is in mscorlib.dll.

Look at mscorlib.dll with Reflector (while it's still free!) to see what's included and what's not. Or look at the MSDN .NET Framework Class Library documentation for a Type you're interested in - the documentation indicates which Assembly contains each Type.

System.String is included, but, for example, System.Uri isn't.

Basic generic collections like List<T> are included, but Queue<T> and Stack<T> aren't.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号