RequestDelegate is not injected on middlewares using Primary Constructor
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Describe the bug
When using primary constructors, the `RequestDelegate` comes null, causing `404` to be returned everytime. When using default constructors, it is injected just fine, which is expected.

### Expected Behavior
Since primary constructor is the same of having a single construtor definition, it should have the same behaviour as injecting the `RequestDelegate` in the default constructor.
### Steps To Reproduce
• Create a middleware
• Use the new primary constructor to inject the RequestDelegate
• Verify during debug that it is injected as null
### Exceptions (if any)
_No response_
### .NET Version
8
### Anything else?
_No response_
Contributor guide
Research direction
Start by reproducing the middleware behavior described in issue #53490 on .NET 8, comparing a primary constructor with a default constructor. Trace how RequestDelegate is supplied during middleware activation and confirm the fix by verifying it is non-null and the middleware no longer returns an unintended 404.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100