Description
Manual checks onIOperation properties like TargetMethod.Name == and ConstantValue.HasValue && are verbose. ANcpLua.Roslyn.Utilities provides extension methods for cleaner operation analysis.
Bad Code
Good Code
Properties
- Category: Usage
- Severity: Info
- Enabled by default: True
- Code fix available: False
Configuration
Notes
The operation extension methods:IsMethodNamed()- cleaner alternative toTargetMethod.Name ==comparisonsTryGetConstantValue<T>()- type-safe constant extraction with null handling- Both reduce boilerplate in Roslyn analyzer implementations
- Work with
IInvocationOperationandIOperationrespectively
