Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C# 7.x §15.15.1 must special-case Task and Task<TResult> because they lack AsyncMethodBuilderAttribute #854

Closed
KalleOlaviNiemitalo opened this issue Jul 14, 2023 · 0 comments · Fixed by #875
Assignees
Milestone

Comments

@KalleOlaviNiemitalo
Copy link
Contributor

Describe the bug

In the C# 7.x draft, §15.15.1 (Async functions / General) states:

The return_type of an async method shall be either void or a task type. For an async method that returns a value, a task type shall be generic. For an async method that does not return a 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> are task types.)
A task type shall be a class or struct type that is associated with a task builder type via the attribute System.Runtime.CompilerServices.AsyncMethodBuilderAttribute. Such types are referred to in this specification as «TaskBuilderType»<T> and «TaskBuilderType».

However, System.Threading.Tasks.Task and System.Threading.Tasks.Task<TResult> are not decorated with AsyncMethodBuilderAttribute. Not in §C.3 (Standard Library Types not defined in ISO/IEC 23271), and not in .NET Framework either.

Example

None.

Expected behavior

Special-case System.Threading.Tasks.Task and System.Threading.Tasks.Task<TResult> so that they need not be decorated with AsyncMethodBuilderAttribute.

Additional context

None.

@jskeet jskeet added this to the C# 7.x milestone Aug 7, 2023
@jskeet jskeet self-assigned this Aug 7, 2023
jskeet added a commit to jskeet/csharpstandard that referenced this issue Aug 7, 2023
- `Task` and `Task<T>` are classified as task types despite not
  specifying builder types
- Interfaces are allowed to be task types
- Enums and methods are prohibited from being decorated with
  AsyncMethodBuilderAttribute
- Task types must not be generic in more than one type parameter
  (including in terms of containing types)

Discussion required for all of this, but if merged, would fix dotnet#854,
jskeet added a commit to jskeet/csharpstandard that referenced this issue Aug 7, 2023
- `Task` and `Task<T>` are classified as task types despite not
  specifying builder types
- Interfaces are allowed to be task types
- Enums and methods are prohibited from being decorated with
  AsyncMethodBuilderAttribute
- Task types must not be generic in more than one type parameter
  (including in terms of containing types)

Discussion required for all of this, but if merged, would fix dotnet#854,
jskeet added a commit to jskeet/csharpstandard that referenced this issue Aug 7, 2023
- `Task` and `Task<T>` are classified as task types despite not
  specifying builder types
- Interfaces are allowed to be task types
- Enums and methods are prohibited from being decorated with
  AsyncMethodBuilderAttribute
- Task types must not be generic in more than one type parameter
  (including in terms of containing types)

Discussion required for all of this, but if merged, would
fix dotnet#854, dotnet#856, dotnet#858 and dotnet#859.
BillWagner pushed a commit that referenced this issue Aug 15, 2023
* Clarify task types

- `Task` and `Task<T>` are classified as task types despite not
  specifying builder types
- Interfaces are allowed to be task types
- Enums and methods are prohibited from being decorated with
  AsyncMethodBuilderAttribute
- Task types must not be generic in more than one type parameter
  (including in terms of containing types)

Discussion required for all of this, but if merged, would
fix #854, #856, #858 and #859.

* Prevent nesting within generic types, for task types.

This wording follows the wording in 15.15.2 for task builders.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants