Gendarme.Rules.Ui

Gendarme's user interface rules are located in the Gendarme.Rules.Ui.dll assembly. Latest sources are available from anonymous SVN.

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 window will be created and shown under Windows (MS runtime) when the application is executed.

Bad example:

gmcs gtk.cs -pkg:gtk-sharp

Good example:

gmcs 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 window will be created and shown under Windows (MS runtime) when the application is executed which is probably not desirable for a winforms application.

Bad example:

gmcs swf.cs -pkg:dotnet

Good example:

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


UseSTAThreadAttributeOnSWFEntryPointsRule

This rule checks executable assemblies, i.e. *.exe's, 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 to ensure that Windows Forms 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. Thanks!