繁体   English   中英

最小起订量 4.18.0 允许我使用 Castle.core.internal 中的 list.IsNullOrEmpty()

[英]moq 4.18.0 doest allow me to use list.IsNullOrEmpty() from Castle.core.internal

当我将我的单元测试项目更新到最小起订量 4.18.0 或更高版本时,出现以下异常Could not load type 'Castle.Core.Internal.CollectionExtensions' 在我的服务 class 中,我使用来自 Castle.core.internal 的 static 方法IsNullOrEmpty 对于低于 4.18.0 的最小起订量版本,我没有遇到此问题。

现在解决这个问题我只是创建我自己的内部IsNullOrEmpty方法。

知道如何解决最小起订量的这个异常吗?

正如Ralf所说, CollectionExtensions已从 package 中删除。

IsNullOrEmpty是这样实现的:

public static bool IsNullOrEmpty(this IEnumerable @this)
{
    return @this == null || @this.GetEnumerator().MoveNext() == false;
}

但是你也可以这样实现

public static bool IsNullOrEmpty(this IEnumerable @this)
    => !(@this?.GetEnumerator().MoveNext() ?? false);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM