-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
analyzerIndicates an issue which is related to analyzer experienceIndicates an issue which is related to analyzer experiencearea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesIncludes: MVC, Actions and Controllers, Localization, CORS, most templates
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
MVC1004 is warning for parameters that are injected from services.


Expected Behavior
MVC1004 does not warn for any BindingSource that is isFromRequest: false
, or at least not BindingSource.Services
.
It should probably also not warn for getter-only properties that will never be bound.
Steps To Reproduce
public class HomeController : Controller
{
[HttpGet]
public async Task<ActionResult> Get([FromServices] SiteSettingsService settings) { /* stuff */ }
^^^^^^^^ MVC1004
}
public class SiteSettings { }
public class SiteSettingsService(AppDbContext db)
{
private SiteSettings _settings;
public SiteSettings Settings => _settings ??= db.SiteSettings.First();
// ... other unrelated stuff
}
Exceptions (if any)
No response
.NET Version
10.0.100-rc.1.25451.107
Anything else?
Tried TargetFramework both net8.0 and net10.0 (10.0.100-rc.1.25451.107)
Metadata
Metadata
Assignees
Labels
analyzerIndicates an issue which is related to analyzer experienceIndicates an issue which is related to analyzer experiencearea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesIncludes: MVC, Actions and Controllers, Localization, CORS, most templates