Description
UseGuard.NotNullOrWhiteSpace() instead of verbose null-or-whitespace check and throw patterns.
Bad Code
Good Code
Properties
- Category: Roslyn Utilities
- Severity: Warning
- Enabled by default: True
- Code fix available: True
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Use Guard.NotNullOrWhiteSpace() instead of verbose patterns
Guard.NotNullOrWhiteSpace() instead of verbose null-or-whitespace check and throw patterns.
public void Process(string name)
{
if (string.IsNullOrWhiteSpace(name))
throw new ArgumentException("Cannot be null or whitespace", nameof(name));
}
public void Process(string name)
{
Guard.NotNullOrWhiteSpace(name);
}
dotnet_diagnostic.AL0046.severity = warning
Was this page helpful?
