.NET 标准 API 参考

.NET Standard API Reference

更新:

所以它似乎是 open issue now. So I guess until this is done I will have to rely on .NET Core API reference 并祈祷我不会击中其中一个 43 APIs that .NET Framework 4.6.1 doesn't support 但官方应该是...

也依赖于 .NET Core API 参考并考虑与 .NET 标准相同可能会非常令人惊讶。例如,当我查看名称空间列表时,我可以看到 System.Drawing,但是当单击它时,我们会意识到这是一个仅包含 6 个结构的 almost empty namespace

这样的命名空间有几个?我不知道,我必须比较 .NET Core 和 .NET Framework 文档才能得到答案。

原创 POST:

我正在尝试查找 .NET Standard API 参考。

this page 上只有指向 .NET Core API reference.NET Framework API reference 的链接。

是的,我已经搜索并阅读了其他人的 SO 问题。例如 points to .NET Core API reference instead of .NET standard and the same in this Github issue feed

但是 .NET Core 和 .NET Standard 是不同的。 .NET Core 是 .NET Standard APIs.

的实现

例如,我在这里看到的一个大问题是基于 official documentation .NET Framework 4.6.1 将实施 .NET Standard 2.0

很好,除了 .NET Standard Github readme page 还说

On the other hand, .NET Standard 2.0 adds many APIs that .NET Framework 4.6.1 already supports. The delta looks as follows:

  • .NET Standard 2.0 adds 14,994 APIs that .NET Framework 4.6.1 already supports

  • .NET Standard 2.0 only has 43 APIs that .NET Framework 4.6.1 doesn't support Originally, we planned to simply elide those APIs from .NET Standard 2.0 in order to make it easier to understand what will work on .NET Framework 4.6.1.

However, we got a lot of feedback around this. You told us that this decision makes it really hard to reason about .NET Standard versioning rules. Thus, we decided to simplify this:

  • .NET Standard 2.0 will be a strict superset of .NET Standard 1.6. In other words, no breaking changes will happen between .NET Standard 2.0 and 1.x.

  • .NET Framework 4.6.1 will allow referencing binaries that are compiled against .NET Standard 2.0. Considering the number of APIs that .NET Framework 4.6.1 will not support is low and that these are all brand-new APIs with low adoption we believe this is a much better trade-off.

You can use API Port to scan a given application to make sure no code in your application depends on these APIs.

那又怎样?他们解决这个问题的方法是to scan a given application?因此,如果我开始一个新项目,考虑到我还没有编写代码这一事实,我会以 .NET Standard 为目标,并祈祷我不会以本应不受支持的 API 结束?

另外,Xamarin 或 UWP 等其他框架中是否存在类似情况? 2.0 列中的 vNext 是什么意思?我是否应该担心其他框架中其他不受支持的 API 因为 Considering the number of APIs that [Framework name] will not support is low and that these are all brand-new APIs with low adoption we believe this is a much better trade-off?

我能找到的最接近这个问题的答案是查看 NETStandard.Library NuGet package 的依赖项。然而,这给了我 1.3 版本的依赖性(不是 1.6 或我不太理解这一部分),并且没有给我 API 应该已经确定的下一个 2.0 的参考。

我们不能拥有每个 .NET Standard 版本 API真正 支持的完整记录列表吗? .NET Standard 的唯一目标就是为开发人员提供这些非常重要的信息,为什么我找不到它?

BCL (Immo Landwerth) 的 PM 维护了一个很好的网页。它显示了所有 API、它们在所有可以想象的平台(.NET Framework、.NET Core、UWP、Mono 等)中的当前实现及其在 .NET 标准版本中的状态,包括 2.0 的计划。

http://apisof.net (sample for List)

希望对您有所帮助。不幸的是,基于标准的库可能会出现某些边缘情况。我想会有一些工具围绕它。

1.4 和 1.5 之间的增量: https://github.com/dotnet/standard/blob/master/docs/versions/netstandard1.5_diff.md

1.5 和 1.6 之间的增量: https://github.com/dotnet/standard/blob/master/docs/versions/netstandard1.6_diff.md

不要太担心 4.6 与 4.6.2 的问题。当我没记错时,他们会解决这个问题。

关于画图的问题:确实是最烦人的问题。 System.Drawing 基于 GDI,因此并非随处可用。常见任务有替代方案。不要忘记,大多数渲染都是客户端的东西,因此不完全是标准的用例,而是更多具体的应用程序模型。

netstandard2.0 在.Net Framework 4.6.1 和当前版本中大多被确定为 netstandard1.6 加上 mscorlib.dll、System.dll 或 System.Core.dll 中的那些方法Xamarin 的。仍然有一些小的变化,可以通过 https://github.com/dotnet/standard/

的提交和 PR 历史记录看到

netstandard1.6 中存在但 .NET 4.6.1 中不存在的方法被标记为对智能感知不可见,以防止新开发人员混淆。但是它们确实存在,因此无论如何编写代码都可以成功编译。这是 "but it won't work on netfx" 和 "but I can't upgrade my netstandard1.6 library" 的折衷方案。

I'm trying to find the .NET Standard API reference.

here. E.g., all the APIs for netstandard1.0. It's not as nice as the MSDN docs - yet. They're working on that。但如果您想要特定 API 的列表,它就在那里。

Their solution to this problem is to scan a given application?

嗯,我认为这比检查源代码的每一行并在文档中查找要容易得多...

So if I start a new project, giving the fact that I don't have code written yet, I would target .NET Standard and pray I don't end up with unsupported APIs that are supposed to be?

如果您的目标是 netstandard,您将无法调用任何不在您的 netstandard 版本中的 API。作为一般规则,您应该从定位 netstandard1.0 开始,只有在需要其他 API 时才向上移动。

关于"unsupported APIs",这是一个完全不同的问题。在这种情况下,您谈论的是一个平台(如 Xamarin.Android 7.0 或 .NET 4.6.2)声明支持给定 netstandard 版本但在运行时抛出 NotSupportedException 一些API。不幸的是,故事的那部分是非常待定的。在这一点上,我们将拥有什么样的工具仍然未知。今天没有事。

Also are there other cases like this in other frameworks like Xamarin or UWP?

是的。 Xamarin 一直都有这个 - 他们从未完全支持 .NET API。 UWP 将至少具有与 .NET 4.6.2 相同的限制。

What does that mean vNext exactly in the 2.0 column?

这意味着 netstandard2.0 不会被这些平台的当前版本支持,但他们预计会发布支持 netstandard2.0 的这些平台的未来版本。

Should I be worried of other unsupported APIs in other frameworks

在这一点上,我不会担心。最终会有某种关于检测不受支持的 API 的故事。 运行 APIPort 作为 post-compile 步,您今天可以走得很远。

正如 Martin 在 , the .NET API Browser 中提到的那样,这正是我之前一直在寻找的。

您可以 select 并使用 .NET 标准 API 或任何框架实现甚至 select 任何版本进行过滤。太好了,微软早该做出来的。