-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Add support for RouteHandlerInvocationContext<> overloads #41406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
07033c9
033bc58
93a6726
5dd971f
5ce83fc
d87d6a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace Microsoft.AspNetCore.Http; | ||
|
||
/// <summary> | ||
/// Provides a default implementation for wrapping the <see cref="HttpContext"/> and parameters | ||
/// provided to a route handler. | ||
/// </summary> | ||
public class DefaultRouteHandlerInvocationContext : RouteHandlerInvocationContext | ||
{ | ||
/// <summary> | ||
/// Creates a new instance of the <see cref="DefaultRouteHandlerInvocationContext"/> for a given request. | ||
/// </summary> | ||
/// <param name="httpContext">The <see cref="HttpContext"/> associated with the current request.</param> | ||
/// <param name="arguments">A list of parameters provided in the current request.</param> | ||
public DefaultRouteHandlerInvocationContext(HttpContext httpContext, params object[] arguments) | ||
{ | ||
HttpContext = httpContext; | ||
Arguments = arguments; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override HttpContext HttpContext { get; } | ||
|
||
/// <inheritdoc /> | ||
public override IList<object?> Arguments { get; } | ||
|
||
/// <inheritdoc /> | ||
public override T GetArgument<T>(int index) | ||
{ | ||
return (T)Arguments[index]!; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,26 @@ Microsoft.AspNetCore.Http.HttpResponse</Description> | |
|
||
<ItemGroup> | ||
<InternalsVisibleTo Include="Microsoft.AspNetCore.Http.Abstractions.Microbenchmarks" /> | ||
<InternalsVisibleTo Include="Microsoft.AspNetCore.Http.Extensions" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="RouteHandlerInvocationContextOfT.Generated.tt"> | ||
<Generator>TextTemplatingFileGenerator</Generator> | ||
<LastGenOutput>RouteHandlerInvocationContextOfT.Generated.cs</LastGenOutput> | ||
</None> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we can include this in the global directory.props cc @dougbu There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean notice a project contains a .tt file and add the We only have 3 projects containing this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not an issue, I would just like to clean it up as we plan to code generate more things. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's up to you @davidfowl whether to centralize things in this PR. I recommend testing if the code in our root Directory.Build.props prevents VS rewriting the project to list the The specific approach would be something like
|
||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Update="RouteHandlerInvocationContextOfT.Generated.cs"> | ||
<DesignTime>True</DesignTime> | ||
<AutoGen>True</AutoGen> | ||
<DependentUpon>RouteHandlerInvocationContextOfT.Generated.tt</DependentUpon> | ||
</Compile> | ||
</ItemGroup> | ||
|
||
</Project> |
Uh oh!
There was an error while loading. Please reload this page.