Skip to content
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

Merged
merged 7 commits into from
Jun 30, 2021
Merged

Conversation

pranavkm
Copy link
Contributor

@pranavkm pranavkm commented Jun 25, 2021

Fixes #33729

@davidfowl
Copy link
Member

Why a new assembly?

@pranavkm
Copy link
Contributor Author

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>();
Copy link
Member

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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source generator?

Copy link
Contributor Author

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.

/// <summary>
/// Creates a <see cref="ChallengeResult"/>.
/// </summary>
/// <returns>The created <see cref="ChallengeResult"/> for the response.</returns>
Copy link
Member

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?

Copy link
Contributor Author

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.

/// 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>
Copy link
Member

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.

/// <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>
Copy link
Member

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'?

Copy link
Contributor Author

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)
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pranavkm pranavkm force-pushed the prkrishn/results branch 3 times, most recently from 803688f to 025962d Compare June 26, 2021 19:23
@pranavkm pranavkm marked this pull request as ready for review June 26, 2021 19:23
@davidfowl
Copy link
Member

@pranavkm can you make one of the samples use these?

@dougbu
Copy link
Member

dougbu commented Jun 27, 2021

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❔

@pranavkm
Copy link
Contributor Author

@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.

pranavkm and others added 2 commits June 28, 2021 13:45
Co-authored-by: Martin Costello <martin@martincostello.com>
@pranavkm pranavkm enabled auto-merge (squash) June 30, 2021 16:59
@pranavkm pranavkm merged commit b9efadc into main Jun 30, 2021
@pranavkm pranavkm deleted the prkrishn/results branch June 30, 2021 17:32
@ghost ghost added this to the 6.0-preview7 milestone Jun 30, 2021
@amcasey amcasey added area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares and removed area-runtime labels Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create IResult-returning static methods
8 participants