[release/v7.4.16] Fix Out-GridView by replacing use of obsolete BinaryFormatter with custom implementation#27426
Merged
adityapatwardhan merged 1 commit intoMay 15, 2026
Conversation
…h custom implementation (PowerShell#25497)
Contributor
There was a problem hiding this comment.
Pull request overview
This PR backports the Out-GridView filtering fix by removing the obsolete BinaryFormatter-based deep copy and replacing it with a custom deep-clone mechanism across FilterCore filter/validation rule types.
Changes:
- Introduces an
IDeepCloneableinterface and implements deep-clone support across FilterCore types. - Replaces
FilterRuleExtensions.DeepCopy()implementation fromBinaryFormatterserialization toDeepClone(). - Adds copy constructors / cloning logic throughout filter rules and validating value types to preserve expected behavior (including event re-wiring).
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/IDeepCloneable.cs | Adds the deep-clone interface used by FilterCore types. |
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/ValidationRules/DataErrorInfoValidationRule.cs | Makes validation rules deep-cloneable via IDeepCloneable. |
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/ValidatingValueBase.cs | Adds cloning support for validation rule collections and requires derived DeepClone(). |
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/ValidatingValue.cs | Implements deep cloning for ValidatingValue<T> via copy ctor + DeepClone(). |
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/ValidatingSelectorValue.cs | Implements deep cloning for selector values, including cloning available values when possible. |
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/FilterRuleExtensions.cs | Removes BinaryFormatter deep copy and delegates to FilterRule.DeepClone(). |
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/FilterRule.cs | Implements IDeepCloneable for filter rules using copy constructors. |
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/ComparableValueFilterRule.cs | Adds copy constructor to carry rule state during cloning. |
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/SingleValueComparableValueFilterRule.cs | Adds copy constructor to clone Value and reattach change handlers. |
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/IsBetweenFilterRule.cs | Adds copy constructor to clone StartValue/EndValue and reattach handlers. |
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/EqualsFilterRule.cs | Adds copy constructor for cloning support. |
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/DoesNotEqualFilterRule.cs | Adds copy constructor for cloning support. |
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/IsEmptyFilterRule.cs | Adds copy constructor for cloning support. |
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/IsNotEmptyFilterRule.cs | Adds copy constructor for cloning support. |
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/IsGreaterThanFilterRule.cs | Adds copy constructor for cloning support. |
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/IsLessThanFilterRule.cs | Adds copy constructor for cloning support. |
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/TextFilterRule.cs | Adds copy constructor to preserve text-rule settings during cloning. |
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/TextEqualsFilterRule.cs | Adds copy constructor for cloning support. |
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/TextDoesNotEqualFilterRule.cs | Adds copy constructor for cloning support. |
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/TextContainsFilterRule.cs | Adds copy constructor for cloning support. |
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/TextDoesNotContainFilterRule.cs | Adds copy constructor for cloning support. |
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/TextStartsWithFilterRule.cs | Adds copy constructor for cloning support. |
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/TextEndsWithFilterRule.cs | Adds copy constructor for cloning support. |
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/SelectorFilterRule.cs | Adds copy constructor to clone AvailableRules and rewire events post-clone. |
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/PropertyValueSelectorFilterRule.cs | Adds copy constructor and reinitializes display-name converter state. |
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/PropertiesTextContainsFilterRule.cs | Adds copy constructor and restores invalidation handler behavior for cloned instances. |
| src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/IsNotEmptyValidationRule.cs | Implements DeepClone() for the validation rule used by validating values. |
andyleejordan
approved these changes
May 14, 2026
andyleejordan
approved these changes
May 14, 2026
4f6d7ca
into
PowerShell:release/v7.4.16
41 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Backport of #25497 to release/v7.4.16
Triggered by @adityapatwardhan on behalf of @mawosoft
Original CL Label: CL-General
/cc @PowerShell/powershell-maintainers
Impact
REQUIRED: Choose either Tooling Impact or Customer Impact (or both). At least one checkbox must be selected.
Tooling Impact
Customer Impact
Out-GridView users benefit from this fix as it removes the dependency on the obsolete BinaryFormatter and implements a custom, maintained serialization approach, ensuring continued functionality in future .NET versions.
Regression
REQUIRED: Check exactly one box.
This is not a regression.
Testing
The original PR was tested with Out-GridView functionality to verify the custom serialization implementation works correctly as a replacement for the obsolete BinaryFormatter.
Risk
REQUIRED: Check exactly one box.
This is a replacement of core serialization logic in Out-GridView. While it removes reliance on obsolete APIs, the custom implementation introduces new code paths that need validation. The risk is mitigated by the fix replacing problematic code and maintaining functional compatibility.