From 492cbe53f23ee2218b39b8685f8cdd359439fb01 Mon Sep 17 00:00:00 2001 From: Yoh Deadfall Date: Thu, 3 Oct 2024 17:51:08 +0300 Subject: [PATCH] Avoid Select when no boxing required (#16886) Co-authored-by: Julien Lebosquain --- src/Avalonia.Base/AvaloniaObjectExtensions.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Base/AvaloniaObjectExtensions.cs b/src/Avalonia.Base/AvaloniaObjectExtensions.cs index 0017f955830..76138beb4d6 100644 --- a/src/Avalonia.Base/AvaloniaObjectExtensions.cs +++ b/src/Avalonia.Base/AvaloniaObjectExtensions.cs @@ -18,7 +18,10 @@ public static class AvaloniaObjectExtensions /// An . public static IBinding ToBinding(this IObservable source) { - return new BindingAdaptor(source.Select(x => (object?)x)); + return new BindingAdaptor( + typeof(T).IsValueType + ? source.Select(x => (object?)x) + : (IObservable)source); } ///