CommunityToolkit / CommunityToolkit/dotnet

Provide `Guard.IsNotNullOrEmpty` for collection types

Open
#741 0 comments 0 reactions 0 assignees View on GitHub
feature request :mailbox_with_mail:
Dominant language
C#
Stars
3.8k
Forks
400
PR merge metrics
No merged PRs in 30d

Description

### Overview

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

### API breakdown

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

### Usage example

`Guard.IsNotNullOrEmpty(myCollection);`

### Breaking change?

No

### Alternatives

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

### Additional context

_No response_

### Help us help you

No, just wanted to propose this

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.