> ## 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.

# AL0036 - Use Guard.NotNull()

> Replace null-coalescing throw patterns with Guard.NotNull() extension

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

## Description

The pattern `value ?? throw new ArgumentNullException(nameof(value))` is verbose. ANcpLua.Roslyn.Utilities provides `Guard.NotNull()` for cleaner null validation.

## Bad Code

```csharp theme={null}
public class Service {
    private readonly ILogger _logger;

    public Service(ILogger logger) {
        _logger = logger ?? throw new ArgumentNullException(nameof(logger));
    }
}
```

## Good Code

```csharp theme={null}
using ANcpLua.Roslyn.Utilities;

public class Service {
    private readonly ILogger _logger;

    public Service(ILogger logger) {
        _logger = Guard.NotNull(logger);
    }
}
```

## Properties

* **Category**: Usage
* **Severity**: Warning
* **Enabled by default**: True
* **Code fix available**: False

## Configuration

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

## Notes

* Automatically uses `CallerArgumentExpression` for parameter name
* Throws `ArgumentNullException` with correct parameter name
* Reduces boilerplate in constructors and methods
