Skip to content

Commit 740a3b3

Browse files
RexJaeschkeBillWagner
authored andcommitted
mention extension methods, and grouping parens
1 parent 1756dc0 commit 740a3b3

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
@@ -849,7 +849,7 @@ For an invocation that occurs within a local function, the name of the method th
849849
850850
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*.
851851
852-
The target parameter shall have a *default_argument*.
852+
Except when it is the first parameter in an extension method, the target parameter shall have a *default_argument*.
853853
854854
Consider the following method declaration:
855855
@@ -882,7 +882,8 @@ The type of the target parameter shall have a standard conversion from `string`.
882882
883883
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:
884884
885-
- Leading and trailing white space is removed.
885+
- Leading and trailing white space is removed both before and after any outermost grouping parentheses are removed.
886+
- All outermost grouping parentheses are removed both before and after any leading and trailing white space is removed.
886887
- All other *input_element*s are retained verbatim (including white space, comments, *Unicode_Escape_Sequence*s, and `@` prefixes on identifiers).
887888
888889
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.
@@ -896,6 +897,7 @@ The captured string is then passed as the argument corresponding to the target p
896897
> Test.M(123, null);
897898
> Test.M(123, "xyz");
898899
> Test.M( 1 + 2 );
900+
> Test.M( ( ((123) + 0) ) );
899901
> int local = 10;
900902
> Test.M(l\u006fcal /*...*/ + // xxx
901903
> 5);
@@ -909,6 +911,7 @@ The captured string is then passed as the argument corresponding to the target p
909911
> val = 123, text = <>
910912
> val = 123, text = <xyz>
911913
> val = 3, text = <1 + 2>
914+
> val = 123, text = <(123 + 0)>
912915
> val = 15, text = <l\u006fcal /*...*/ + // xxx
913916
> 5>
914917
> ```

0 commit comments

Comments
 (0)