Skip to content

Conversation

@jjonescz
Copy link
Member

@jjonescz jjonescz commented Feb 28, 2025

Fixes #77346.

The classic (not extended) partial methods are always private (hence also not virtual), and that is also true in interfaces. However, the extended partial methods feature allows partial methods to be public and virtual, but in interfaces, they are not implicitly public nor virtual unlike their non-partial counterparts which I think was just an oversight (all speclet wording I could find in the mentioned features supports that). Since partial properties and events are based on extended partial methods, they have the same bug. This PR fixes that inconsistency for partial properties and events but leaves it for extended partial methods per LDM decision.

@ghost ghost added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 28, 2025
@jjonescz jjonescz marked this pull request as ready for review February 28, 2025 18:18
@jjonescz jjonescz requested a review from a team as a code owner February 28, 2025 18:18
@RikkiGibson RikkiGibson self-assigned this Mar 4, 2025
Copy link
Member

@RikkiGibson RikkiGibson left a comment

Choose a reason for hiding this comment

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

Impl and testing seems good, we should just seek confirmation that we want to do this as a bug-fix level change, and figure out if we need to update the breaking change doc.

@jjonescz jjonescz changed the base branch from features/PartialEventsCtors to main March 5, 2025 14:56
@AlekseyTs
Copy link
Contributor

AlekseyTs commented Mar 5, 2025

we should just seek confirmation that we want to do this as a bug-fix level change

It is unfortunate that we have this behavior with already shipped features. Changing virtual-ness of interface members feels like a big change to me. #Closed

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Mar 5, 2025

Done with review pass (commit 3) #Resolved

Copy link
Member

@RikkiGibson RikkiGibson left a comment

Choose a reason for hiding this comment

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

LGTM modulo additional suggested tests and confirmation on moving forward with the break.

@jjonescz
Copy link
Member Author

jjonescz commented Apr 1, 2025

@RikkiGibson @AlekseyTs for another look, thanks
@jaredpar said he is okay with moving forward with this break but that I should also send an e-mail to LDT which I did and also got no pushback #Closed

@jaredpar
Copy link
Member

jaredpar commented Apr 1, 2025

Good to go from my perspective. #Closed

@jaredpar jaredpar added the breaking-change https://github.com/dotnet/sdk/blob/main/documentation/project-docs/breaking-change-guidelines.md label Apr 1, 2025
@AlekseyTs
Copy link
Contributor

AlekseyTs commented Apr 1, 2025

@jjonescz It looks like there are conflicts that should be resolved #Closed

@AlekseyTs
Copy link
Contributor

Done with review pass (commit 6)

@jjonescz jjonescz requested a review from AlekseyTs April 11, 2025 13:44
@AlekseyTs
Copy link
Contributor

AlekseyTs commented Apr 11, 2025

@jjonescz Does PR description accurately reflect the changes that this PR is making now?

@AlekseyTs
Copy link
Contributor

Done with review pass (commit 11)

@jjonescz
Copy link
Member Author

Does PR description accurately reflect the changes that this PR is making now?

Updated the description, thanks.

Likely caused by some unintentional git operation.
Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

LGTM (commit 13)

@jjonescz
Copy link
Member Author

@RikkiGibson for another look, thanks

This inconsistency is however [preserved](./Deviations%20from%20Standard.md#interface-partial-methods) for partial interface methods to avoid a larger breaking change.
Note that Visual Basic and other languages not supporting default interface members will start requiring to implement implicitly virtual `partial` interface members.

To keep the previous behavior, explicitly mark `partial` interface members as `sealed` and `private`.
Copy link
Member

Choose a reason for hiding this comment

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

nit: private by itself should accomplish this, right? Since the member will be implicitly sealed in that case. It looks like private sealed is permitted on static interface methods but not instance ones.

Copy link
Member Author

Choose a reason for hiding this comment

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

private will be enough for members like partial int P { get; }. But if you had a member like public partial int P { get; }, the workaround to preserve previous behavior is adding sealed modifier (you cannot add private since the member is already public). Let me try to clarify, thanks.

@RikkiGibson
Copy link
Member

It looks like the PR is ready to merge

@jjonescz jjonescz merged commit 6091e3c into dotnet:main Apr 24, 2025
24 checks passed
@jjonescz jjonescz deleted the PartialEventsCtors-12-Interface branch April 24, 2025 07:33
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Apr 24, 2025
@RikkiGibson RikkiGibson modified the milestones: Next, 18.0 P1 Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Compilers breaking-change https://github.com/dotnet/sdk/blob/main/documentation/project-docs/breaking-change-guidelines.md untriaged Issues and PRs which have not yet been triaged by a lead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Partial default interface members are not virtual

4 participants