Code inspection: Operator without matching checked operator
This inspection reports an operator that has no matching checked version while related operators do. That can make arithmetic behavior inconsistent, especially for numeric types where overflow handling matters.
Example
public struct Counter
{
public static Counter operator +(Counter left, Counter right)
{
return left;
}
public static checked Counter operator -(Counter left, Counter right)
{
return left;
}
}
public struct Counter
{
public static Counter operator +(Counter left, Counter right)
{
return left;
}
public static checked Counter operator +(Counter left, Counter right)
{
}
public static checked Counter operator -(Counter left, Counter right)
{
return left;
}
}
Quick-fix
The quick-fix creates the missing matching checked operator.
01 April 2026