Browse Source
Merge pull request #5075 from MarchingCube/compile-time-cursor-parse
Parse cursor type during xaml compilation
pull/5081/head
Dan Walmsley
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
18 additions and
0 deletions
-
src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs
-
src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs
|
|
|
@ -341,6 +341,18 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (type.Equals(types.Cursor)) |
|
|
|
{ |
|
|
|
if (TypeSystemHelpers.TryGetEnumValueNode(types.StandardCursorType, text, node, out var enumConstantNode)) |
|
|
|
{ |
|
|
|
var cursorTypeRef = new XamlAstClrTypeReference(node, types.Cursor, false); |
|
|
|
|
|
|
|
result = new XamlAstNewClrObjectNode(node, cursorTypeRef, types.CursorTypeConstructor, new List<IXamlAstValueNode> { enumConstantNode }); |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (type.FullName == "Avalonia.AvaloniaProperty") |
|
|
|
{ |
|
|
|
var scope = context.ParentNodes().OfType<AvaloniaXamlIlTargetTypeMetadataNode>().FirstOrDefault(); |
|
|
|
|
|
|
|
@ -69,6 +69,9 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers |
|
|
|
public IXamlType GridLength { get; } |
|
|
|
public IXamlConstructor GridLengthConstructorValueType { get; } |
|
|
|
public IXamlType Color { get; } |
|
|
|
public IXamlType StandardCursorType { get; } |
|
|
|
public IXamlType Cursor { get; } |
|
|
|
public IXamlConstructor CursorTypeConstructor { get; } |
|
|
|
|
|
|
|
public AvaloniaXamlIlWellKnownTypes(TransformerConfiguration cfg) |
|
|
|
{ |
|
|
|
@ -150,6 +153,9 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers |
|
|
|
GridLength = cfg.TypeSystem.GetType("Avalonia.Controls.GridLength"); |
|
|
|
GridLengthConstructorValueType = GridLength.GetConstructor(new List<IXamlType> { XamlIlTypes.Double, cfg.TypeSystem.GetType("Avalonia.Controls.GridUnitType") }); |
|
|
|
Color = cfg.TypeSystem.GetType("Avalonia.Media.Color"); |
|
|
|
StandardCursorType = cfg.TypeSystem.GetType("Avalonia.Input.StandardCursorType"); |
|
|
|
Cursor = cfg.TypeSystem.GetType("Avalonia.Input.Cursor"); |
|
|
|
CursorTypeConstructor = Cursor.GetConstructor(new List<IXamlType> { StandardCursorType }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|