简体   繁体   English

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

[英]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.

相关问题 如何从Castle.Core而不是Moq引用Castle.DynamicProxy.IProxyTargetAccessor? - How to reference Castle.DynamicProxy.IProxyTargetAccessor from Castle.Core rather than Moq? Moq.CastleProxyFactory' 无法加载文件或程序集 'Castle.Core - Moq.CastleProxyFactory' Could not load file or assembly 'Castle.Core 我怎样才能使用Castle Core 2.5.2中的DictionaryAdapter? - How can I use just the DictionaryAdapter from Castle Core 2.5.2? 将Moq与温莎城堡配合使用 - Using Moq With Castle Windsor 无法加载类型“ Castle.Core.Internal.SlimReaderWriterLock” - Could not load type 'Castle.Core.Internal.SlimReaderWriterLock' DataGridViewComboBoxColumn不允许我从列表中选择一个对象 - DataGridViewComboBoxColumn does not allow me to select an object from a list 起订量内部 class 和/或内部方法 - Moq internal class and/or internal method 将 Castle-Core 从 4.4.1 升级到 5.0.0 后,Castle Windsor 5.1.1 出错 - 无法从 Castle.Core 加载 PermissionUtil - Castle Windsor 5.1.1 erroring after upgrading Castle-Core from 4.4.1 to 5.0.0 - Could not load PermissionUtil from Castle.Core C# 是否有用于 List/IEnumerable 的 IsNullOrEmpty? - Does C# have IsNullOrEmpty for List/IEnumerable? 如何在 ASP.NET Core 中的模型中 xunit/Moq 测试内部设置器 - How to xunit / Moq test an internal setter within a model in ASP.NET Core
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM