Update XamlX (#15488)

* Update XAMLX

* And update XamlX again

---------

Co-authored-by: Jumar Macato <16554748+jmacato@users.noreply.github.com>
This commit is contained in:
Max Katz
2024-04-24 00:34:35 -07:00
committed by GitHub
parent aa60e5d2f9
commit e38edb258d
9 changed files with 43 additions and 14 deletions
@@ -182,7 +182,8 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions
}
public static bool CustomValueConverter(AstTransformationContext context,
IXamlAstValueNode node, IXamlType type, out IXamlAstValueNode result)
IXamlAstValueNode node, IReadOnlyList<IXamlCustomAttribute> customAttributes, IXamlType type,
out IXamlAstValueNode result)
{
if (node is AvaloniaXamlIlOptionMarkupExtensionTransformer.OptionsMarkupExtensionNode optionsNode)
{
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using XamlX.Ast;
using XamlX.Emit;
@@ -61,6 +62,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers
public PropertySetterBinderParameters BinderParameters { get; } =
new PropertySetterBinderParameters { AllowXNull = false };
public IReadOnlyList<IXamlType> Parameters { get; }
public IReadOnlyList<IXamlCustomAttribute> CustomAttributes => Array.Empty<IXamlCustomAttribute>();
}
class ClassBindingSetter : IXamlEmitablePropertySetter<IXamlILEmitter>
@@ -92,6 +94,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers
public PropertySetterBinderParameters BinderParameters { get; } =
new PropertySetterBinderParameters { AllowXNull = false };
public IReadOnlyList<IXamlType> Parameters { get; }
public IReadOnlyList<IXamlCustomAttribute> CustomAttributes => Array.Empty<IXamlCustomAttribute>();
}
}
}
@@ -99,6 +99,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers
public PropertySetterBinderParameters BinderParameters { get; }
public IReadOnlyList<IXamlType> Parameters { get; }
public IReadOnlyList<IXamlCustomAttribute> CustomAttributes => _adder.CustomAttributes;
public void Emit(IXamlILEmitter emitter)
{
@@ -339,6 +339,8 @@ internal class AvaloniaXamlIlOptionMarkupExtensionTransformer : IXamlAstTransfor
public IXamlMethod MakeGenericMethod(IReadOnlyList<IXamlType> typeArguments) => throw new NotImplementedException();
public IReadOnlyList<IXamlCustomAttribute> CustomAttributes => Array.Empty<IXamlCustomAttribute>();
public IXamlParameterInfo GetParameterInfo(int index) => new AnonymousParameterInfo(Parameters[index], index);
public void EmitCall(XamlEmitContext<IXamlILEmitter, XamlILNodeEmitResult> context, IXamlILEmitter codeGen)
{
// At this point this extension will be called from MarkupExtensionEmitter.
@@ -109,6 +109,8 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers
public IXamlType TargetType { get; }
public PropertySetterBinderParameters BinderParameters { get; }
public IReadOnlyList<IXamlType> Parameters { get; }
public IReadOnlyList<IXamlCustomAttribute> CustomAttributes => _method.CustomAttributes;
public void Emit(IXamlILEmitter codegen)
{
if (_type.IsValueType)
@@ -123,6 +123,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers
public IXamlType TargetType => _parent.DeclaringType;
public PropertySetterBinderParameters BinderParameters { get; } = new PropertySetterBinderParameters();
public IReadOnlyList<IXamlType> Parameters { get; }
public IReadOnlyList<IXamlCustomAttribute> CustomAttributes => _parent.CustomAttributes;
public void Emit(IXamlILEmitter emitter)
{
var so = _parent._config.WellKnownTypes.Object;
@@ -178,6 +179,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers
public IReadOnlyList<IXamlType> Parameters { get; }
public IReadOnlyList<IXamlCustomAttribute> CustomAttributes => DeclaringType.CustomAttributes;
public IXamlParameterInfo GetParameterInfo(int index) => new AnonymousParameterInfo(Parameters[index], index);
public void EmitCall(IXamlILEmitter emitter)
{
@@ -228,6 +228,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions
public PropertySetterBinderParameters BinderParameters { get; }
public IReadOnlyList<IXamlType> Parameters { get; set; }
public IReadOnlyList<IXamlCustomAttribute> CustomAttributes => Array.Empty<IXamlCustomAttribute>();
public abstract void Emit(IXamlILEmitter emitter);
@@ -152,8 +152,8 @@ internal class RoslynType : IXamlType
_symbol.Constructors
.Select(method => new RoslynConstructor(method, _assembly))
.ToList();
public IReadOnlyList<IXamlCustomAttribute> CustomAttributes { get; } = new List<IXamlCustomAttribute>();
public IReadOnlyList<IXamlCustomAttribute> CustomAttributes { get; } = Array.Empty<IXamlCustomAttribute>();
public IReadOnlyList<IXamlType> GenericArguments { get; private set; } = new List<IXamlType>();
@@ -189,6 +189,8 @@ internal class RoslynType : IXamlType
public IXamlType GetEnumUnderlyingType() => null;
public IReadOnlyList<IXamlType> GenericParameters { get; } = new List<IXamlType>();
public bool IsFunctionPointer => false;
}
internal class RoslynConstructor : IXamlConstructor
@@ -212,10 +214,10 @@ internal class RoslynConstructor : IXamlConstructor
public IReadOnlyList<IXamlType> Parameters =>
_symbol.Parameters
.Select(parameter => parameter.Type)
.OfType<INamedTypeSymbol>()
.Select(type => new RoslynType(type, _assembly))
.Select(parameter => new RoslynParameter(_assembly, parameter).ParameterType)
.ToList();
public IXamlParameterInfo GetParameterInfo(int index) => new RoslynParameter(_assembly, _symbol.Parameters[index]);
}
internal class RoslynProperty : IXamlProperty
@@ -243,12 +245,28 @@ internal class RoslynProperty : IXamlProperty
public IXamlMethod Getter => _symbol.GetMethod == null ? null : new RoslynMethod(_symbol.GetMethod, _assembly);
public IXamlMethod Setter => _symbol.SetMethod == null ? null : new RoslynMethod(_symbol.SetMethod, _assembly);
public IReadOnlyList<IXamlCustomAttribute> CustomAttributes { get; } = new List<IXamlCustomAttribute>();
public IReadOnlyList<IXamlCustomAttribute> CustomAttributes { get; } = Array.Empty<IXamlCustomAttribute>();
public IReadOnlyList<IXamlType> IndexerParameters { get; } = new List<IXamlType>();
}
internal class RoslynParameter : IXamlParameterInfo
{
private readonly RoslynAssembly _assembly;
private readonly IParameterSymbol _symbol;
public RoslynParameter(RoslynAssembly assembly, IParameterSymbol symbol)
{
_assembly = assembly;
_symbol = symbol;
}
public string Name => _symbol.Name;
public IXamlType ParameterType => new RoslynType((INamedTypeSymbol)_symbol.Type, _assembly);
public IReadOnlyList<IXamlCustomAttribute> CustomAttributes => Array.Empty<IXamlCustomAttribute>();
}
internal class RoslynMethod : IXamlMethod
{
private readonly IMethodSymbol _symbol;
@@ -277,14 +295,13 @@ internal class RoslynMethod : IXamlMethod
public IXamlType ReturnType => new RoslynType((INamedTypeSymbol) _symbol.ReturnType, _assembly);
public IReadOnlyList<IXamlType> Parameters =>
_symbol.Parameters.Select(parameter => parameter.Type)
.OfType<INamedTypeSymbol>()
.Select(type => new RoslynType(type, _assembly))
_symbol.Parameters.Select(parameter => new RoslynParameter(_assembly, parameter).ParameterType)
.ToList();
public IXamlType DeclaringType => new RoslynType((INamedTypeSymbol)_symbol.ReceiverType, _assembly);
public IXamlMethod MakeGenericMethod(IReadOnlyList<IXamlType> typeArguments) => null;
public IReadOnlyList<IXamlCustomAttribute> CustomAttributes { get; } = new List<IXamlCustomAttribute>();
public IReadOnlyList<IXamlCustomAttribute> CustomAttributes { get; } = Array.Empty<IXamlCustomAttribute>();
public IXamlParameterInfo GetParameterInfo(int index) => new RoslynParameter(_assembly, _symbol.Parameters[index]);
}