c# - ImmutableArray 在哪里?

标签 c# immutable-collections

为什么 ImmutableArray Microsoft Immutable Collections NuGet 包版本中似乎没有 1.0.34

enter image description here

最佳答案

ImmutableArray不存在于您的库版本中。

正如您在 version history 中看到的那样,1.1.20 的发行说明提到“重新包含 ImmutableArray

您可以在 .NET 博客的 1.0 版本中找到关于 ImmutableArray 为何缺失的解释,在此 announcement . (简而言之,当 Roslyn 团队尝试使用该类型而不是常规数组时,他们的性能受到了显着影响,负责该库的团队不确定如何解决该问题,同时保持合理的 API。)

您将在其新的 NuGet 包下找到该库的更新版本, System.Collections.Immutable .

注意:根据 source codeSystem.Collections.Immutable 的新版本中,他们显然已经决定接受 API 攻击——也就是说,对未初始化的 ImmutableArray 进行一些操作。会抛出一个令人惊讶的 NullReferenceException秒。显然,ImmutableArray不应该永远被实例化为new . (应改用 ImmutableArray<T>.Empty)

关于c# - ImmutableArray 在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29273466/

相关文章:

c# - 在远程服务器中创建文件夹时出错

c# - 为什么 ImmutableList 的 add 方法复杂度为 O(logN)?

c# - 为什么 ImmutableList<T> 的枚举器与 List<T> 相比慢得多

c# - 正则表达式匹配以句点开头并以下划线结尾的单词?

c# - 从库类公开枚举

c# - Rabbit MQ 句柄取消 token

c# - C# 中的列表大小限制

c# - 应该更喜欢 ImmutableDictionary 还是 ImmutableSortedDictionary?

c# - 如何在 C# 中将 ImmutableArray<DerivedClass> 转换为 ImmutableArray<BaseClass> ,反之亦然?

java - Guava - 将从两个 Optionals 中提取的值收集到一个 ImmutableSet 中