[英]moq 4.18.0 doest allow me to use list.IsNullOrEmpty() from Castle.core.internal
when i update my unit test project to moq 4.18.0 or above, i get the following exception Could not load type 'Castle.Core.Internal.CollectionExtensions'
.当我将我的单元测试项目更新到最小起订量 4.18.0 或更高版本时,出现以下异常
Could not load type 'Castle.Core.Internal.CollectionExtensions'
。 In my service class im using the static method IsNullOrEmpty
from Castle.core.internal.在我的服务 class 中,我使用来自 Castle.core.internal 的 static 方法
IsNullOrEmpty
。 Im not getting this issue for moq versions below 4.18.0.对于低于 4.18.0 的最小起订量版本,我没有遇到此问题。
the resolve the issue for now I'm just creating my own internal IsNullOrEmpty
method.现在解决这个问题我只是创建我自己的内部
IsNullOrEmpty
方法。
Any Idea how to solve this exception from moq?知道如何解决最小起订量的这个异常吗?
As it was stated by Ralf the CollectionExtensions
has been removed from the package.正如Ralf所说,
CollectionExtensions
已从 package 中删除。
The IsNullOrEmpty
was implemented like this: IsNullOrEmpty
是这样实现的:
public static bool IsNullOrEmpty(this IEnumerable @this)
{
return @this == null || @this.GetEnumerator().MoveNext() == false;
}
But you can implement like this as well但是你也可以这样实现
public static bool IsNullOrEmpty(this IEnumerable @this)
=> !(@this?.GetEnumerator().MoveNext() ?? false);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.