8000 [release/v7.4.0-preview.6] Revert change to use `BinaryFormatter` for `Out-GridView` by daxian-dbw · Pull Request #20360 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

[release/v7.4.0-preview.6] Revert change to use BinaryFormatter for Out-GridView #20360

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

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace Microsoft.Management.UI.Internal
/// The generic parameter.
/// </typeparam>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes")]
[Serializable]
public abstract class ComparableValueFilterRule<T> : FilterRule where T : IComparable
{
#region Properties
Expand Down Expand Up @@ -61,19 +62,6 @@ public override bool Evaluate(object item)
return this.Evaluate(castItem);
}

/// <summary>
/// Creates a clone of the ComparableValueFilterRule instance.
/// </summary>
/// <returns>
/// Returns a clone of the ComparableValueFilterRule instance.
/// </returns>
public override FilterRule Clone()
{
ComparableValueFilterRule<T> rule = (ComparableValueFilterRule<T>)Activator.CreateInstance(this.GetType());
rule.DefaultNullValueEvaluation = this.DefaultNullValueEvaluation;
return rule;
}

/// <summary>
/// Determines if item matches a derived classes criteria.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace Microsoft.Management.UI.Internal
/// The generic parameter.
/// </typeparam>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes")]
[Serializable]
public class DoesNotEqualFilterRule<T> : EqualsFilterRule<T> where T : IComparable
{
/// <summary>
Expand All @@ -24,20 +25,6 @@ public DoesNotEqualFilterRule()
this.DefaultNullValueEvaluation = true;
}

/// <summary>
/// Creates a clone of the DoesNotEqualFilterRule instance.
/// </summary>
/// <returns>
/// A clone of the DoesNotEqualFilterRule instance.
/// </returns>
public override FilterRule Clone()
{
DoesNotEqualFilterRule<T> rule = new DoesNotEqualFilterRule<T>();
rule.Value = this.Value;
rule.DefaultNullValueEvaluation = this.DefaultNullValueEvaluation;
return rule;
}

/// <summary>
/// Determines if item is not equal to Value.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace Microsoft.Management.UI.Internal
/// The generic parameter.
/// </typeparam>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes")]
[Serializable]
public class EqualsFilterRule<T> : SingleValueComparableValueFilterRule<T> where T : IComparable
{
/// <summary>
Expand All @@ -24,20 +25,6 @@ public EqualsFilterRule()
this.DisplayName = UICultureResources.FilterRule_Equals;
}

/// <summary>
/// Creates a new EqualsFilterRule that is a clone of the current instance.
/// </summary>
/// <returns>
/// A new EqualsFilterRule that is a clone of the current instance.
/// </returns>
public override FilterRule Clone()
{
EqualsFilterRule<T> rule = new EqualsFilterRule<T>();
rule.Value = this.Value;
rule.DefaultNullValueEvaluation = this.DefaultNullValueEvaluation;
return rule;
}

/// <summary>
/// Determines if item is equal to Value.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Microsoft.Management.UI.Internal
/// The base class for all filtering rules.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes")]
[Serializable]
public abstract class FilterRule : IEvaluate
{
/// <summary>
Expand Down Expand Up @@ -48,12 +49,6 @@ protected FilterRule()
/// <returns>Returns true if the item meets the criteria. False otherwise.</returns>
public abstract bool Evaluate(object item);

/// <summary>
/// Creates a clone of this FilterRule.
/// </summary>
/// <returns>Returns a clone of this FilterRule.</returns>
public abstract FilterRule Clone();

#region EvaluationResultInvalidated

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,30 @@ public static class FilterRuleExtensions
/// </returns>
public static FilterRule DeepCopy(this FilterRule rule)
{
return rule.Clone();
ArgumentNullException.ThrowIfNull(rule);

#pragma warning disable SYSLIB0050
Debug.Assert(rule.GetType().IsSerializable, "rule is serializable");
#pragma warning disable SYSLIB0011
BinaryFormatter formatter = new BinaryFormatter(null, new StreamingContext(StreamingContextStates.Clone));
#pragma warning restore SYSLIB0011
MemoryStream ms = new MemoryStream();

FilterRule copy = null;
try
{
formatter.Serialize(ms, rule);

ms.Position = 0;
copy = (FilterRule)formatter.Deserialize(ms);
#pragma warning restore SYSLIB0050
}
finally
{
ms.Close();
}

return copy;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace Microsoft.Management.UI.Internal
/// The generic parameter.
/// </typeparam>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes")]
[Serializable]
public class IsBetweenFilterRule<T> : ComparableValueFilterRule<T> where T : IComparable
{
#region Properties
Expand Down Expand Up @@ -50,21 +51,6 @@ public ValidatingValue<T> EndValue
protected set;
}

/// <summary>
/// Creates a clone of the FilterRule.
/// </summary>
/// <returns>
/// A clone of the FilterRule.
/// </returns>
public override FilterRule Clone()
{
IsBetweenFilterRule<T> clone = new IsBetweenFilterRule<T>();
clone.DefaultNullValueEvaluation = this.DefaultNullValueEvaluation;
clone.StartValue = this.StartValue;
clone.EndValue = this.EndValue;
return clone;
}

#endregion Properties

#region Ctor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Microsoft.Management.UI.Internal
/// is empty or not.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes")]
[Serializable]
public class IsEmptyFilterRule : FilterRule
{
/// <summary>
Expand All @@ -20,18 +21,6 @@ public IsEmptyFilterRule()
this.DisplayName = UICultureResources.FilterRule_IsEmpty;
}

/// <summary>
/// Creates a clone of the IsEmptyFilterRule instance.
/// </summary>
/// <returns>
/// A clone of IsEmptyFilterRule instance.
/// </returns>
public override FilterRule Clone()
{
IsEmptyFilterRule rule = new IsEmptyFilterRule();
return rule;
}

/// <summary>
/// Gets a values indicating whether the supplied item is empty.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace Microsoft.Management.UI.Internal
/// The generic parameter.
/// </typeparam>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes")]
[Serializable]
public class IsGreaterThanFilterRule<T> : SingleValueComparableValueFilterRule<T> where T : IComparable
{
/// <summary>
Expand All @@ -24,20 +25,6 @@ public IsGreaterThanFilterRule()
this.DisplayName = UICultureResources.FilterRule_GreaterThanOrEqual;
}

/// <summary>
/// Creates a new IsGreaterThanFilterRule that is a clone of the current instance.
/// </summary>
/// <returns>
/// A new IsGreaterThanFilterRule that is a clone of the current instance.
/// </returns>
public override FilterRule Clone()
{
IsGreaterThanFilterRule<T> rule = new IsGreaterThanFilterRule<T>();
rule.Value = this.Value;
rule.DefaultNullValueEvaluation = this.DefaultNullValueEvaluation;
return rule;
}

/// <summary>
/// Determines if item is greater than Value.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace Microsoft.Management.UI.Internal
/// The generic parameter.
/// </typeparam>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes")]
[Serializable]
public class IsLessThanFilterRule<T> : SingleValueComparableValueFilterRule<T> where T : IComparable
{
/// <summary>
Expand All @@ -24,20 +25,6 @@ public IsLessThanFilterRule()
this.DisplayName = UICultureResources.FilterRule_LessThanOrEqual;
}

/// <summary>
/// Creates a new IsLessThanFilterRule that is a clone of the current instance.
/// </summary>
/// <returns>
/// A new IsLessThanFilterRule that is a clone of the current instance.
/// </returns>
public override FilterRule Clone()
{
IsLessThanFilterRule<T> rule = new IsLessThanFilterRule<T>();
rule.Value = this.Value;
rule.DefaultNullValueEvaluation = this.DefaultNullValueEvaluation;
return rule;
}

/// <summary>
/// Determines if item is less than Value.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Microsoft.Management.UI.Internal
/// is empty or not.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes")]
[Serializable]
public class IsNotEmptyFilterRule : IsEmptyFilterRule
{
/// <summary>
Expand All @@ -20,18 +21,6 @@ public IsNotEmptyFilterRule()
this.DisplayName = UICultureResources.FilterRule_IsNotEmpty;
}

/// <summary>
/// Creates a clone of the IsNotEmptyFilterRule.
/// </summary>
/// <returns>
/// A clone of the IsNotEmptyFilterRule.
/// </returns>
public override FilterRule Clone()
{
IsNotEmptyFilterRule rule = new IsNotEmptyFilterRule();
return rule;
}

/// <summary>
/// Gets a values indicating whether the supplied item is not empty.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Microsoft.Management.UI.Internal
/// The IsNotEmptyValidationRule checks a value to see if a value is not empty.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes")]
[Serializable]
public class IsNotEmptyValidationRule : DataErrorInfoValidationRule
{
#region Properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Microsoft.Management.UI.Internal
/// Represents a filter rule that searches for text within properties on an object.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes")]
[Serializable]
public class PropertiesTextContainsFilterRule : TextFilterRule
{
private static readonly string TextContainsCharactersRegexPattern = "{0}";
Expand All @@ -37,20 +38,6 @@ public ICollection<string> PropertyNames
private set;
}

/// <summary>
/// Creates a clone of this <see cref="PropertiesTextContainsFilterRule"/>.
/// </summary>
/// <returns>
/// A clone of this <see cref="PropertiesTextContainsFilterRule"/>.
/// </returns>
public override FilterRule Clone()
{
PropertiesTextContainsFilterRule clone = new PropertiesTextContainsFilterRule();
clone.DefaultNullValueEvaluation = this.DefaultNullValueEvaluation;
clone.PropertyNames = new List<string>(this.PropertyNames);
return clone;
}

/// <summary>
/// Evaluates whether the specified properties on <paramref name="item"/> contain the current value.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace Microsoft.Management.UI.Internal
/// The generic parameter.
/// </typeparam>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes")]
[Serializable]
public class PropertyValueSelectorFilterRule<T> : SelectorFilterRule where T : IComparable
{
#region Properties
Expand Down Expand Up @@ -65,11 +66,6 @@ public PropertyValueSelectorFilterRule(string propertyName, string propertyDispl
/// </param>
public PropertyValueSelectorFilterRule(string propertyName, string propertyDisplayName, IEnumerable<FilterRule> rules)
{
ArgumentException.ThrowIfNullOrEmpty(propertyName);
ArgumentException.ThrowIfNullOrEmpty(propertyDisplayName);

ArgumentNullException.ThrowIfNull(rules);

this.PropertyName = propertyName;
this.DisplayName = propertyDisplayName;

Expand Down Expand Up @@ -120,17 +116,6 @@ public override bool Evaluate(object item)
return this.AvailableRules.SelectedValue.Evaluate(propertyValue);
}

/// <summary>
/// Creates a clone of the PropertyValueSelectorFilterRule instance.
/// </summary>
/// <returns>
/// Returns a clone of the PropertyValueSelectorFilterRule instance.
/// </returns>
public override FilterRule Clone()
{
return new PropertyValueSelectorFilterRule<T>(this.PropertyName, this.DisplayName, this.AvailableRules.AvailableValues);
}

#endregion Public Methods

#region Private Methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Microsoft.Management.UI.Internal
/// The SelectorFilterRule represents a rule composed of other rules.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes")]
[Serializable]
public class SelectorFilterRule : FilterRule
{
#region Properties
Expand Down Expand Up @@ -70,23 +71,6 @@ public override bool Evaluate(object item)
return this.AvailableRules.SelectedValue.Evaluate(item);
}

/// <summary>
/// Creates a clone of the SelectorFilterRule instance.
/// </summary>
/// <returns>
/// Returns a clone of the SelectorFilterRule instance.
/// </returns>
public override FilterRule Clone()
{
SelectorFilterRule clone = new SelectorFilterRule();
clone.DisplayName = this.DisplayName;
clone.AvailableRules = this.AvailableRules;
clone.AvailableRules.SelectedValueChanged += clone.AvailableRules_SelectedValueChanged;
clone.AvailableRules.SelectedValue.EvaluationResultInvalidated += clone.SelectedValue_EvaluationResultInvalidated;

return clone;
}

/// <summary>
/// Called when the SelectedValue within AvailableRules changes.
/// </summary>
Expand Down
Loading
0