GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix getting a property whose override defines only the setter by piupiunn · Pull Request #28282 · PowerShell/PowerShell

Conversation

@piupiunn

@piupiunn Caner Demir (piupiunn) commented Oct 29, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

PR Summary

PowerShell can now get a .NET property whose override defines only the setter. The getter is inherited from the base property, as in C#.

Fix #25038

PR Context

For public override int Foo { set { ... } }, reflection returns a PropertyInfo for the override that has only the setter, although the getter is inherited. The .NET adapter used that PropertyInfo for getting too, so the property was treated as write-only:

  • $obj.Foo threw WriteOnlyProperty.
  • $obj.psobject.Properties['Foo'].Value and Select-Object Foo returned $null.
  • Get-Member showed int Foo {set;}.

PropertyCacheEntry still stores the override's PropertyInfo, so setting, attributes and the declaring type don't change. Only for getting, when the override has no getter, it now uses the property that introduced the virtual property (found with MethodInfo.GetBaseDefinition()). That getter is virtual, so a getter override in a type in between is still called. ParameterizedPropertyCacheEntry takes the inherited getter the same way, so $obj.Item(1) works too, and the setter keeps the override's parameters. Protected properties used inside a PowerShell class are covered as well, because they also get a PropertyCacheEntry.

Other visible changes for these properties: $obj.Item(1) now calls the matching overload instead of another overload that has a getter, Get-Member shows an indexer as the base getter declares it, and Select-Object *, Format-List * and ConvertTo-Json now output their values.

In-box properties that become readable:

  • XmlDocument.InnerText, XmlAttribute.InnerText and XmlAttribute.InnerXml. For example, ([xml]'<a>b</a>').InnerText returns $null today and b with this change.
  • AnonymousPipeServerStream.ReadMode and AnonymousPipeClientStream.ReadMode.
  • RSAOpenSsl.KeySize on Linux (### **Title:** Missing KeySize Reading Access in RSACertificateExtensions.GetRSAPrivateKey on Linux (.NET 9) dotnet/runtime#112622).
  • On Windows: Site of ErrorProvider, AxHost and WebBrowserBase; HwndTarget.RootVisual.

Not changed:

  • An override that defines only a non-public setter of a property with a public getter, for example public override int Foo { protected set { ... } }, used outside a PowerShell class that derives from the type. Reflection doesn't return such a property as public, so it isn't in the property table.
  • Completion tooltips for types inferred without an instance still show { set; }, because CompletionCompleters reads the override's PropertyInfo itself.
  • The opposite case: an override that defines only the getter of a property that has a setter. It has the same cause, so such a property can't be set from PowerShell (for example RSACryptoServiceProvider.KeySize), although C# can call the inherited setter. I left it out because the issue doesn't cover it, and it would make some properties settable that look read-only today.

I can handle the last two here or in separate PRs if you want them.

The new tests fail without the fix and pass with it.

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Make sure all .h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright header
  • This PR is ready to merge. If this PR is a work in progress, please open this as a Draft Pull Request and mark it as Ready to Review when it is ready to merge.
  • Breaking changes
    • None
    • OR
    • Experimental feature(s) needed
      • Experimental feature name(s):
  • User-facing changes
    • Not Applicable
    • OR
    • Documentation needed
      • Issue filed:
  • Testing - New and feature
    • N/A or can only be tested interactively
    • OR
    • Make sure you've added a new test if existing tests do not effectively test the code changed

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@piupiunn
Fix getting a property whose override defines only the setter
9ac3eb3
Copilot AI balanced review requested due to automatic review settings October 29, 2026 12:07
@piupiunn
Caner Demir (piupiunn) requested a review from a team as a code owner October 29, 2026 12:07
@azure-pipelines

azure-pipelines Bot commented Oct 29, 2026

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Copilot started reviewing on behalf of Caner Demir (piupiunn) October 29, 2026 12:08
View session
Copilot AI reviewed Oct 29, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

🟡 Changes recommended

The change regresses indexer setters’ optional-argument defaults and params support, and breaks protected-property assignments involving generic base types.

2 open issues
  • Medium severity Preserve setter metadata when merging inherited indexer getters · New
  • Medium severity Support protected accessors when resolving generic inherited properties · New
What changed in this PR

Addresses #25038 by allowing PowerShell to read inherited getters when a .NET property override defines only the setter.

Changes:

  • Resolves inherited getters when populating the .NET property cache.
  • Applies the same lookup to non-public properties accessed inside PowerShell classes.
  • Adds regression tests for ordinary, indexed, generic-base, and protected properties, including virtual dispatch.
File Description
test/​powershell/​engine/​ETS/​Adapter.Tests.ps1 Adds setter-only override regression tests.
src/​System.Management.Automation/​engine/​runtime/​Binding/​Binders.cs Uses inherited-getter lookup for non-public property binding.
src/​System.Management.Automation/​engine/​CoreAdapter.cs Adds inherited-getter resolution and integrates it into property caching.

Review effort: Balanced

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/System.Management.Automation/engine/CoreAdapter.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/runtime/Binding/Binders.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Caner Demir (piupiunn) added 2 commits October 29, 2026 15:30
@piupiunn
Keep the override's PropertyInfo and use the base property only for g…
ca604be
…etting
@piupiunn
Add a test for a setter-only override declared in a generic type
1bb0486
@microsoft-github-policy-service microsoft-github-policy-service Bot added the Review - Needed The PR is being reviewed label Nov 5, 2026
@microsoft-github-policy-service

microsoft-github-policy-service Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments

At least 1 approving review is required to merge this pull request.

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

Review - Needed The PR is being reviewed

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

PowerShell does not property overrides that only override the set

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@piupiunn
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.