aspnetcore: Ambiguous Map method with Minimal

Proposed API

Add a new Map overload to remove ambiguity caused by implicit conversion from PathString:

namespace Microsoft.AspNetCore.Builder
{
    public static class MapExtensions
    {
+        public static IApplicationBuilder Map(this IApplicationBuilder app, string pathMatch, Action<IApplicationBuilder> configuration)

Original Issue

When using minimal there is ambiguity when using app.Map("/", builder => {}); between IApplicationBuilder Map(this IApplicationBuilder app, PathString pathMatch, Action<IApplicationBuilder> configuration) https://github.com/dotnet/aspnetcore/blob/ff51fd7105a9003841215f1f3b0b8fc9e2998a67/src/Http/Http.Abstractions/src/Extensions/MapExtensions.cs#L23 and public static MinimalActionEndpointConventionBuilder Map(this IEndpointRouteBuilder endpoints, string pattern, Delegate action) https://github.com/dotnet/aspnetcore/blob/ff51fd7105a9003841215f1f3b0b8fc9e2998a67/src/Http/Routing/src/Builder/MinimalActionEndpointRouteBuilderExtensions.cs#L123

image

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (16 by maintainers)

Most upvoted comments

I reopened https://github.com/dotnet/roslyn/issues/55691 because there’s still some weirdness there if you specify IApplicationBuilder as the parameter type in the lambda, but I think the main scenario where the parameter type is unspecified (or specified to be anything other than IApplicationBuilder) is addressed, so I’ll leave this closed.