Skip to content

[Version 9.0] Feature support for more partial methods - #1468

Open
BillWagner wants to merge 15 commits into
draft-v9from
v9-more-partial-methods
Open

BillWagner wants to merge 15 commits into
draft-v9from
v9-more-partial-methods

Conversation

@BillWagner
BillWagner force-pushed the v9-more-partial-methods branch from 5e7986c to 9e0a0f2 Compare November 11, 2025 21:33
@RexJaeschke RexJaeschke added this to the C# 9.0 milestone Nov 12, 2025
@RexJaeschke RexJaeschke added type: feature This issue describes a new feature Review: pending Proposal is available for review labels Nov 12, 2025
@RexJaeschke RexJaeschke changed the title [Version 9.0] More partial methods [Version 9.0] Feature support for more partial methods Nov 14, 2025
@BillWagner
BillWagner force-pushed the v9-more-partial-methods branch from 9e0a0f2 to 13eca45 Compare January 8, 2026 21:28
@BillWagner BillWagner added the meeting: discuss This issue should be discussed at the next TC49-TG2 meeting label Jan 9, 2026
@BillWagner

BillWagner commented Jan 9, 2026 •

Copy link
Copy Markdown
Member Author

This is ready for a first look from the committee.

I addressed all the comments from #991. However, #991 (comment) is an instance where the spec language is correct, and the roslyn implementation has a parsing error. See dotnet/roslyn#81947.

Secondly, I made more substantial edits to the original PR. The draft retained a single clause for Partial methods. Looking ahead at the future versions (for the standard), I split this into three sections: General, restricted partial methods, and unrestricted partial methods. I think that makes the text easier to read, and provides the framework for future versions where there are more unrestricted partial methods.

Discussion question: I used the terms in the current PR of "restricted" and "unrestricted". I'm not convinced those are the best terms. It might be better to use "optional partial methods", and "required partial methods", respectively. I'm not sold on those either. Other thoughts?

@BillWagner
BillWagner marked this pull request as ready for review January 9, 2026 16:34
Comment thread standard/classes.md Outdated
Comment thread standard/classes.md Outdated
Comment thread standard/classes.md Outdated
Comment thread standard/classes.md Outdated
Comment thread standard/classes.md Outdated
Comment thread standard/classes.md
Comment thread standard/classes.md Outdated
@BillWagner
BillWagner force-pushed the v9-more-partial-methods branch from df85388 to 5839c04 Compare January 16, 2026 16:10

@jskeet jskeet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall - either optional and required are the wrong way round here, or I think we should find another pair of terms. Sorry to throw a spanner in the works!

Comment thread standard/classes.md Outdated
Comment thread standard/classes.md Outdated
Comment thread standard/classes.md Outdated
Comment thread standard/classes.md Outdated
Comment thread standard/classes.md Outdated
@BillWagner BillWagner removed the meeting: discuss This issue should be discussed at the next TC49-TG2 meeting label Mar 11, 2026
@BillWagner
BillWagner force-pushed the v9-more-partial-methods branch from fbe81a5 to c403cee Compare April 10, 2026 21:09
BillWagner added a commit that referenced this pull request Apr 10, 2026
…review commits

Delta: 9 commits (16fa8b4..c403cee)
Original: 3563471 (alpha-v9) / 3eed3e3 (pr-1468)
Conflicts resolved: 2 in classes.md
  - Conflict 1: Replaced old 'two kinds' paragraph with new 'classified as follows' intro
  - Conflict 2: Replaced old 'restricted partial method' restrictions with 'default arguments' bullet (restrictions moved to §optional-partial-methods)
@RexJaeschke
RexJaeschke marked this pull request as draft May 5, 2026 14:51
@BillWagner
BillWagner force-pushed the v9-more-partial-methods branch from c403cee to 84fff65 Compare May 12, 2026 21:21
@BillWagner
BillWagner force-pushed the v9-more-partial-methods branch from 84fff65 to db72bd2 Compare June 24, 2026 17:40
@BillWagner

Copy link
Copy Markdown
Member Author

An earlier version of this feature is already present on alpha-v9 from a prior meeting. Edits made to this PR since then are not yet on alpha-v9; they will land at the next propagation. If you need them on alpha-v9 sooner, please open a separate PR targeting alpha-v9.
Thanks!

@BillWagner
BillWagner force-pushed the v9-more-partial-methods branch from b637493 to e116922 Compare July 24, 2026 19:50
@BillWagner BillWagner added the meeting: discuss This issue should be discussed at the next TC49-TG2 meeting label Aug 18, 2026
@BillWagner

Copy link
Copy Markdown
Member Author

This is ready for a first review at the next committee meeting.

@Nigel-Ecma I think the ANTLR tests are failing because this PR allows new partial declarations.

@Nigel-Ecma

Copy link
Copy Markdown
Contributor

This is ready for a first review at the next committee meeting.

@Nigel-Ecma I think the ANTLR tests are failing because this PR allows new partial declarations.

@BillWagner – A quick glance suggests the two tests fail because the structure of existing syntax rules has changed, i.e. 'partial'? has been moved up from method_modifiers to method_declaration – the recognised syntax for non-ref methods remain the same but the tree-structure changes.

As far as my quick glance goes you’ve done this so that ref-methods can be partial as well. There is nothing wrong with this per se, it is a choice, but if you want to achieve the same result without breaking anything just add 'partial'? to ref_method_modifers – adding an extra optional child ('partial'?) in a rule doesn’t change its structure, so existing tests should continue without error (but you can add a new test for a partial ref method to make sure partial ref methods are recognised as expected).

HTH

@Nigel-Ecma Nigel-Ecma left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggested small changes, including a grammar rewrite previously suggested in this comment

Comment thread standard/basic-concepts.md
Comment thread standard/classes.md Outdated
Comment thread standard/classes.md Outdated
Comment thread standard/classes.md Outdated
Comment thread standard/classes.md
Comment on lines +3053 to +3075
> *Example*:
>
> <!-- Example: {template:"standalone-lib-without-using", name:"PartialMethods2", replaceEllipsis:true, customEllipsisReplacements: ["", "return true;", "i = 10;"]} -->
> ```csharp
> // part containing defining partial method declarations
> partial class C
> {
> partial void M1(); // implementation optional
> private partial void M2(); // required, impl. required
> protected partial bool M3(); // required, impl. required
> public partial void M4(out int i); // required, impl. required
> }
>
> // part containing implementing partial method declarations
> partial class C
> {
> private partial void M2() { ... }
> protected partial bool M3() { ... }
> public partial void M4(out int i) { ... }
> }
> ```
>
> *end example*

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest adding a M5 which uses extern, thus showing an implementing declaration with a semicolon rather than a block.

@BillWagner
BillWagner force-pushed the v9-more-partial-methods branch from 82d6e56 to a28ffad Compare September 18, 2026 19:51
RexJaeschke and others added 13 commits October 13, 2026 14:26
fix md formatting

revert to previous text

handle imp/exp private

allow partial with ref_kind returns

change link's target name

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 21570b74-c6f5-4fc5-ab6d-7546918d6ddb
Also, edit after moving text around.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 21570b74-c6f5-4fc5-ab6d-7546918d6ddb
Clean up a bit of language and flow.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 21570b74-c6f5-4fc5-ab6d-7546918d6ddb
Co-authored-by: Jon Skeet <[email protected]>
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 21570b74-c6f5-4fc5-ab6d-7546918d6ddb
Investigate and respond to feedback from reviews.

Implement the proposed name change to "optional" and "required"

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 21570b74-c6f5-4fc5-ab6d-7546918d6ddb
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 21570b74-c6f5-4fc5-ab6d-7546918d6ddb
Co-authored-by: Jon Skeet <[email protected]>
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 21570b74-c6f5-4fc5-ab6d-7546918d6ddb
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 21570b74-c6f5-4fc5-ab6d-7546918d6ddb
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 21570b74-c6f5-4fc5-ab6d-7546918d6ddb
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 21570b74-c6f5-4fc5-ab6d-7546918d6ddb
- Add that return types must match.
- Add rule on type parameter constraints.
- Add text for extern implementations.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 21570b74-c6f5-4fc5-ab6d-7546918d6ddb
Review and make two small updates.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 21570b74-c6f5-4fc5-ab6d-7546918d6ddb
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 21570b74-c6f5-4fc5-ab6d-7546918d6ddb
@BillWagner
BillWagner force-pushed the v9-more-partial-methods branch from a28ffad to d5d2748 Compare October 14, 2026 13:56
BillWagner and others added 2 commits October 22, 2026 15:57
Address the remaining feedback on partial methods
@BillWagner
BillWagner marked this pull request as ready for review October 22, 2026 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

meeting: discuss This issue should be discussed at the next TC49-TG2 meeting Review: pending Proposal is available for review type: feature This issue describes a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants