Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions standard/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ The captured string is then passed as the argument corresponding to the target p
>
> *end example*
>
> *Example*: An optional target parameter can capture an extension method's receiver by naming the first parameter. Both invocation forms below capture `value`:
> *Example*: An optional target parameter can capture an extension method’s receiver by naming the first parameter. Both invocation forms below capture `value`:
>
> <!-- Example: {template:"standalone-console-without-using", name:"CallerArgumentAttr3", inferOutput:true} -->
> ```csharp
Expand Down Expand Up @@ -1563,7 +1563,7 @@ Constructor binding is performed on `T` using this argument list and the ordinar
Append methods are resolved only for components present in the *interpolated_string_handler_expression*:

- For each nonempty literal segment, an invocation of `AppendLiteral` is resolved with one value argument of type `string`.
- For each interpolation, an invocation of `AppendFormatted` is resolved. Its first argument is the interpolation's *expression*, passed by value. If an *interpolation_minimum_width* is present, its constant value is supplied as a named argument `alignment`. If a format specifier is present, its text is supplied as a named argument `format`.
- For each interpolation, an invocation of `AppendFormatted` is resolved. Its first argument is the interpolation’s *expression*, passed by value. If an *interpolation_minimum_width* is present, its constant value is supplied as a named argument `alignment`. If a format specifier is present, its text is supplied as a named argument `format`.

Member lookup and overload resolution use the ordinary rules for invocation through an instance of `T` ([§12.8.10.2](expressions.md#128102-method-invocations)). Each selected append method shall be an accessible instance method; extension methods are not considered. Optional parameters, generic inference, and argument conversions apply as usual. Every selected append method shall return either `void` or `bool` by value, and all selected append methods shall return the same type. A missing, ambiguous, or otherwise invalid required method is a compile-time error.

Expand Down Expand Up @@ -1622,7 +1622,7 @@ Handler conversion does not implicitly invoke `ToString` or require a handler to

##### 23.5.11.1.2 Inhibiting a custom handler

If constructor resolution selects a constructor with an `out bool` argument, that argument's value is tested after construction. If it is `true`, component processing begins. If it is `false`, the handler is *inhibited*: no interpolation expression is evaluated and no append method is called. This test is separate from the short-circuiting performed after each bool-returning append call.
If constructor resolution selects a constructor with an `out bool` argument, that argument’s value is tested after construction. If it is `true`, component processing begins. If it is `false`, the handler is *inhibited*: no interpolation expression is evaluated and no append method is called. This test is separate from the short-circuiting performed after each bool-returning append call.

``` csharp
public LogInterpolatedStringHandler(int literalLength, int formattedCount,
Expand Down Expand Up @@ -1672,9 +1672,9 @@ public ref struct LogInterpolatedStringHandler

`InterpolatedStringHandlerArgumentAttribute` is applied to the handler parameter. Its arguments specify an ordered list of parameter names to forward to the handler constructor. An empty list forwards nothing. An empty string designates the receiver of the containing invocation.

Each nonempty name shall identify another parameter of the containing member. An unknown name, the handler parameter's own name, or a request for an unavailable receiver, including that of a static method, is a compile-time error. A declaration may produce a warning if a named parameter is declared after the handler parameter; this does not make the declaration invalid.
Each nonempty name shall identify another parameter of the containing member. An unknown name, the handler parameter’s own name, or a request for an unavailable receiver, including that of a static method, is a compile-time error. A declaration may produce a warning if a named parameter is declared after the handler parameter; this does not make the declaration invalid.

At a use of the handler conversion, each forwarded argument shall occur lexically before the *interpolated_string_handler_expression* in the invocation's argument list. A forwarded argument cannot be omitted and supplied by a parameter's default value. These requirements depend on call-site order, not declaration order; named arguments can therefore make a warned declaration usable. A request to forward an indexer receiver when the indexer is an *initializer_target* in a *member_initializer* is a compile-time error.
At a use of the handler conversion, each forwarded argument shall occur lexically before the *interpolated_string_handler_expression* in the invocation’s argument list. A forwarded argument cannot be omitted and supplied by a parameter’s default value. These requirements depend on call-site order, not declaration order; named arguments can therefore make a warned declaration usable. A request to forward an indexer receiver when the indexer is an *initializer_target* in a *member_initializer* is a compile-time error.

Constructor overload resolution uses the parameter types of the containing member after substitution of its type arguments, not the original argument expressions. Forwarded arguments retain their parameter-passing modes. At run time, the already evaluated receiver and the already converted argument values or evaluated storage locations are reused by the handler construction and the containing invocation, preserving reference semantics. Additional conversions needed by the constructor are applied to these retained values; the original expressions are not evaluated or bound again.

Expand Down
8 changes: 4 additions & 4 deletions standard/classes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5904,7 +5904,7 @@ It is a compile-time error for the parameter list of an async function to specif

The *return_type* of an async method shall be either `void`, a ***task type***, or an ***asynchronous iterator type*** ([§15.15](classes.md#1515-synchronous-and-asynchronous-iterators)). For an async method that produces a result value, a task type or an asynchronous iterator type ([§15.15.3](classes.md#15153-enumerable-interfaces)) shall be generic. For an async method that does not produce a result value, a task type shall not be generic. Such types are referred to in this specification as `«TaskType»<T>` and `«TaskType»`, respectively. The Standard library type `System.Threading.Tasks.Task` and types constructed from `System.Threading.Tasks.Task<TResult>` and `System.Threading.Tasks.ValueTask<T>` are task types, as well as a class, struct or interface type that is associated with a ***task builder type*** via the attribute `System.Runtime.CompilerServices.AsyncMethodBuilderAttribute`. Such builder types are referred to in this specification as `«TaskBuilderType»<T>` and `«TaskBuilderType»`. A task type can have at most one type parameter and cannot be nested in a generic type.

An async function other than an asynchronous iterator may instead specify a task builder type by applying `AsyncMethodBuilderAttribute` to the function ([§15.14.5](classes.md#15145-task-builder-selection)). Its non-`void` return type shall be a class, struct, or interface type, with at most one type parameter and not nested in a generic type. For checking that function's return type, effective return type, body, and anonymous function conversions, this return type is treated as `«TaskType»` if it is nongeneric, or `«TaskType»<T>` if its single type argument is `T`. This does not make the return type a task type in other contexts or require it to be awaitable.
An async function other than an asynchronous iterator may instead specify a task builder type by applying `AsyncMethodBuilderAttribute` to the function ([§15.14.5](classes.md#15145-task-builder-selection)). Its non-`void` return type shall be a class, struct, or interface type, with at most one type parameter and not nested in a generic type. For checking that function’s return type, effective return type, body, and anonymous function conversions, this return type is treated as `«TaskType»` if it is nongeneric, or `«TaskType»<T>` if its single type argument is `T`. This does not make the return type a task type in other contexts or require it to be awaitable.

An async method returning a task type is said to be ***task-returning***.

Expand Down Expand Up @@ -6014,12 +6014,12 @@ The ability to provide an alternate builder type shall not be used when the synt
The builder type of a task-returning async function is determined by:

1. Using the builder type from `AsyncMethodBuilderAttribute`, if one is present;
1. Otherwise, falling back to the builder type determined by the async function's *return_type* ([§15.14.1](classes.md#15141-general)).
1. Otherwise, falling back to the builder type determined by the async function’s *return_type* ([§15.14.1](classes.md#15141-general)).

If an `AsyncMethodBuilderAttribute` is present on the function, its argument shall specify a class or struct type, and the builder type is determined as follows:

- If the async function's return type is nongeneric, the specified builder type shall be nongeneric and shall not be nested in a generic type. That type is the builder type.
- Otherwise, the specified builder type shall be an unbound generic type with exactly one type parameter, and shall not be nested in a generic type. The builder type is constructed by substituting the single type argument of the async function's return type for that parameter.
- If the async function’s return type is nongeneric, the specified builder type shall be nongeneric and shall not be nested in a generic type. That type is the builder type.
- Otherwise, the specified builder type shall be an unbound generic type with exactly one type parameter, and shall not be nested in a generic type. The builder type is constructed by substituting the single type argument of the async function’s return type for that parameter.

A constructed generic builder type is not permitted as the attribute argument.

Expand Down
4 changes: 2 additions & 2 deletions standard/conversions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 10 Conversions

## 10.1 General

Check warning on line 3 in standard/conversions.md

View workflow job for this annotation

GitHub Actions / word-converter

Markdown to Word Converter - MDC032

Line length 91 > maximum 83; Console.WriteLine(identity.Method.ReturnParameter.IsDefined(typeof(MarkAttribute), false));

Check warning on line 4 in standard/conversions.md

View workflow job for this annotation

GitHub Actions / word-converter

Markdown to Word Converter - MDC032

Line length 94 > maximum 83; Console.WriteLine(identity.Method.GetParameters()[0].IsDefined(typeof(MarkAttribute), false));
A ***conversion*** causes an expression to be converted to, or treated as being of, a particular type; in the former case a conversion may involve a change in representation. Conversions can be ***implicit*** or ***explicit***, and this determines whether an explicit cast is required.

Expand Down Expand Up @@ -150,7 +150,7 @@

An implicit interpolated string conversion permits an *interpolated_string_expression* ([§12.8.3](expressions.md#1283-interpolated-string-expressions)) to be converted to `System.IFormattable` or `System.FormattableString` (which implements `System.IFormattable`). When this conversion is applied, a string value is not composed from the interpolated string. Instead an instance of `System.FormattableString` is created, as further described in [§12.8.3](expressions.md#1283-interpolated-string-expressions).

For any type `T` that is an applicable interpolated string handler type ([§23.5.11.1.1](attributes.md#2351111-declaring-a-custom-handler)), there exists an implicit interpolated string handler conversion to `T` from an *interpolated_string_handler_expression* ([§12.8.3](expressions.md#1283-interpolated-string-expressions)), including a constant interpolated string. This conversion exists, regardless of whether errors are found later when attempting to lower the interpolation using the handler pattern. This ensures that there are predictable and useful errors, and that runtime behavior doesn't change based on the content of an interpolated string.
For any type `T` that is an applicable interpolated string handler type ([§23.5.11.1.1](attributes.md#2351111-declaring-a-custom-handler)), there exists an implicit interpolated string handler conversion to `T` from an *interpolated_string_handler_expression* ([§12.8.3](expressions.md#1283-interpolated-string-expressions)), including a constant interpolated string. This conversion exists, regardless of whether errors are found later when attempting to lower the interpolation using the handler pattern. This ensures that there are predictable and useful errors, and that runtime behavior doesn’t change based on the content of an interpolated string.

### 10.2.6 Implicit nullable conversions

Expand Down Expand Up @@ -1054,7 +1054,7 @@

The invocation list of a delegate produced from an anonymous function contains a single entry. The exact target object and target method of the delegate are unspecified. In particular, it is unspecified whether the target object of the delegate is `null`, the `this` value of the enclosing function member, or some other object.

When a delegate is produced from a lambda expression, attributes explicitly specified on the lambda whose target is the method shall be emitted in metadata on the method referenced by the delegate's `Method` property. Attributes with a `return` target shall be emitted on that method's return parameter, and attributes on lambda parameters shall be emitted on the corresponding method parameters. These requirements do not specify a synthesized method name or the representation of captured variables.
When a delegate is produced from a lambda expression, attributes explicitly specified on the lambda whose target is the method shall be emitted in metadata on the method referenced by the delegate’s `Method` property. Attributes with a `return` target shall be emitted on that method’s return parameter, and attributes on lambda parameters shall be emitted on the corresponding method parameters. These requirements do not specify a synthesized method name or the representation of captured variables.

> *Example*: Explicit lambda attributes can be inspected through the resulting delegate:
>
Expand Down
Loading
Loading