-
Notifications
You must be signed in to change notification settings - Fork 10.4k
First pass at basic query string parameters. #46545
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
Merged
mitchdenny
merged 13 commits into
dotnet:main
from
mitchdenny:request-delegate-gen-basic-string-parameters
Feb 14, 2023
Merged
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d8dc221
First pass at basic string parameters.
mitchdenny 5b1d26a
Tidy up based on feedback.
mitchdenny ad116ac
Update src/Http/Http.Extensions/gen/StaticRouteHandlerModel/Emitters/…
mitchdenny 8dbd0f0
Update src/Http/Http.Extensions/gen/StaticRouteHandlerModel/EndpointP…
mitchdenny c6d8d64
Update src/Http/Http.Extensions/gen/StaticRouteHandlerModel/StaticRou…
mitchdenny ad40133
Null handling test cases.
mitchdenny b028f52
Fix indentation and add additional baselines.
mitchdenny 1067a87
Fix up test base and build errors from filtered request handler.
mitchdenny 0a847ac
Whitespace change to force push to happen.
mitchdenny dd1d94b
Remove whitespace again.
mitchdenny ec74e2e
Remove rogue namespaces.
mitchdenny 3c93d20
PR feedback. Stray newline and && true removal.
mitchdenny d0a729e
Revert "Whitespace change to force push to happen."
mitchdenny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/Http/Http.Extensions/gen/StaticRouteHandlerModel/Emitters/EndpointEmitter.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Microsoft.AspNetCore.Http.Generators.StaticRouteHandlerModel.Emitters; | ||
internal static class EndpointEmitter | ||
{ | ||
internal static string EmitParameterPreparation(this Endpoint endpoint) | ||
{ | ||
var parameterPreparationBuilder = new StringBuilder(); | ||
|
||
foreach (var parameter in endpoint.Parameters) | ||
{ | ||
var parameterPreparationCode = parameter switch | ||
{ | ||
{ | ||
Source: EndpointParameterSource.SpecialType | ||
} => parameter.EmitSpecialParameterPreparation(), | ||
{ | ||
Source: EndpointParameterSource.Query, | ||
} => parameter.EmitQueryParameterPreparation(), | ||
_ => throw new Exception("Unreachable!") | ||
}; | ||
|
||
parameterPreparationBuilder.AppendLine(parameterPreparationCode); | ||
} | ||
|
||
return parameterPreparationBuilder.ToString(); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/Http/Http.Extensions/gen/StaticRouteHandlerModel/Emitters/EndpointParameterEmitter.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Microsoft.AspNetCore.Http.Generators.StaticRouteHandlerModel.Emitters; | ||
internal static class EndpointParameterEmitter | ||
{ | ||
internal static string EmitSpecialParameterPreparation(this EndpointParameter endpointParameter) | ||
{ | ||
return $""" | ||
var {endpointParameter.Name}_local = {endpointParameter.AssigningCode}; | ||
"""; | ||
} | ||
|
||
internal static string EmitQueryParameterPreparation(this EndpointParameter endpointParameter) | ||
{ | ||
return $$""" | ||
var {{endpointParameter.Name}}_raw = {{endpointParameter.AssigningCode}}; | ||
|
||
if (StringValues.IsNullOrEmpty({{endpointParameter.Name}}_raw) && {{(endpointParameter.IsOptional ? "false" : "false")}}) | ||
{ | ||
httpContext.Response.StatusCode = 400; | ||
return Task.CompletedTask; | ||
} | ||
|
||
var {{endpointParameter.HandlerArgument}} = {{endpointParameter.Name}}_raw.ToString(); | ||
"""; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 0 additions & 45 deletions
45
src/Http/Http.Extensions/gen/StaticRouteHandlerModel/WellKnownTypeData.cs
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.