-
Notifications
You must be signed in to change notification settings - Fork 87
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.2 task builder "accessible" members #879
Comments
Alternative fix Declare that the task builder members shall be public.
|
Apologies, triaged this too late for C# 7. Will address address in C# 8. |
Clarify the required accessibility of any task builder type and its required members. Note that we will need to update this text once dotnet/roslyn#71283 is fixed and merged.
Clarify the required accessibility of any task builder type and its required members. Note that we will need to update this text once dotnet/roslyn#71283 is fixed and merged.
Describe the bug
In the C# 7.x draft, §15.15.2 (Async functions / Task-type builder pattern) says that the task builder type must have "the following accessible members". It is not clear what "accessible" means there. Does it mean accessible by the async function, by the task type, or something else? Can the members be
internal
if all relevant code is in the same assembly?(In any case, the task type must be accessible by the async function, in order to be the return type; and the task builder type must be accessible by the task type, in order to be named in the AsyncMethodBuilderAttribute.)
Example 1
Is the following allowed? The members are accessible by the async method and also by the task type. Roslyn however rejects this code. SharpLab
Example 2
Is the following allowed? The task builder type is not accessible by the async method, so its members are not accessible by that either. They are however accessible by the task type, and Roslyn allows this code. SharpLab
Example 3
Is the following allowed? As in Example 2, the task builder type is not accessible by the async method but is accessible by the task type. This time however, Roslyn rejects this code. SharpLab
Example 4
The same as Example 3, except now with
internal struct CustomTaskBuilder
. The members are accessible by the async method and also by the task type. Roslyn allows the code. SharpLabExample 5
The same as Example 3, except now with
internal protected struct CustomTaskBuilder
. The members are accessible by the async method and also by the task type. Roslyn rejects the code, even thoughinternal protected
generally is more accessible thaninternal
. SharpLabExpected behavior
Declare that the task builder type shall be accessible by the async function (and thus also by the generated state machine).
Declare that the listed members of the task builder type shall be
public
. Do not say whether they are "accessible".Additional context
None.
Associated WorkItem - 187391
The text was updated successfully, but these errors were encountered: