8000 Fix Propertyless Object not displaying after ETS introspection - Simple Fix by GregoireLD · Pull Request #26520 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@GregoireLD
Copy link
@GregoireLD GregoireLD commented Nov 24, 2025

PR Summary

Fix #25832
This fix the case where a Propertyless object is rendered undisplayable after being inspected using Get-Member or any similar introspection commands.

PR Context

Propertyless object are usually displayed using a fallback to their ToString() methods.
But the method currently used to evaluate the "Propertyless-ness" of an object relies on a flawed evaluation:
After inspecting the object, one new property gets dynamically attached to the object, rendering it undisplayable, because no longer regarded as Propertyless.

This PR fixes and extend the current IsNotRemotingProperty function in two ways: adds the currently missing RemotingConstants.EventObject kind (currently missing from the evaluation), and also adds the PSObject.PSTypeNames kind to the exclusion list to ensure introspected propertyless objects don't get misjudged as "property-full".

Also, maybe changing the IsNotRemotingProperty into a new name like IsNotBlacklistedProperty or IsNotSkippedProperty could be a good idea to mach this function extended purpose, but I wanted to get some feedback before any name change.

The full rational and discussion prior to making this PR can be found in my issue report :
#25832

PR Checklist

@iSazonov iSazonov added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Nov 24, 2025
/// </summary>
internal static class OutOfBandFormatViewManager
{
private static bool IsNotRemotingProperty(string name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems we should rename the method. Maybe IsNotPSSpecificProperty

|| name.Equals(RemotingConstants.SourceJobInstanceId, StringComparison.OrdinalIgnoreCase);
|| name.Equals(RemotingConstants.SourceJobInstanceId, StringComparison.OrdinalIgnoreCase)
|| name.Equals(RemotingConstants.EventObject, StringComparison.OrdinalIgnoreCase)
|| name.Equals(PSObject.PSTypeNames, StringComparison.OrdinalIgnoreCase);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd prefer to cover all code branches by tests.
I suggest using TestCases with ma,es of the properties and manually add the properties (one per test) to propertyless object.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Review - Needed The PR is being reviewed label Dec 1, 2025
@iSazonov
Copy link
Collaborator

@GregoireLD Do you want to continue?

@microsoft-github-policy-service microsoft-github-policy-service bot removed the Review - Needed The PR is being reviewed label Dec 11, 2025
@GregoireLD
Copy link
Author

@iSazonov yes, sorry I got busy lately, but I still aim to fix it for good

@microsoft-github-policy-service microsoft-github-policy-service bot added the Review - Needed The PR is being reviewed label Dec 18, 2025
@microsoft-github-policy-service
Copy link
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

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

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log Review - Needed The PR is being reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hidden-only class loses ToString() formatting after Get-Member inspection

2 participants

0