diff --git a/src/Avalonia.Base/Data/CompiledBinding.cs b/src/Avalonia.Base/Data/CompiledBinding.cs
index e243246b4f..ca8ecc62ff 100644
--- a/src/Avalonia.Base/Data/CompiledBinding.cs
+++ b/src/Avalonia.Base/Data/CompiledBinding.cs
@@ -28,7 +28,7 @@ public class CompiledBinding : BindingBase
///
/// The binding path.
public CompiledBinding(CompiledBindingPath path) => Path = path;
-
+
///
/// Creates a from a lambda expression.
///
@@ -81,12 +81,10 @@ public class CompiledBinding : BindingBase
/// - Indexers: x => x.Items[0]
/// - Type casts: x => ((DerivedType)x).Property
/// - Logical NOT: x => !x.BoolProperty
- /// - Stream bindings: x => x.TaskProperty (Task/Observable)
/// - AvaloniaProperty access: x => x[MyProperty]
///
///
- [RequiresDynamicCode(TrimmingMessages.ExpressionNodeRequiresDynamicCodeMessage)]
- [RequiresUnreferencedCode(TrimmingMessages.ExpressionNodeRequiresUnreferencedCodeMessage)]
+ [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "Expression statically preserves members used in binding expressions.")]
public static CompiledBinding Create(
Expression> expression,
object? source = null,
diff --git a/src/Avalonia.Base/Data/CompiledBindingPath.cs b/src/Avalonia.Base/Data/CompiledBindingPath.cs
index 886d89df43..2b8b914122 100644
--- a/src/Avalonia.Base/Data/CompiledBindingPath.cs
+++ b/src/Avalonia.Base/Data/CompiledBindingPath.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using Avalonia.Controls;
using Avalonia.Data.Core;
@@ -155,12 +156,26 @@ namespace Avalonia.Data
return this;
}
+ [RequiresUnreferencedCode(TrimmingMessages.StreamPluginRequiresUnreferencedCodeMessage)]
+ public CompiledBindingPathBuilder StreamTask()
+ {
+ _elements.Add(new TaskStreamPathElement());
+ return this;
+ }
+
public CompiledBindingPathBuilder StreamObservable()
{
_elements.Add(new ObservableStreamPathElement());
return this;
}
+ [RequiresUnreferencedCode(TrimmingMessages.StreamPluginRequiresUnreferencedCodeMessage)]
+ public CompiledBindingPathBuilder StreamObservable()
+ {
+ _elements.Add(new ObservableStreamPathElement());
+ return this;
+ }
+
public CompiledBindingPathBuilder Self()
{
_elements.Add(new SelfPathElement());
@@ -197,6 +212,12 @@ namespace Avalonia.Data
return this;
}
+ public CompiledBindingPathBuilder TypeCast(Type targetType)
+ {
+ _elements.Add(new TypeCastPathElement(targetType));
+ return this;
+ }
+
public CompiledBindingPathBuilder TemplatedParent()
{
_elements.Add(new TemplatedParentPathElement());
@@ -299,6 +320,14 @@ namespace Avalonia.Data
public IStreamPlugin CreatePlugin() => new TaskStreamPlugin();
}
+ [RequiresUnreferencedCode(TrimmingMessages.StreamPluginRequiresUnreferencedCodeMessage)]
+ internal class TaskStreamPathElement : IStronglyTypedStreamElement
+ {
+ public static readonly TaskStreamPathElement Instance = new TaskStreamPathElement();
+
+ public IStreamPlugin CreatePlugin() => new TaskStreamPlugin();
+ }
+
internal class ObservableStreamPathElement : IStronglyTypedStreamElement
{
public static readonly ObservableStreamPathElement Instance = new ObservableStreamPathElement();
@@ -306,6 +335,14 @@ namespace Avalonia.Data
public IStreamPlugin CreatePlugin() => new ObservableStreamPlugin();
}
+ [RequiresUnreferencedCode(TrimmingMessages.StreamPluginRequiresUnreferencedCodeMessage)]
+ internal class ObservableStreamPathElement : IStronglyTypedStreamElement
+ {
+ public static readonly ObservableStreamPathElement Instance = new ObservableStreamPathElement();
+
+ public IStreamPlugin CreatePlugin() => new ObservableStreamPlugin();
+ }
+
internal class SelfPathElement : ICompiledBindingPathElement, IControlSourceBindingPathElement
{
public static readonly SelfPathElement Instance = new SelfPathElement();
@@ -387,7 +424,28 @@ namespace Avalonia.Data
public Type Type => typeof(T);
- public Func