Closed
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