Navigation

Gendarme.Rules.Ui

From Mono

Gendarme's user interface rules are located in the Gendarme.Rules.Ui.dll assembly. Latest sources are available from anonymous SVN (http://anonsvn.mono-project.com/viewcvs/trunk/mono-tools/gendarme/rules/Gendarme.Rules.Ui/) (tarball (http://anonsvn.mono-project.com/viewcvs/trunk/mono-tools/gendarme/rules/Gendarme.Rules.Ui.tar.gz?view=tar)).

Table of contents

Rules

GtkSharpExecutableTargetRule

An executable assembly, i.e. an .exe, refers to the gtk-sharp assembly but isn't compiled using -target:winexe. A console windows will be created and shown under Windows (MS runtime) when the application is executed.

Bad example:

mcs gtk.cs -pkg:gtk-sharp

Good example:

mcs gtk.cs -pkg:gtk-sharp -target:winexe


SystemWindowsFormsExecutableTargetRule

An executable assembly, i.e. an .exe, refers to the System.Windows.Forms assembly but isn't compiled using -target:winexe. A console windows will be created and shown under Windows (MS runtime) when the application is executed.

Bad example:

mcs swf.cs -pkg:dotnet

Good example:

mcs swf.cs -pkg:dotnet -target:winexe


UseSTAThreadAttributeOnSWFEntryPointsRule

This rule checks executable assemblies that reference System.Windows.Forms to ensure that their entry point is decorated with [System.STAThread] attribute and is not decorated with [System.MTAThread] attribute, or otherwise Windows Forms may not work properly.

Bad example #1 (no attributes):

public class WindowsFormsEntryPoint {
    static void Main ()
    {
    }
}

Bad example #2 (MTAThread)

public class WindowsFormsEntryPoint {
    [MTAThread]
    static void Main ()
    {
    }
}

Good example #1 (STAThread):

public class WindowsFormsEntryPoint {
    [STAThread]
    static void Main ()
    {
    }
}

Good example #2 (not Windows Forms):

public class ConsoleAppEntryPoint {
    static void Main ()
    {
    }
}

Feedback

Please report any documentation errors, typos or suggestions to the Gendarme Google Group (http://groups.google.com/group/gendarme). Thanks!