Arnolyzer icon indicating copy to clipboard operation
Arnolyzer copied to clipboard

The `StaticMethodMustNotBeVoid` analyzer should ignore `Main`

Open DavidArno opened this issue 9 years ago • 0 comments

Currently, StaticMethodMustNotBeVoid reports an error on the Main entry-point method of an application. Main has to be void.

Winform applications are decorated with [STAThread], but this doesn't apply to console applications. The method can be decorated with [HasSideEffects], but this somehow seems odd for an entry point method.

One solution would be to simply have the analyzer ignore methods called Main.

What might be better is to add support for a new [ApplicationStartup] attribute that can be used in this situation. It's tempting to limit this to methods named Main, but other folk may well use other method names, which would cause problems.

DavidArno avatar Mar 16 '16 12:03 DavidArno