Skip to main content

Documentation Index

Fetch the complete documentation index at: https://ancplua.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Source: Al0046UseGuardNotNullOrWhiteSpaceAnalyzer.cs

Description

Use Guard.NotNullOrWhiteSpace() instead of verbose null-or-whitespace check and throw patterns.

Bad Code

public void Process(string name)
{
    if (string.IsNullOrWhiteSpace(name))
        throw new ArgumentException("Cannot be null or whitespace", nameof(name));
}

Good Code

public void Process(string name)
{
    Guard.NotNullOrWhiteSpace(name);
}

Properties

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

Configuration

dotnet_diagnostic.AL0046.severity = warning