Browse Source
Merge branch 'master' into missing-ScrollGestureEndedEvent-mapping
pull/9911/head
Max Katz
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with
31 additions and
26 deletions
-
src/Avalonia.Base/Controls/NameScopeExtensions.cs
-
src/Avalonia.Build.Tasks/ComInteropHelper.cs
-
src/Avalonia.Controls/PullToRefresh/ScrollViewerIRefreshInfoProviderAdapter.cs
-
src/Avalonia.Controls/Templates/FuncTreeDataTemplate`1.cs
-
src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlDetailsViewModel.cs
-
src/Markup/Avalonia.Markup/Markup/Parsers/SelectorGrammar.cs
-
src/Windows/Avalonia.Win32.Interop/Wpf/IntSize.cs
-
src/Windows/Avalonia.Win32/WindowImpl.CustomCaptionProc.cs
|
|
|
@ -25,13 +25,18 @@ namespace Avalonia.Controls |
|
|
|
|
|
|
|
var result = nameScope.Find(name); |
|
|
|
|
|
|
|
if (result != null && !(result is T)) |
|
|
|
if (result == null) |
|
|
|
{ |
|
|
|
throw new InvalidOperationException( |
|
|
|
$"Expected control '{name}' to be '{typeof(T)} but it was '{result.GetType()}'."); |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
return (T?)result; |
|
|
|
if (result is T typed) |
|
|
|
{ |
|
|
|
return typed; |
|
|
|
} |
|
|
|
|
|
|
|
throw new InvalidOperationException( |
|
|
|
$"Expected control '{name}' to be '{typeof(T)} but it was '{result.GetType()}'."); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -74,13 +79,13 @@ namespace Avalonia.Controls |
|
|
|
throw new KeyNotFoundException($"Could not find control '{name}'."); |
|
|
|
} |
|
|
|
|
|
|
|
if (!(result is T)) |
|
|
|
if (result is T typed) |
|
|
|
{ |
|
|
|
throw new InvalidOperationException( |
|
|
|
$"Expected control '{name}' to be '{typeof(T)} but it was '{result.GetType()}'."); |
|
|
|
return typed; |
|
|
|
} |
|
|
|
|
|
|
|
return (T)result; |
|
|
|
throw new InvalidOperationException( |
|
|
|
$"Expected control '{name}' to be '{typeof(T)} but it was '{result.GetType()}'."); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
@ -65,10 +65,8 @@ namespace Avalonia.Build.Tasks |
|
|
|
{ |
|
|
|
Instruction instruction = instructions[i]; |
|
|
|
|
|
|
|
if (instruction.OpCode == OpCodes.Call && instruction.Operand is MethodReference) |
|
|
|
if (instruction.OpCode == OpCodes.Call && instruction.Operand is MethodReference methodDescription) |
|
|
|
{ |
|
|
|
var methodDescription = (MethodReference)instruction.Operand; |
|
|
|
|
|
|
|
if (methodDescription.Name.StartsWith("Calli") && methodDescription.DeclaringType.Name == "LocalInterop") |
|
|
|
{ |
|
|
|
var callSite = new CallSite(methodDescription.ReturnType) { CallingConvention = MethodCallingConvention.StdCall }; |
|
|
|
|
|
|
|
@ -197,12 +197,12 @@ namespace Avalonia.Controls.PullToRefresh |
|
|
|
throw new ArgumentException(nameof(_scrollViewer), "Adaptee's content property must be a Visual"); |
|
|
|
} |
|
|
|
|
|
|
|
if (content.Parent is not InputElement) |
|
|
|
if (content.Parent is not InputElement parent) |
|
|
|
{ |
|
|
|
throw new ArgumentException(nameof(_scrollViewer), "Adaptee's content parent must be an InputElement"); |
|
|
|
} |
|
|
|
|
|
|
|
MakeInteractionSource(content.Parent as InputElement); |
|
|
|
MakeInteractionSource(parent); |
|
|
|
|
|
|
|
if (_scrollViewer != null) |
|
|
|
{ |
|
|
|
|
|
|
|
@ -59,7 +59,7 @@ namespace Avalonia.Controls.Templates |
|
|
|
/// <returns>The untyped function.</returns>
|
|
|
|
private static Func<object?, bool> CastMatch(Func<T, bool> f) |
|
|
|
{ |
|
|
|
return o => (o is T) && f((T)o); |
|
|
|
return o => o is T arg && f(arg); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -72,7 +72,7 @@ namespace Avalonia.Controls.Templates |
|
|
|
{ |
|
|
|
return (o, s) => f((T)o!, s); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Casts a function with a typed parameter to an untyped function.
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
@ -33,12 +33,12 @@ namespace Avalonia.Diagnostics.ViewModels |
|
|
|
{ |
|
|
|
_avaloniaObject = avaloniaObject; |
|
|
|
|
|
|
|
TreePage = treePage; |
|
|
|
Layout = avaloniaObject is Visual |
|
|
|
? new ControlLayoutViewModel((Visual)avaloniaObject) |
|
|
|
TreePage = treePage; |
|
|
|
Layout = avaloniaObject is Visual visual |
|
|
|
? new ControlLayoutViewModel(visual) |
|
|
|
: default; |
|
|
|
|
|
|
|
NavigateToProperty(_avaloniaObject, (_avaloniaObject as Control)?.Name ?? _avaloniaObject.ToString()); |
|
|
|
NavigateToProperty(_avaloniaObject, (_avaloniaObject as Control)?.Name ?? _avaloniaObject.ToString()); |
|
|
|
|
|
|
|
AppliedStyles = new ObservableCollection<StyleViewModel>(); |
|
|
|
PseudoClasses = new ObservableCollection<PseudoClassViewModel>(); |
|
|
|
|
|
|
|
@ -552,7 +552,8 @@ namespace Avalonia.Markup.Parsers |
|
|
|
|
|
|
|
public override bool Equals(object? obj) |
|
|
|
{ |
|
|
|
return obj is ClassSyntax && ((ClassSyntax)obj).Class == Class; |
|
|
|
return obj is ClassSyntax syntax && |
|
|
|
syntax.Class == Class; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -562,7 +563,8 @@ namespace Avalonia.Markup.Parsers |
|
|
|
|
|
|
|
public override bool Equals(object? obj) |
|
|
|
{ |
|
|
|
return obj is NameSyntax && ((NameSyntax)obj).Name == Name; |
|
|
|
return obj is NameSyntax syntax && |
|
|
|
syntax.Name == Name; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -574,9 +576,9 @@ namespace Avalonia.Markup.Parsers |
|
|
|
|
|
|
|
public override bool Equals(object? obj) |
|
|
|
{ |
|
|
|
return obj is PropertySyntax && |
|
|
|
((PropertySyntax)obj).Property == Property && |
|
|
|
((PropertySyntax)obj).Value == Value; |
|
|
|
return obj is PropertySyntax syntax && |
|
|
|
syntax.Property == Property && |
|
|
|
syntax.Value == Value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -28,7 +28,7 @@ namespace Avalonia.Win32.Interop.Wpf |
|
|
|
public override bool Equals(object obj) |
|
|
|
{ |
|
|
|
if (ReferenceEquals(null, obj)) return false; |
|
|
|
return obj is IntSize && Equals((IntSize) obj); |
|
|
|
return obj is IntSize size && Equals(size); |
|
|
|
} |
|
|
|
|
|
|
|
public override int GetHashCode() |
|
|
|
|
|
|
|
@ -109,7 +109,7 @@ namespace Avalonia.Win32 |
|
|
|
|
|
|
|
if (_owner is Window window) |
|
|
|
{ |
|
|
|
var visual = window.Renderer.HitTestFirst(position, (Visual)_owner, x => |
|
|
|
var visual = window.Renderer.HitTestFirst(position, window, x => |
|
|
|
{ |
|
|
|
if (x is IInputElement ie && (!ie.IsHitTestVisible || !ie.IsEffectivelyVisible)) |
|
|
|
{ |
|
|
|
|