Skip to content

Commit e7d8643

Browse files
RexJaeschkeBillWagner
authored andcommitted
mention extension methods, and grouping parens
1 parent 6ae6001 commit e7d8643

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

standard/attributes.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ For an invocation that occurs within a local function or an anonymous function,
885885
886886
The attribute `System.Runtime.CompilerServices.CallerArgumentExpression` is applied to a *target parameter*, and can result in the capture of the source-code text of a sibling parameter’s argument as a string, referred to here as the *captured string*.
887887
888-
The target parameter shall have a *default_argument*.
888+
Except when it is the first parameter in an extension method, the target parameter shall have a *default_argument*.
889889
890890
Consider the following method declaration:
891891
@@ -918,7 +918,8 @@ The type of the target parameter shall have a standard conversion from `string`.
918918
919919
If an explicit argument is passed for the target parameter, no string is captured, and that parameter takes on that arguments value. Otherwise, the text for the argument corresponding to the sibling parameter is converted to a captured string, according to the following rules:
920920
921-
- Leading and trailing white space is removed.
921+
- Leading and trailing white space is removed both before and after any outermost grouping parentheses are removed.
922+
- All outermost grouping parentheses are removed both before and after any leading and trailing white space is removed.
922923
- All other *input_element*s are retained verbatim (including white space, comments, *Unicode_Escape_Sequence*s, and `@` prefixes on identifiers).
923924
924925
The captured string is then passed as the argument corresponding to the target parameter. However, if the argument for the sibling parameter is omitted, the target parameter takes on its *default_argument* value.
@@ -932,6 +933,7 @@ The captured string is then passed as the argument corresponding to the target p
932933
> Test.M(123, null);
933934
> Test.M(123, "xyz");
934935
> Test.M( 1 + 2 );
936+
> Test.M( ( ((123) + 0) ) );
935937
> int local = 10;
936938
> Test.M(l\u006fcal /*...*/ + // xxx
937939
> 5);
@@ -945,6 +947,7 @@ The captured string is then passed as the argument corresponding to the target p
945947
> val = 123, text = <>
946948
> val = 123, text = <xyz>
947949
> val = 3, text = <1 + 2>
950+
> val = 123, text = <(123 + 0)>
948951
> val = 15, text = <l\u006fcal /*...*/ + // xxx
949952
> 5>
950953
> ```

0 commit comments

Comments
 (0)