BCL 与 CLS 有何关系?

发布于 2024-10-25 04:49:00 字数 444 浏览 8 评论 0原文

一些 .net 理论问题:哪些库实际上是标准化的?我知道有通用类型系统,它指定了 32 位整数和所有这些低级信息,但我对公共语言规范和基类库的状态/关系感到困惑。

系统中有一些基本类型:System.Object、System.ValueType、System.Exception。但是像 System.String 之类的东西及其方法/属性(例如 .Length、.StartsWith 或 string.IsNullOrEmpty)又如何呢?

这些是任何标准的一部分吗? ECMA-335 是否足以实现符合 CLS 的 .net 运行时?

PS:我知道人们日常使用的许多功能并不符合标准,而是 Microsoft 专有的 .net Framework 实现的一部分。这与在某些不受支持的操作系统下运行现有应用程序无关,为此我会考虑 Mono。这实际上是一个关于什么是 .net 核心、什么是 .net 标准库的理论问题。

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 implement 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

溺渁∝ 2024-11-01 04:49:00

查看 Ecma 规范的第四部分。它定义了“标准运行时库”。但是,没有一个“标准库”。它定义了 2 个配置文件:一个内核配置文件和一个紧凑配置文件,以及 7 个库。紧凑配置文件是内核配置文件的超集。它定义的几个库是“可选的”并且不与任一配置文件关联。它还标识了一些“可选”的 CLR 功能,并且可能并未被所有实现所覆盖。

Ecma 规范中定义的 BCL(基类库)只是它定义的 7 个库之一。

CLS(通用语言规范)是一组 API 设计指南,可促进最大程度的语言互操作性。

正如 ecma 规范第 I 部分第 7.2 节中所定义的,CLS 合规性有 3 种观点:

  1. CLS 合规框架是包含 CLS 合规代码的库
  2. CLS 使用者是一种语言(或其他工具),允许访问定义在 CLS 中的任何功能。任何符合 CLS 的框架。
  3. CLS 扩展器是一种语言(或其他工具),允许程序员使用和扩展符合 CLS 的框架。

ECMA 规范中列出了每一项的具体要求。

无论如何,不​​存在“符合 CLS 的 .NET 运行时”的概念。 “.NET Runtime”由运行时系统中的所有内容组成。然而,CLS 合规性仅涉及公开可见项目的界面。

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.

我还不会笑 2024-11-01 04:49:00

AFAIK 的核心是 mscorlib.dll 中的所有内容。

使用 Reflector 查看 mscorlib.dll(虽然它仍然是免费的!),看看包含哪些内容和不包含哪些内容。或者查看 MSDN .NET Framework 类库文档,了解您想要的类型感兴趣 - 文档指示哪个程序集包含每种类型。

System.String 包含在内,但 System.Uri 则不包含在内。

包括 List 等基本通用集合,但不包括 QueueStack

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文