Code inspection: Incorrect usage of the 'ConstantExpected' attribute
This inspection reports incorrect usage of ConstantExpectedAttribute. It appears when the attribute is applied to a parameter type that does not support it, or when its Min and Max boundaries are invalid for that parameter.
It is the same as the CA1856 code quality rule.
Example
using System.Diagnostics.CodeAnalysis;
void Print([ConstantExpected] decimal value)
{
}
void Print(decimal value)
{
}
Quick-fix
There is no dedicated quick-fix for this inspection. A typical correction is to remove the attribute or use it only on supported parameter types with valid bounds.
01 April 2026