-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
analyzerIndicates an issue which is related to analyzer experienceIndicates an issue which is related to analyzer experienceold-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
Milestone
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Given the following example:
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics.CodeAnalysis;
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/{blah}", ([FromRoute(Name = "blah")]MyRouteObject x) => "Hello World!");
app.Run();
public class MyRouteObject
{
}... the recently added Roslyn analyzer fails to warn that MyRouteObject does not have a TryParse(...) method. This results in a runtime error when this code is run.
Expected Behavior
We should raise an analyzer warning on the handler parameter because it's a route parameter that does not implement TryParse.
Steps To Reproduce
See above.
Exceptions (if any)
At runtime we get the following exception:
InvalidOperationException: No public static bool MyRouteObject.TryParse(string, out MyRouteObject) method found for x.
.NET Version
8.0.100-alpha.1.22613.3
Anything else?
No response
Metadata
Metadata
Assignees
Labels
analyzerIndicates an issue which is related to analyzer experienceIndicates an issue which is related to analyzer experienceold-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels