You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Well-known attributes that affect constant parameters
DefaultValueAttribute
CallerInfoX
Params
unsafe scenarios
sizeof
int* parameter with null default value
Non-default parameters trailing
Mismatched default parameters between lambda and target delegate type
Both have different constant values - Error
Target delegate has constant value, lambda does not - Valid
Target delegate does not have constant value, lambda does - Error
Mismatched default parameters between method group and target delegate type
Both have different constant values - Warning
Target delegate has constant value, method does not - Valid
Target delegate does not have constant value, method does - Valid
Conversion between different delegate types is unaffected
var produces anonymous delegate type with default parameters and does not use Action/Func
Lambda
Method group
Nullability analysis
Discard parameters with defaults.
Does (dynamic d = null) => { } create a delegate with dynamic parameter type? (Same question for (dynamic d, ref int i) => { }.)
Do (T t = default) => { }, (T t = null) => { } share a delegate type when T is appropriately constrained?
MemberSemanticModel should be parented to the correct outer SemanticModel
symbols for locals declared outside of a lambda referenced inside default value should be reference identical to symbols returned by GetDeclaredSymbol for the locals and for references to the locals outside of the lambda
binder chain should be shared with member model for the enclosing method body
step through the code to make sure the correct things happen
SpeculativeSemanticModel to ensure errors from default parameter values are not added to declaration table
Expression trees: follow up with LDM on whether it should be allowed
new[] { (int i = 1) => { }, (int i = 2) => { } } is there a best common type or an error?
Championed issue: dotnet/csharplang#6051
Spec: https://github.com/dotnet/csharplang/blob/main/proposals/csharp-12.0/lambda-method-group-defaults.md
General
Syntax
=arglistwith initializer(int i = > 0) => { }Semantics
unsafescenariossizeofint*parameter withnulldefault valuevarproduces anonymous delegate type with default parameters and does not use Action/Func(dynamic d = null) => { }create a delegate withdynamicparameter type? (Same question for(dynamic d, ref int i) => { }.)(T t = default) => { },(T t = null) => { }share a delegate type whenTis appropriately constrained?new[] { (int i = 1) => { }, (int i = 2) => { } }is there a best common type or an error?Emit
Invokemethod for the lambda has default parametersProductivity
var