[AOT] Enable analysis and annotate Http.Results by JamesNK · Pull Request #46082 · dotnet/aspnetcore (original) (raw)
Good to know. Thanks.
Unfortunately, another challenge. Adding a generic argument for route values to TypeResults creates ambiguous method calls.
public static IResult CreatedAtRoute(string? routeName = null, object? routeValues = null, object? value = null)
- public static IResult CreatedAtRoute(string? routeName, TRouteValues routeValues, object? value = null) public static IResult CreatedAtRoute(string? routeName = null, object? routeValues = null, TValue? value = default)
- public static IResult CreatedAtRoute<TValue, TRouteValues>(string? routeName, TRouteValues routeValues, TValue? value = default)
CreatedAtRoute<TRouteValues> and CreatedAtRoute<TValue> creates a conflict if one generic argument is specified and parameters that match both overloads.
For example, this is ambigious:
TypedResults.CreatedAtRoute("RouteName", new { param1 = "param1Value" }, new User());
It's a source-breaking change, and the method call needs to be modified to one of:
// both generic arguments TypedResults.CreatedAtRoute<object, object>("RouteName", new { param1 = "param1Value" }, new User());
// or remove generic argument TypedResults.CreatedAtRoute("RouteName", new { param1 = "param1Value" }, new User());
@davidfowl What do you think? I'm concerned about how many overloads there are with optional parameters. And generic arguments. I worry that there are undiscovered ambiguous method call situations today, and adding future overloads will be an ambiguous method call minefield.