簡體   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