Skip to content

Gendarme.Rules.Design.EnsureSymmetryForOverloadedOperatorsRule(git)

Sebastien Pouliot edited this page Mar 2, 2011 · 1 revision

EnsureSymmetryForOverloadedOperatorsRule

Assembly: Gendarme.Rules.Design
Version: git

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;
    }
}

Source code

You can browse the latest source code of this rule on github.com

Clone this wiki locally