dotnet / dotnet/aspnetcore

Minimal .NET API - Delegate 'RequestDelegate' does not take 0 arguments

Open
#47,275 3 comments 0 reactions 0 assignees View on GitHub
area-networking
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

Sort of like this https://github.com/dotnet/aspnetcore/issues/34390, but in my case I wanted to create stub routes to be completed later. These look like

`MapGet("countries", () => throw new NotImplementedException());`

### Expected Behavior

No warning/error

### Steps To Reproduce

Set up a minimal API like

`MapGet("countries", () =>throw new NotImplementedException());`

problem is due to the lack of return value.

### Exceptions (if any)

_No response_

### .NET Version

7.0.300-preview.23122.5; using VS2022 17.6.0 Preview 2.0

### Anything else?

Current solution is to write it as

`MapGet("countries", () => { throw new NotImplementedException(); return string.Empty; });`

This is by no means is a blocking or problematic bug. I just want to report this behaviour from Visual Studio I encountered while migrating an old project to minimal API

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.