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

# AL0025 - Anonymous function can be made static

> Lambda expressions and anonymous methods that don't capture variables should be marked 'static'

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

## Description

Lambda expressions and anonymous methods that don't capture variables should be marked 'static' to avoid unnecessary allocations and improve performance.

## Bad Code

```csharp theme={null}
list.Where(x => x > 0) // when no captures
```

## Good Code

```csharp theme={null}
list.Where(static x => x > 0)
```

## Properties

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

## Configuration

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