-
Notifications
You must be signed in to change notification settings - Fork 8k
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 our terms of service and privacy 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
Outdated
Show resolved
Hide resolved
|
@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? |
@iSazonov Done. |
|
Any chance we can get this PR reviewed? Thank you! |
|
Sorry for the long delay! I will make sure review this PR next Monday. |
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!
test/powershell/Language/Classes/scripting.Classes.inheritance.tests.ps1
Show resolved
Hide resolved
test/powershell/Language/Classes/scripting.Classes.inheritance.tests.ps1
Show resolved
Hide resolved
|
/azp run PowerShell-CI-linux-packaging PowerShell-Windows-Packaging-CI |
|
No pipelines are associated with this pull request. |
|
📣 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! |
…rShell class scope (PowerShell#25245)
…scope. Follow up for PowerShell#25245.
PR Summary
This PR enables PowerShell classes to access inherited
protected internalinstance members in addition toprotectedones. It expands the existing scope checks forIsFamilyto check for bothIsFamilyandIsFamilyOrAssembly.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 fromprotectedtoprotected internal. Other APIs may be affected as well, but this is the most notable problem, causing a breaking 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 inherited instance 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
protectedandprotected internalstatic members as well, I already have a separate PR ready to submit, after this one has been merged.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.- [ ] Issue filed:
(which runs in a different PS Host).