Skip to content

Gendarme.Rules.Design.EnsureSymmetryForOverloadedOperatorsRule(2.10)

Sebastien Pouliot edited this page Jan 22, 2011 · 2 revisions

EnsureSymmetryForOverloadedOperatorsRule

Assembly: Gendarme.Rules.Design
Version: 2.10

Description

This rule checks for operators that are not overloaded in pairs. Some compilers, like the C# compilers, require you to implement some of the pairs, but other languages might not. The following pairs are checked:

Examples

Bad example:

class DoesNotOverloadAdd {
    public static int operator - (DoesNotOverloadAdd left, DoesNotOverloadAdd right)
    {
        return 0;
    }
}

Good example:

class Good {
    public static int operator + (Good right, Good left)
    {
        return 0;
    }
    public static int operator - (Good right, Good left)
    {
        return 0;
    }
}
Clone this wiki locally