- Notifications
You must be signed in to change notification settings - Fork7.7k
Make inherited protected internal instance members accessible in class scope.#25245
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
test/powershell/Language/Classes/scripting.Classes.inheritance.tests.ps1 OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
@mawosoft Please look CI failures. I see only 8 failed tests. |
This comment was marked as outdated.
This comment was marked as outdated.
@mawosoft Let's wait MSFT team member's review. It can take a long time. |
- Remove tests for static members because this PR is limited to instance members.- Add tests for accessing instance members dynamically.- Clean up code and clarify test descriptions.
@iSazonov,@SeeminglyScience,@daxian-dbw
See PR description. |
Can we have a test to ensure this now works? |
mawosoft commentedApr 8, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@iSazonov Done. |
FabienTschanz commentedApr 28, 2025
Any chance we can get this PR reviewed? Thank you! |
Sorry for the long delay! I will make sure review this PR next Monday. |
daxian-dbw left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@mawosoft Again, sorry for the long delay! The product changes look good to me, but I left 2 comments in the test changes. Please take a look, thanks!
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
/azp run PowerShell-CI-linux-packaging PowerShell-Windows-Packaging-CI |
No pipelines are associated with this pull request. |
eb1cc6d
intoPowerShell:masterUh oh!
There was an error while loading.Please reload this page.
microsoft-github-policy-servicebot commentedMay 12, 2025 • edited by unfurl-linksbot
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by unfurl-linksbot
Uh oh!
There was an error while loading.Please reload this page.
📣 Hey @@mawosoft, how did we do? We would love to hear your feedback with the link below! 🗣️ 🔗https://aka.ms/PSRepoFeedback |
@daxian-dbw What are your thoughts on doing this for static members as well? See "future considerations" in the PR Context at the top. Also, don't forget to backport to 7.5 :) Not sure how that selection process works here. |
I agree to support the same for static members for the sake of consistency. Please submit a new PR for that. Thank you! |
Uh oh!
There was an error while loading.Please reload this page.
PR Summary
This PR enables PowerShell classes to access inherited
protected internal
instance members in addition toprotected
ones. It expands the existing scope checks forIsFamily
to check for bothIsFamily
andIsFamilyOrAssembly
.Fixes#24898.
PR Context
After switching to .NET 9 in Powershell 7.5, PowerShell classes can no longer call
$this.MemberwiseClone()
because the API signature of the method in the .NET SDK was changed fromprotected
toprotected internal
. Other APIs may be affected as well, but this is the most notable problem, causing abreaking change when existing scripts switch from PowerShell 7.4 to 7.5 or newer.To speed up the review process, this PR makes only minimal changes adressing access to inheritedinstance members. These changes should be backported to 7.5 immediately (bugfix). A backport to 7.4 should also be considered (enhancement).
Future considerations for inherited static members
At the moment, PowerShell classes can only access public inherited static members. If it is desirable to allow access to
protected
andprotected internal
static members as well, I already have a separate PR ready to submit, after this one has been merged.PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.- [ ] Issue filed:
(which runs in a different PS Host).