CommunityToolkit / dotnet

.NET Community Toolkit is a collection of helpers and APIs that work for all .NET developers and are agnostic of any specific UI platform. The toolkit is maintained and published by Microsoft, and part of the .NET Foundation.
https://docs.microsoft.com/dotnet/communitytoolkit/?WT.mc_id=dotnet-0000-bramin
Other
2.99k stars 294 forks source link

Provide `Guard.IsNotNullOrEmpty` for collection types #741

Open cremor opened 1 year ago

cremor commented 1 year ago

Overview

Guard provides IsNotEmpty overloads for many collection types. It should also provide IsNotNullOrEmpty overloads.

API breakdown

public static class Guard
{
    public static void IsNotNullOrEmpty<T>(ICollection<T> collection, [CallerArgumentExpression("collection")] string name = "");
    // Also other overloads like already exist for 'IsNotEmpty'.
}

Usage example

Guard.IsNotNullOrEmpty(myCollection);

Breaking change?

No

Alternatives

Guard.IsNotNull(myCollection);
Guard.IsNotEmpty(myCollection);

Additional context

No response

Help us help you

No, just wanted to propose this