dotnet / dotnet/aspnetcore

Provide an analyzer for Configure() in Startup

Open
#17,854 0 comments 4 reactions 0 assignees View on GitHub
affected-medium analyzer area-hosting area-networking enhancement severity-minor
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is your feature request related to a problem? Please describe.
It's related to an issue with the `Configure()` method in `Startup`.

### Describe the solution you'd like
Recently a developer on a project I'm on created a `Configure()` method like this:
```
public async Task Configure(IApplicationBuilder app, IConfiguration config)
```
This will compile just fine, but when you run it, you get this exception:

> System.InvalidOperationException : The 'Configure' method in the type 'XYZ' must have a return type of 'Void'.

Now, there are ways to get around this (https://andrewlock.net/running-async-tasks-on-app-startup-in-asp-net-core-part-1/), but the point is, if an analyzer was in place to make sure methods in `Startup` are defined correctly, we wouldn't have to wait until we ran the code to know there's a problem.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.