Browse Source

Obsolete CompiledBindingPathBuilder.SetRawSource (#16505)

pull/16539/head
Julien Lebosquain 2 years ago
committed by GitHub
parent
commit
0f4ed21ae0
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 16
      src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlBindingPathParser.cs
  2. 25
      src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/XamlIlBindingPathHelper.cs
  3. 14
      src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/CompiledBindings/CompiledBindingPath.cs

16
src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlBindingPathParser.cs

@ -336,20 +336,4 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers
{
public IXamlType Type { get; set; }
}
class RawSourceBindingExpressionNode : XamlAstNode, BindingExpressionGrammar.INode
{
public RawSourceBindingExpressionNode(IXamlAstValueNode rawSource)
: base(rawSource)
{
RawSource = rawSource;
}
public IXamlAstValueNode RawSource { get; private set; }
public override void VisitChildren(IXamlAstVisitor visitor)
{
RawSource = (IXamlAstValueNode)RawSource.Visit(visitor);
}
}
}

25
src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/XamlIlBindingPathHelper.cs

@ -325,9 +325,6 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions
}
nodes.Add(new ElementNamePathElementNode(elementName.Name, elementType));
break;
case RawSourceBindingExpressionNode rawSource:
nodes.Add(new RawSourcePathElementNode(rawSource.RawSource));
break;
case BindingExpressionGrammar.TypeCastNode typeCastNode:
var castType = GetType(typeCastNode.Namespace, typeCastNode.TypeName);
@ -862,28 +859,6 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions
public IXamlType Type => _arrayType.ArrayElementType;
}
class RawSourcePathElementNode : XamlAstNode, IXamlIlBindingPathElementNode
{
private readonly IXamlAstValueNode _rawSource;
public RawSourcePathElementNode(IXamlAstValueNode rawSource)
: base(rawSource)
{
_rawSource = rawSource;
}
public IXamlType Type => _rawSource.Type.GetClrType();
public void Emit(XamlIlEmitContext context, IXamlILEmitter codeGen)
{
context.Emit(_rawSource, codeGen, Type);
codeGen
.EmitCall(context.GetAvaloniaTypes()
.CompiledBindingPathBuilder.FindMethod(m => m.Name == "SetRawSource"));
}
}
class TypeCastPathElementNode : IXamlIlBindingPathElementNode
{
public TypeCastPathElementNode(IXamlType ancestorType)

14
src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/CompiledBindings/CompiledBindingPath.cs

@ -16,11 +16,8 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings
public CompiledBindingPath()
=> _elements = Array.Empty<ICompiledBindingPathElement>();
internal CompiledBindingPath(ICompiledBindingPathElement[] elements, object? rawSource)
{
_elements = elements;
RawSource = rawSource;
}
internal CompiledBindingPath(ICompiledBindingPathElement[] elements)
=> _elements = elements;
internal void BuildExpression(List<ExpressionNode> result, out bool isRooted)
{
@ -97,8 +94,6 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings
internal SourceMode SourceMode => Array.Exists(_elements, e => e is IControlSourceBindingPathElement)
? SourceMode.Control : SourceMode.Data;
internal object? RawSource { get; }
/// <inheritdoc />
public override string ToString()
=> string.Concat((IEnumerable<ICompiledBindingPathElement>) _elements);
@ -107,7 +102,6 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings
public class CompiledBindingPathBuilder
{
private readonly int _apiVersion;
private object? _rawSource;
private readonly List<ICompiledBindingPathElement> _elements = new();
public CompiledBindingPathBuilder()
@ -210,13 +204,13 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings
return this;
}
[Obsolete("This method doesn't do anything anymore. Use Binding.Source instead.")]
public CompiledBindingPathBuilder SetRawSource(object? rawSource)
{
_rawSource = rawSource;
return this;
}
public CompiledBindingPath Build() => new CompiledBindingPath(_elements.ToArray(), _rawSource);
public CompiledBindingPath Build() => new CompiledBindingPath(_elements.ToArray());
}
internal interface ICompiledBindingPathElement

Loading…
Cancel
Save