> ## Documentation Index
> Fetch the complete documentation index at: https://ancplua.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# AL0049 - Use positive-guard helper

> Use Guard.Positive() instead of verbose if (x <= 0) throw patterns

Source: [Al0049UseGuardPositiveAnalyzer.cs](https://github.com/ANcpLua/ANcpLua.Analyzers/blob/main/src/ANcpLua.Analyzers/Analyzers/Al0049UseGuardPositiveAnalyzer.cs)

## Description

Use `Guard.Positive()` instead of verbose positive-check and throw patterns.

## Bad Code

```csharp theme={null}
public void SetPageSize(int size)
{
    if (size <= 0)
        throw new ArgumentOutOfRangeException(nameof(size));
}
```

## Good Code

```csharp theme={null}
public void SetPageSize(int size)
{
    Guard.Positive(size);
}
```

## Properties

* **Category**: Roslyn Utilities
* **Severity**: Warning
* **Enabled by default**: True
* **Code fix available**: True

## Configuration

```editorconfig theme={null}
dotnet_diagnostic.AL0049.severity = warning
```
