From 07680d413169d7e2781f4483d6abf97a71da77bd Mon Sep 17 00:00:00 2001 From: Christian Lindenau Date: Tue, 14 Oct 2025 09:27:21 +0200 Subject: [PATCH 1/3] Make Dependent implement IEquatable to reduce boxing --- .../WindowsBase/System/Windows/DependentList.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/DependentList.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/DependentList.cs index 9252133c86b..86c8600c83b 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/DependentList.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/DependentList.cs @@ -126,7 +126,7 @@ private void CleanUpDeadWeakReferences() } } - internal struct Dependent + internal struct Dependent : IEquatable { private DependencyProperty _DP; private WeakReference _wrDO; @@ -178,14 +178,14 @@ public Expression Expr return (Expression)_wrEX.Target; } } - + public override bool Equals(object o) { - if(! (o is Dependent)) - return false; - - Dependent d = (Dependent)o; - + return o is Dependent d ? Equals(d) : false; + } + + public override bool Equals(Dependent d) + { // Not equal to Dead values. // This is assuming that at least one of the compared items is live. // This assumtion comes from knowing that Equal is used by FrugalList.Remove() From 1f288f4e8b4a7bbc31b8388e8e15b05fb4cd7dc7 Mon Sep 17 00:00:00 2001 From: Christian Lindenau Date: Tue, 14 Oct 2025 09:42:20 +0200 Subject: [PATCH 2/3] Compiler error --- .../src/WindowsBase/System/Windows/DependentList.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/DependentList.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/DependentList.cs index 86c8600c83b..e83c982419d 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/DependentList.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/DependentList.cs @@ -184,7 +184,7 @@ public override bool Equals(object o) return o is Dependent d ? Equals(d) : false; } - public override bool Equals(Dependent d) + public bool Equals(Dependent d) { // Not equal to Dead values. // This is assuming that at least one of the compared items is live. From 58a1db84d4248b053b2efddca685803001b969ad Mon Sep 17 00:00:00 2001 From: Christian Lindenau Date: Wed, 15 Oct 2025 08:35:26 +0200 Subject: [PATCH 3/3] Update src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/DependentList.cs Co-authored-by: h3xds1nz --- .../src/WindowsBase/System/Windows/DependentList.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/DependentList.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/DependentList.cs index e83c982419d..311d85941ec 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/DependentList.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/DependentList.cs @@ -181,7 +181,7 @@ public Expression Expr public override bool Equals(object o) { - return o is Dependent d ? Equals(d) : false; + return o is Dependent d && Equals(d); } public bool Equals(Dependent d)