Skip to main content
Source: AL0032UseOrEmptyAnalyzer.cs

Description

Null-coalescing with empty collections is verbose. ANcpLua.Roslyn.Utilities provides the OrEmpty() extension for cleaner null handling.

Bad Code

Good Code

Properties

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

Configuration

Notes

  • Works with arrays, lists, and any IEnumerable<T>
  • Returns empty collection of the same type when null
  • Reduces boilerplate in LINQ chains