Skip to content

[release/v7.4.16] Fix Out-GridView by replacing use of obsolete BinaryFormatter with custom implementation#27426

Merged
adityapatwardhan merged 1 commit into
PowerShell:release/v7.4.16from
adityapatwardhan:backport/release/v7.4.16/25497-cbafa5a7f
May 15, 2026
Merged

[release/v7.4.16] Fix Out-GridView by replacing use of obsolete BinaryFormatter with custom implementation#27426
adityapatwardhan merged 1 commit into
PowerShell:release/v7.4.16from
adityapatwardhan:backport/release/v7.4.16/25497-cbafa5a7f

Conversation

@adityapatwardhan
Copy link
Copy Markdown
Member

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

  • Required tooling change
  • Optional tooling change (include reasoning)

Customer Impact

  • Customer reported
  • Found internally

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.

  • Yes
  • No

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.

  • High
  • Medium
  • Low

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.

Copilot AI review requested due to automatic review settings May 13, 2026 19:44
@adityapatwardhan adityapatwardhan added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label May 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 IDeepCloneable interface and implements deep-clone support across FilterCore types.
  • Replaces FilterRuleExtensions.DeepCopy() implementation from BinaryFormatter serialization to DeepClone().
  • 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.

@adityapatwardhan adityapatwardhan merged commit 4f6d7ca into PowerShell:release/v7.4.16 May 15, 2026
41 checks passed
@adityapatwardhan adityapatwardhan deleted the backport/release/v7.4.16/25497-cbafa5a7f branch May 15, 2026 16:53
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants