Skip to content

The StaticMethodMustNotBeVoid analyzer should ignore Main #2

@DavidArno

Description

@DavidArno

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions