Skip to content

Commit 19c9306

Browse files
authored
Remove RequiresUnreferencedCode from low-level endpoint map methods (#42519)
1 parent 86c7e01 commit 19c9306

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

src/Http/HttpAbstractions.slnf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
"solution": {
33
"path": "..\\..\\AspNetCore.sln",
44
"projects": [
5+
"src\\DataProtection\\Abstractions\\src\\Microsoft.AspNetCore.DataProtection.Abstractions.csproj",
6+
"src\\DataProtection\\Cryptography.Internal\\src\\Microsoft.AspNetCore.Cryptography.Internal.csproj",
7+
"src\\DataProtection\\DataProtection\\src\\Microsoft.AspNetCore.DataProtection.csproj",
8+
"src\\DefaultBuilder\\src\\Microsoft.AspNetCore.csproj",
59
"src\\Extensions\\Features\\src\\Microsoft.Extensions.Features.csproj",
610
"src\\Extensions\\Features\\test\\Microsoft.Extensions.Features.Tests.csproj",
711
"src\\Hosting\\Abstractions\\src\\Microsoft.AspNetCore.Hosting.Abstractions.csproj",
@@ -43,15 +47,25 @@
4347
"src\\Http\\samples\\MinimalSample\\MinimalSample.csproj",
4448
"src\\Http\\samples\\SampleApp\\HttpAbstractions.SampleApp.csproj",
4549
"src\\Middleware\\CORS\\src\\Microsoft.AspNetCore.Cors.csproj",
50+
"src\\Middleware\\Diagnostics.Abstractions\\src\\Microsoft.AspNetCore.Diagnostics.Abstractions.csproj",
51+
"src\\Middleware\\Diagnostics\\src\\Microsoft.AspNetCore.Diagnostics.csproj",
52+
"src\\Middleware\\HostFiltering\\src\\Microsoft.AspNetCore.HostFiltering.csproj",
4653
"src\\Middleware\\HttpOverrides\\src\\Microsoft.AspNetCore.HttpOverrides.csproj",
54+
"src\\Middleware\\OutputCaching\\src\\Microsoft.AspNetCore.OutputCaching.csproj",
55+
"src\\Middleware\\ResponseCaching.Abstractions\\src\\Microsoft.AspNetCore.ResponseCaching.Abstractions.csproj",
4756
"src\\Middleware\\StaticFiles\\src\\Microsoft.AspNetCore.StaticFiles.csproj",
57+
"src\\Mvc\\Mvc.Abstractions\\src\\Microsoft.AspNetCore.Mvc.Abstractions.csproj",
58+
"src\\Mvc\\Mvc.Core\\src\\Microsoft.AspNetCore.Mvc.Core.csproj",
4859
"src\\ObjectPool\\src\\Microsoft.Extensions.ObjectPool.csproj",
60+
"src\\Security\\Authentication\\Core\\src\\Microsoft.AspNetCore.Authentication.csproj",
4961
"src\\Security\\Authorization\\Core\\src\\Microsoft.AspNetCore.Authorization.csproj",
5062
"src\\Security\\Authorization\\Policy\\src\\Microsoft.AspNetCore.Authorization.Policy.csproj",
5163
"src\\Servers\\Connections.Abstractions\\src\\Microsoft.AspNetCore.Connections.Abstractions.csproj",
5264
"src\\Servers\\IIS\\IISIntegration\\src\\Microsoft.AspNetCore.Server.IISIntegration.csproj",
65+
"src\\Servers\\IIS\\IIS\\src\\Microsoft.AspNetCore.Server.IIS.csproj",
5366
"src\\Servers\\Kestrel\\Core\\src\\Microsoft.AspNetCore.Server.Kestrel.Core.csproj",
5467
"src\\Servers\\Kestrel\\Kestrel\\src\\Microsoft.AspNetCore.Server.Kestrel.csproj",
68+
"src\\Servers\\Kestrel\\Transport.Quic\\src\\Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.csproj",
5569
"src\\Servers\\Kestrel\\Transport.Sockets\\src\\Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.csproj",
5670
"src\\Testing\\src\\Microsoft.AspNetCore.Testing.csproj",
5771
"src\\WebEncoders\\src\\Microsoft.Extensions.WebEncoders.csproj"

src/Http/Routing/src/Builder/EndpointRouteBuilderExtensions.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ public static RouteGroupBuilder MapGroup(this IEndpointRouteBuilder endpoints, R
6363
/// <param name="pattern">The route pattern.</param>
6464
/// <param name="requestDelegate">The delegate executed when the endpoint is matched.</param>
6565
/// <returns>A <see cref="IEndpointConventionBuilder"/> that can be used to further customize the endpoint.</returns>
66-
[RequiresUnreferencedCode(MapEndpointTrimmerWarning)]
6766
public static IEndpointConventionBuilder MapGet(
6867
this IEndpointRouteBuilder endpoints,
6968
[StringSyntax("Route")] string pattern,
@@ -80,7 +79,6 @@ public static IEndpointConventionBuilder MapGet(
8079
/// <param name="pattern">The route pattern.</param>
8180
/// <param name="requestDelegate">The delegate executed when the endpoint is matched.</param>
8281
/// <returns>A <see cref="IEndpointConventionBuilder"/> that can be used to further customize the endpoint.</returns>
83-
[RequiresUnreferencedCode(MapEndpointTrimmerWarning)]
8482
public static IEndpointConventionBuilder MapPost(
8583
this IEndpointRouteBuilder endpoints,
8684
[StringSyntax("Route")] string pattern,
@@ -97,7 +95,6 @@ public static IEndpointConventionBuilder MapPost(
9795
/// <param name="pattern">The route pattern.</param>
9896
/// <param name="requestDelegate">The delegate executed when the endpoint is matched.</param>
9997
/// <returns>A <see cref="IEndpointConventionBuilder"/> that can be used to further customize the endpoint.</returns>
100-
[RequiresUnreferencedCode(MapEndpointTrimmerWarning)]
10198
public static IEndpointConventionBuilder MapPut(
10299
this IEndpointRouteBuilder endpoints,
103100
[StringSyntax("Route")] string pattern,
@@ -114,7 +111,6 @@ public static IEndpointConventionBuilder MapPut(
114111
/// <param name="pattern">The route pattern.</param>
115112
/// <param name="requestDelegate">The delegate executed when the endpoint is matched.</param>
116113
/// <returns>A <see cref="IEndpointConventionBuilder"/> that can be used to further customize the endpoint.</returns>
117-
[RequiresUnreferencedCode(MapEndpointTrimmerWarning)]
118114
public static IEndpointConventionBuilder MapDelete(
119115
this IEndpointRouteBuilder endpoints,
120116
[StringSyntax("Route")] string pattern,
@@ -131,7 +127,6 @@ public static IEndpointConventionBuilder MapDelete(
131127
/// <param name="pattern">The route pattern.</param>
132128
/// <param name="requestDelegate">The delegate executed when the endpoint is matched.</param>
133129
/// <returns>A <see cref="IEndpointConventionBuilder"/> that can be used to further customize the endpoint.</returns>
134-
[RequiresUnreferencedCode(MapEndpointTrimmerWarning)]
135130
public static IEndpointConventionBuilder MapPatch(
136131
this IEndpointRouteBuilder endpoints,
137132
[StringSyntax("Route")] string pattern,
@@ -149,7 +144,6 @@ public static IEndpointConventionBuilder MapPatch(
149144
/// <param name="requestDelegate">The delegate executed when the endpoint is matched.</param>
150145
/// <param name="httpMethods">HTTP methods that the endpoint will match.</param>
151146
/// <returns>A <see cref="IEndpointConventionBuilder"/> that can be used to further customize the endpoint.</returns>
152-
[RequiresUnreferencedCode(MapEndpointTrimmerWarning)]
153147
public static IEndpointConventionBuilder MapMethods(
154148
this IEndpointRouteBuilder endpoints,
155149
[StringSyntax("Route")] string pattern,
@@ -172,7 +166,6 @@ public static IEndpointConventionBuilder MapMethods(
172166
/// <param name="pattern">The route pattern.</param>
173167
/// <param name="requestDelegate">The delegate executed when the endpoint is matched.</param>
174168
/// <returns>A <see cref="IEndpointConventionBuilder"/> that can be used to further customize the endpoint.</returns>
175-
[RequiresUnreferencedCode(MapEndpointTrimmerWarning)]
176169
public static IEndpointConventionBuilder Map(
177170
this IEndpointRouteBuilder endpoints,
178171
[StringSyntax("Route")] string pattern,
@@ -189,7 +182,6 @@ public static IEndpointConventionBuilder Map(
189182
/// <param name="pattern">The route pattern.</param>
190183
/// <param name="requestDelegate">The delegate executed when the endpoint is matched.</param>
191184
/// <returns>A <see cref="IEndpointConventionBuilder"/> that can be used to further customize the endpoint.</returns>
192-
[RequiresUnreferencedCode(MapEndpointTrimmerWarning)]
193185
public static IEndpointConventionBuilder Map(
194186
this IEndpointRouteBuilder endpoints,
195187
RoutePattern pattern,
@@ -199,12 +191,6 @@ public static IEndpointConventionBuilder Map(
199191
ArgumentNullException.ThrowIfNull(pattern);
200192
ArgumentNullException.ThrowIfNull(requestDelegate);
201193

202-
var returnType = requestDelegate.Method.ReturnType;
203-
if (returnType.IsGenericType && returnType.GetGenericTypeDefinition() == typeof(Task<>))
204-
{
205-
return Map(endpoints, pattern, requestDelegate as Delegate);
206-
}
207-
208194
const int defaultOrder = 0;
209195

210196
var builder = new RouteEndpointBuilder(

src/Http/Routing/test/UnitTests/Builder/RequestDelegateEndpointRouteBuilderExtensionsTest.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,28 @@ public static object[][] MapMethods
3535
{
3636
get
3737
{
38-
IEndpointConventionBuilder MapGet(IEndpointRouteBuilder routes, string template, RequestDelegate action) =>
38+
IEndpointConventionBuilder MapGet(IEndpointRouteBuilder routes, string template, Delegate action) =>
3939
routes.MapGet(template, action);
4040

41-
IEndpointConventionBuilder MapPost(IEndpointRouteBuilder routes, string template, RequestDelegate action) =>
41+
IEndpointConventionBuilder MapPost(IEndpointRouteBuilder routes, string template, Delegate action) =>
4242
routes.MapPost(template, action);
4343

44-
IEndpointConventionBuilder MapPut(IEndpointRouteBuilder routes, string template, RequestDelegate action) =>
44+
IEndpointConventionBuilder MapPut(IEndpointRouteBuilder routes, string template, Delegate action) =>
4545
routes.MapPut(template, action);
4646

47-
IEndpointConventionBuilder MapDelete(IEndpointRouteBuilder routes, string template, RequestDelegate action) =>
47+
IEndpointConventionBuilder MapDelete(IEndpointRouteBuilder routes, string template, Delegate action) =>
4848
routes.MapDelete(template, action);
4949

50-
IEndpointConventionBuilder Map(IEndpointRouteBuilder routes, string template, RequestDelegate action) =>
50+
IEndpointConventionBuilder Map(IEndpointRouteBuilder routes, string template, Delegate action) =>
5151
routes.Map(template, action);
5252

5353
return new object[][]
5454
{
55-
new object[] { (Func<IEndpointRouteBuilder, string, RequestDelegate, IEndpointConventionBuilder>)MapGet },
56-
new object[] { (Func<IEndpointRouteBuilder, string, RequestDelegate, IEndpointConventionBuilder>)MapPost },
57-
new object[] { (Func<IEndpointRouteBuilder, string, RequestDelegate, IEndpointConventionBuilder>)MapPut },
58-
new object[] { (Func<IEndpointRouteBuilder, string, RequestDelegate, IEndpointConventionBuilder>)MapDelete },
59-
new object[] { (Func<IEndpointRouteBuilder, string, RequestDelegate, IEndpointConventionBuilder>)Map },
55+
new object[] { (Func<IEndpointRouteBuilder, string, Delegate, IEndpointConventionBuilder>)MapGet },
56+
new object[] { (Func<IEndpointRouteBuilder, string, Delegate, IEndpointConventionBuilder>)MapPost },
57+
new object[] { (Func<IEndpointRouteBuilder, string, Delegate, IEndpointConventionBuilder>)MapPut },
58+
new object[] { (Func<IEndpointRouteBuilder, string, Delegate, IEndpointConventionBuilder>)MapDelete },
59+
new object[] { (Func<IEndpointRouteBuilder, string, Delegate, IEndpointConventionBuilder>)Map },
6060
};
6161
}
6262
}
@@ -81,7 +81,7 @@ public void MapEndpoint_StringPattern_BuildsEndpoint()
8181

8282
[Theory]
8383
[MemberData(nameof(MapMethods))]
84-
public async Task MapEndpoint_ReturnGenericTypeTask_GeneratedDelegate(Func<IEndpointRouteBuilder, string, RequestDelegate, IEndpointConventionBuilder> map)
84+
public async Task MapEndpoint_ReturnGenericTypeTask_GeneratedDelegate(Func<IEndpointRouteBuilder, string, Delegate, IEndpointConventionBuilder> map)
8585
{
8686
var httpContext = new DefaultHttpContext();
8787
var responseBodyStream = new MemoryStream();

0 commit comments

Comments
 (0)