-
Notifications
You must be signed in to change notification settings - Fork 92
Add an exception to the requirement that partial method declarations have the same modifiers #1521
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
Conversation
…have the same modifiers
|
@BillWagner @jskeet This looks like a candidate for merging without a meeting discussion. |
Could not an implementation choose to invoke an While I do not doubt that a certain compiler made this choice intentionally, I’m unsure that an implementation which choose to allow it should be deemed to be in error. |
User code does not invoke an async method differently from a non-async one. Nor would an implementation invoke it differently. The effect of the What the Either way, the caller invokes the method the same way (a direct method call), and it sees only the |
|
And then, given that the |
Where in your code:
is this “Task object” you mention specified, the signature seems to say it returns Is it perhaps indicated by the So is this method perhaps not called like one taking no arguments and returning nothing as its “signature” might suggest? Anyway, neither of us should be here today! Happy New Year, see you in 2026 🙂 |
|
Oops, I forgot that part. With
But the caller cannot observe when any asynchronous work is completed due to the return type being void. The method is called like one taking no arguments and returning nothing, since that is what it is. I appreciate that |
* Bump Microsoft.NET.Test.Sdk and 2 others (#1526) Bumps Microsoft.NET.Test.Sdk from 17.14.1 to 18.0.1 Bumps Newtonsoft.Json from 13.0.3 to 13.0.4 Bumps xunit.runner.visualstudio from 3.1.4 to 3.1.5 --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-version: 18.0.1 dependency-type: direct:production update-type: version-update:semver-major dependency-group: dotnet - dependency-name: Newtonsoft.Json dependency-version: 13.0.4 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dotnet - dependency-name: xunit.runner.visualstudio dependency-version: 3.1.5 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dotnet ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump Microsoft.NET.Test.Sdk, NUnit.Analyzers and NUnit3TestAdapter (#1525) Bumps Microsoft.NET.Test.Sdk from 17.14.1 to 18.0.1 Bumps NUnit.Analyzers from 4.10.0 to 4.11.2 Bumps NUnit3TestAdapter from 5.1.0 to 6.0.1 --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-version: 18.0.1 dependency-type: direct:production update-type: version-update:semver-major dependency-group: dotnet - dependency-name: NUnit.Analyzers dependency-version: 4.11.2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: dotnet - dependency-name: NUnit3TestAdapter dependency-version: 6.0.1 dependency-type: direct:production update-type: version-update:semver-major dependency-group: dotnet ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Address remaining nullable reference type issues (#1515) * Warning on lifted conversion w/ null Fixes item 2 in #1228 * Specify default null state of default Fixes the 3rd and 4th item in the list. * Update standard/types.md Co-authored-by: Joseph Musser <me@jnm2.com> * Apply suggestions from code review Co-authored-by: Joseph Musser <me@jnm2.com> --------- Co-authored-by: Joseph Musser <me@jnm2.com> * [create-pull-request] automated change (#1531) Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com> * Add an exception to the requirement that partial method declarations have the same modifiers (#1521) * Add an exception to the requirement that partial method declarations have the same modifiers * Update standard/classes.md --------- Co-authored-by: Jon Skeet <jonskeet@google.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Joseph Musser <me@jnm2.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com> Co-authored-by: Jon Skeet <jonskeet@google.com>
This code is accepted just fine:
And this is by design. It's not allowed for the
asyncmodifier to be on both parts. Nor would that make intuitive sense, sinceasyncis a keyword that only affects the body. It does not affect the signature.When C# 9 comes along,
externwill have to be added as another exception for the same reason.