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

# AL0033 - Use ToImmutableArrayOrEmpty()

> Replace nullable ToImmutableArray patterns with ToImmutableArrayOrEmpty() extension

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

## Description

The pattern `?.ToImmutableArray() ?? ImmutableArray<T>.Empty` is verbose. ANcpLua.Roslyn.Utilities provides `ToImmutableArrayOrEmpty()` for cleaner conversion.

## Bad Code

```csharp theme={null}
using System.Collections.Immutable;

// Verbose nullable pattern
var result = items?.ToImmutableArray() ?? ImmutableArray<string>.Empty;
```

## Good Code

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

// Clean extension
var result = items.ToImmutableArrayOrEmpty();
```

## Properties

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

## Configuration

```editorconfig theme={null}
dotnet_diagnostic.AL0033.severity = suggestion
```

## Notes

* Handles null input gracefully
* Returns `ImmutableArray<T>.Empty` for null
* Common pattern in Roslyn analyzer development
