-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Area-CompilersuntriagedIssues and PRs which have not yet been triaged by a leadIssues and PRs which have not yet been triaged by a lead
Description
Description
ParameterInfo.DefaultValue isn't available with local methods (and I'm guessing delegates as well). In this ASP.NET Core feature we want to use the default value information to make decisions about how a delegate will be called. e.g. use the default value when calling the method if no other value is available.
[Fact]
public void DefaultValueTest()
{
void TestAction([FromRoute] int foo1 = 5)
{
}
var method = GetType().GetMethod(nameof(TestAction), BindingFlags.Instance | BindingFlags.NonPublic)!;
var p1 = method.GetParameters();
Console.WriteLine(p1[0].HasDefaultValue);
Console.WriteLine(p1[0].DefaultValue);
// true
// 5
var d = (Action<int>)TestAction;
var p2 = d.Method.GetParameters();
Console.WriteLine(p2[0].HasDefaultValue);
Console.WriteLine(p2[0].DefaultValue);
// false
// DBNull.Value
}
private void TestAction([FromRoute] int foo1 = 5)
{
}Configuration
Host (useful for support):
Version: 6.0.0-preview.2.21154.6
Commit: 3eaf1f316b
Regression?
No
halter73 and metoule
Metadata
Metadata
Assignees
Labels
Area-CompilersuntriagedIssues and PRs which have not yet been triaged by a leadIssues and PRs which have not yet been triaged by a lead