|
1 | 1 | // Licensed to the .NET Foundation under one or more agreements.
|
2 | 2 | // The .NET Foundation licenses this file to you under the MIT license.
|
3 | 3 | using System.Collections.Immutable;
|
| 4 | +using System.Globalization; |
4 | 5 | using System.Text;
|
5 | 6 | using Microsoft.CodeAnalysis;
|
6 | 7 | using Microsoft.AspNetCore.Http.RequestDelegateGenerator;
|
@@ -96,6 +97,57 @@ public async Task SupportsDifferentInterceptorsFromSameLocation()
|
96 | 97 | await VerifyAgainstBaselineUsingFile(updatedCompilation);
|
97 | 98 | }
|
98 | 99 |
|
| 100 | + [Fact] |
| 101 | + public async Task SupportsMapCallOnNewLine() |
| 102 | + { |
| 103 | + var source = """ |
| 104 | +app |
| 105 | + .MapGet("/hello1/{id}", (int id) => $"Hello {id}!"); |
| 106 | +EndpointRouteBuilderExtensions |
| 107 | + .MapGet(app, "/hello2/{id}", (int id) => $"Hello {id}!"); |
| 108 | +app. |
| 109 | + MapGet("/hello1/{id}", (int id) => $"Hello {id}!"); |
| 110 | +EndpointRouteBuilderExtensions. |
| 111 | + MapGet(app, "/hello2/{id}", (int id) => $"Hello {id}!"); |
| 112 | +app. |
| 113 | +MapGet("/hello1/{id}", (int id) => $"Hello {id}!"); |
| 114 | +EndpointRouteBuilderExtensions. |
| 115 | +MapGet(app, "/hello2/{id}", (int id) => $"Hello {id}!"); |
| 116 | +app. |
| 117 | +
|
| 118 | +
|
| 119 | +MapGet("/hello1/{id}", (int id) => $"Hello {id}!"); |
| 120 | +EndpointRouteBuilderExtensions. |
| 121 | +
|
| 122 | +
|
| 123 | +MapGet(app, "/hello2/{id}", (int id) => $"Hello {id}!"); |
| 124 | +app. |
| 125 | +MapGet |
| 126 | +("/hello1/{id}", (int id) => $"Hello {id}!"); |
| 127 | +EndpointRouteBuilderExtensions. |
| 128 | + MapGet |
| 129 | +(app, "/hello2/{id}", (int id) => $"Hello {id}!"); |
| 130 | +app |
| 131 | +. |
| 132 | +MapGet |
| 133 | +("/hello1/{id}", (int id) => $"Hello {id}!"); |
| 134 | +EndpointRouteBuilderExtensions |
| 135 | +. |
| 136 | + MapGet |
| 137 | +(app, "/hello2/{id}", (int id) => $"Hello {id}!"); |
| 138 | +"""; |
| 139 | + var (_, compilation) = await RunGeneratorAsync(source); |
| 140 | + var endpoints = GetEndpointsFromCompilation(compilation); |
| 141 | + |
| 142 | + for (int i = 0; i < endpoints.Length; i++) |
| 143 | + { |
| 144 | + var httpContext = CreateHttpContext(); |
| 145 | + httpContext.Request.RouteValues["id"] = i.ToString(CultureInfo.InvariantCulture); |
| 146 | + await endpoints[i].RequestDelegate(httpContext); |
| 147 | + await VerifyResponseBodyAsync(httpContext, $"Hello {i}!"); |
| 148 | + } |
| 149 | + } |
| 150 | + |
99 | 151 | [Fact]
|
100 | 152 | public async Task SourceMapsAllPathsInAttribute()
|
101 | 153 | {
|
|
0 commit comments