-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Separate IResult based results from ActionResults #33843
Conversation
Why a new assembly? |
The results depend on M.A.Routing which adds a circular dependency if they are in M.A.H.Extensions. |
|
||
public Task ExecuteAsync(HttpContext httpContext) | ||
{ | ||
var loggerFactory = httpContext.RequestServices.GetRequiredService<ILoggerFactory>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're going to want to cache these calls to the logger, but that should be in another PR. My guess is that we haven't looked at this cost in MVC.
private static Action<ILogger, StringValues, string, Exception?> _copyingFileRange; | ||
private static Action<ILogger, Exception?> _writeCancelled; | ||
private static Action<ILogger, Exception?> _endpointMatched; | ||
private static readonly Action<ILogger, string, Exception?> _methodNotSupported; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Source generator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's this analyzer - which is a suggestion, but shows up as warnings in VS: https://github.com/dotnet/aspnetcore/blob/main/.editorconfig#L100-L101. Source generator to happen separately.
src/Http/Http.Results/src/Results.cs
Outdated
/// <summary> | ||
/// Creates a <see cref="ChallengeResult"/>. | ||
/// </summary> | ||
/// <returns>The created <see cref="ChallengeResult"/> for the response.</returns> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it OK to refer to internal types in these public doc comments? What happens when API doc is generated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API docs will referer to the type full name, and completion colorizes it correctly, but you're not able to control click on the type to get there. Not super weird. I didn't change the doc comments much as I mas transferring them from MVC, but if you feel strongly about it, I can do a pass to clean it up.
src/Http/Http.Results/src/Results.cs
Outdated
/// Creates a <see cref="AcceptedResult"/> object that produces an <see cref="StatusCodes.Status202Accepted"/> response. | ||
/// </summary> | ||
/// <param name="uri">The optional URI with the location at which the status of requested content can be monitored. | ||
/// May be null.</param> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're not consistent with how we document nullable ref types in params. Some are 'blah blah; may be null', others are like this one. Let's just pick one form and stick with it.
src/Http/Http.Results/src/Results.cs
Outdated
/// <summary> | ||
/// Creates a <see cref="AcceptedResult"/> object that produces an <see cref="StatusCodes.Status202Accepted"/> response. | ||
/// </summary> | ||
/// <param name="value">The optional content value to format in the entity body; may be null.</param> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might 'response body' be clearer language than 'entity body'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I think this comment might have been from WebAPI2 which tends to use the RFC names
string contentType, | ||
string? fileDownloadName, | ||
bool enableRangeProcessing) | ||
=> new PhysicalFileResult(physicalPath, contentType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious, why is this one expression bodied but the next one not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somebody forgot to update MVC: https://github.com/dotnet/aspnetcore/blob/main/src/Mvc/Mvc.Core/src/ControllerBase.cs#L1647-L1677
803688f
to
025962d
Compare
025962d
to
7d22183
Compare
@pranavkm can you make one of the samples use these? |
Curious: I skimmed the projects but couldn't find a reference to the new project. Other than the samples @davidfowl suggested, where will the assembly be used❔ |
@dougbu the plan is to use these in the minimal actions project template. I updated a functional test to use some of these result types. |
Co-authored-by: Martin Costello <martin@martincostello.com>
3244ce7
to
b330b73
Compare
Fixes #33729