-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Support optional input for MapAction #30434
Conversation
Ping @halter73! |
I'm not sure we want to do this. This will result in LOTS of allocations (see #30390). |
src/Http/Routing/src/Internal/MapActionExpressionTreeBuilder.cs
Outdated
Show resolved
Hide resolved
src/Http/Routing/src/Internal/MapActionExpressionTreeBuilder.cs
Outdated
Show resolved
Hide resolved
src/Http/Routing/src/Internal/MapActionExpressionTreeBuilder.cs
Outdated
Show resolved
Hide resolved
src/Http/Routing/src/Internal/MapActionExpressionTreeBuilder.cs
Outdated
Show resolved
Hide resolved
What if the |
We're going to make it cheap but not as part of this PR. We also don't pass the token anywhere except when doing big IO transfers (like copying files) so I'd leave it for now |
src/Http/Routing/test/UnitTests/Internal/MapActionExpressionTreeBuilderTest.cs
Show resolved
Hide resolved
|
||
void TestAction([FromRoute] int value) | ||
public static IEnumerable<object[]> FromRouteOptionalResult |
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.
Nit: Any particular reason for using local functions for FromRouteResult but not FromRouteOptionalResult?
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 looks like local functions are not generating the optional parameter and handles then in compile time.
According to Sharplab.io, this code:
public void M()
{
Test();
void Test(int a = 2)
{
}
}
will be compiled to this:
public void M()
{
<M>g__Test|0_0(2);
}
[CompilerGenerated]
internal static void <M>g__Test|0_0(int a)
{
}
Perhaps this is another feature that could be asked from C# team?
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.
Issue filed: dotnet/roslyn#51518
I also requested that lambdas add support for optional parameters as part of the C# 10 lambda improvements: dotnet/csharplang#4451 (comment)
Hello @halter73! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
ValueTask
outputPassHttpContext.RequestAborted
toWriteAsJsonAsync()
,WriteAsync()
,ReadFromJsonAsync()
,ReadFormAsync()
Addresses #30248