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
using System.Runtime.CompilerServices;publicpartialclassC{publicpartialvoidM1(stringa,[CallerArgumentExpression("a")]string?b=null);// warning CS8963: The CallerArgumentExpressionAttribute applied to parameter 'y' will have no effect. It is applied with an invalid parameter name.publicpartialvoidM1(stringx,string?y){}publicpartialvoidM2(stringa,[CallerArgumentExpression("a")]string?b=null);// okpublicpartialvoidM2(stringa,string?b){}voidM(){// Call sites use the definition part parameter names
M1(a:"1");// ok
M1(x:"1");// error}}
Expected Behavior: The definition part parameter name is used to decide what parameter to include a caller argument expression for
Actual Behavior: The implementation part parameter name is used
Note that using the attribute on the implementation part results in the attribute being ignored in source. So, it feels like the attribute's parameter name references should be oriented around the declaration where usage of the attribute is supported.
The text was updated successfully, but these errors were encountered:
Instead of using ContainingSymbol, This probably should be (ContainingSymbol as MethodSymbol)?.PartialDefinitionPart ?? ContainingSymbol.
Edit: Reading the code and thinking again, I think ContainingSymbol should actually have been the definition part. Needs a bit of debugging to see what ContainingSymbol is in this code path.
Agree the declaration name makes more sense but this is now 15 year old behavior. Changing it is very risky. Think this should be documented but not changed.
This seems very specific to caller argument expression and not caller info attributes in general. Am I missing some scenario where a similar issue could be noticed with other caller infos?
Version Used: fca6e1f
Steps to Reproduce: SharpLab
Expected Behavior: The definition part parameter name is used to decide what parameter to include a caller argument expression for
Actual Behavior: The implementation part parameter name is used
caller-argument-expression.md does not appear to specify what should happen here.
Note that using the attribute on the implementation part results in the attribute being ignored in source. So, it feels like the attribute's parameter name references should be oriented around the declaration where usage of the attribute is supported.
The text was updated successfully, but these errors were encountered: