Browse Source
Merge pull request #7758 from Gillibald/fixes/CompiledMethodToCommandBinding
Fix compiled method to command binding
fixes/center-screen-maximized-parent
Dan Walmsley
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
12 additions and
3 deletions
-
src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/XamlIlBindingPathHelper.cs
|
|
|
@ -72,10 +72,19 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions |
|
|
|
|
|
|
|
private static XamlIlBindingPathNode TransformForTargetTyping(XamlIlBindingPathNode transformed, AstTransformationContext context) |
|
|
|
{ |
|
|
|
if (context.ParentNodes().OfType<XamlPropertyAssignmentNode>().FirstOrDefault().Property.Getter.ReturnType == context.GetAvaloniaTypes().ICommand |
|
|
|
&& transformed.Elements[transformed.Elements.Count - 1] is XamlIlClrMethodPathElementNode method) |
|
|
|
var parentNode = context.ParentNodes().OfType<XamlPropertyAssignmentNode>().FirstOrDefault(); |
|
|
|
|
|
|
|
if (parentNode == null) |
|
|
|
{ |
|
|
|
return transformed; |
|
|
|
} |
|
|
|
|
|
|
|
var lastElement = |
|
|
|
transformed.Elements[transformed.Elements.Count - 1]; |
|
|
|
|
|
|
|
if (parentNode.Property?.Getter?.ReturnType == context.GetAvaloniaTypes().ICommand && lastElement is XamlIlClrMethodPathElementNode methodPathElement) |
|
|
|
{ |
|
|
|
IXamlMethod executeMethod = method.Method; |
|
|
|
IXamlMethod executeMethod = methodPathElement.Method; |
|
|
|
IXamlMethod canExecuteMethod = executeMethod.DeclaringType.FindMethod(new FindMethodMethodSignature($"Can{executeMethod.Name}", context.Configuration.WellKnownTypes.Boolean, context.Configuration.WellKnownTypes.Object)); |
|
|
|
List<string> dependsOnProperties = new(); |
|
|
|
if (canExecuteMethod is not null) |
|
|
|
|