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

Draft spec for extended partial methods #3417

Open
RikkiGibson opened this issue May 1, 2020 · 3 comments
Open

Draft spec for extended partial methods #3417

RikkiGibson opened this issue May 1, 2020 · 3 comments
Labels

Comments

@RikkiGibson
Copy link
Contributor

RikkiGibson commented May 1, 2020

Related to #3301
Proposal: https://github.com/dotnet/csharplang/blob/master/proposals/csharp-9.0/extending-partial-methods.md

C# 9 introduces a new kind of partial method called an extended partial method. An extended partial method must have both a defining declaration and an implementing declaration.

They are required to have explicit accessibility modifiers, which must be identical on both declarations. They are permitted to have out parameters and to have non-void return types. They are permitted to use the virtual, override, sealed, and new modifiers. Both declarations must contain identical combinations of these modifiers, although they may be present in a different order in each declaration.

A single declaration of an extended partial method is said to be an implementing partial declaration if it has a body or if it has an extern modifier. Only the implementing declaration is permitted to have an extern modifier.

@ufcpp
Copy link

ufcpp commented Jun 7, 2020

Can't explicit implementation of an interface method be partial?

interface I
{
    int M();
}

partial class C : I
{
    private partial int I.M(); // requires access modifier but explicit implementation bans it
}

partial class C : I
{
    private partial int I.M() { }
}

(modified publicprivate)

@HaloFour
Copy link
Contributor

HaloFour commented Jun 7, 2020

Maybe the explicit implementation syntax needs to optionally allow a private access modifier?

@RikkiGibson
Copy link
Contributor Author

The feature as shipped in VS 16.7-preview2 does not support partial explicit interface implementations. The compiler team may reconsider this limitation based on user feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants