Skip to content

Gendarme.Rules.Interoperability.Com.AvoidStaticMembersInComVisibleTypesRule(git)

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

AvoidStaticMembersInComVisibleTypesRule

Assembly: Gendarme.Rules.Interoperability.Com
Version: git

Description

COM visible types should not contain static methods because they are not supported by COM

Examples

Bad example:

[assembly: ComVisible (false)]
namespace InteropLibrary {
    [ComVisible (true)]
    public class Bad {
        public static void BadMethod ()
        {
            // do something
        }
    }
}

Good example:

[assembly: ComVisible (false)]
namespace InteropLibrary {
    [ComVisible (true)]
    public class Good {
        [ComVisiblte (false)]
        public static void GoodMethod ()
        {
            // do something
        }
    }
}

Notes

  • This rule ignores methods marked with ComRegisterFunctionAttribute or ComUnregisterFunctionAttribute attributes. Rule applies only when the containing assembly has ComVisible attribute explicitly set to false and the type has ComVisible attribute explicitly set to true.

Source code

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

Clone this wiki locally