Browse Source

Merge branch 'master' into fixes/Warnings/CS0618/ListItemAutomationPeer-Missing

pull/10177/head
Max Katz 4 years ago
committed by GitHub
parent
commit
dfd1b1fc6c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      src/Avalonia.Base/Animation/Animatable.cs
  2. 88
      src/Avalonia.Controls/ScrollViewer.cs
  3. 2
      src/tools/DevGenerators/CompositionGenerator/Generator.ListProxy.cs
  4. 4
      src/tools/DevGenerators/CompositionGenerator/Generator.cs
  5. 2
      src/tools/DevGenerators/EnumMemberDictionaryGenerator.cs
  6. 2
      src/tools/DevGenerators/GetProcAddressInitialization.cs

14
src/Avalonia.Base/Animation/Animatable.cs

@ -27,6 +27,7 @@ namespace Avalonia.Animation
AvaloniaProperty.Register<Animatable, Transitions?>(nameof(Transitions)); AvaloniaProperty.Register<Animatable, Transitions?>(nameof(Transitions));
private bool _transitionsEnabled = true; private bool _transitionsEnabled = true;
private bool _isSubscribedToTransitionsCollection = false;
private Dictionary<ITransition, TransitionState>? _transitionState; private Dictionary<ITransition, TransitionState>? _transitionState;
/// <summary> /// <summary>
@ -62,6 +63,11 @@ namespace Avalonia.Animation
if (Transitions is object) if (Transitions is object)
{ {
if (!_isSubscribedToTransitionsCollection)
{
_isSubscribedToTransitionsCollection = true;
Transitions.CollectionChanged += TransitionsCollectionChanged;
}
AddTransitions(Transitions); AddTransitions(Transitions);
} }
} }
@ -72,7 +78,7 @@ namespace Avalonia.Animation
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// This method should not be called from user code, it will be called automatically by the framework /// This method should not be called from user code, it will be called automatically by the framework
/// when a control is added to the visual tree. /// when a control is removed from the visual tree.
/// </remarks> /// </remarks>
protected void DisableTransitions() protected void DisableTransitions()
{ {
@ -82,6 +88,11 @@ namespace Avalonia.Animation
if (Transitions is object) if (Transitions is object)
{ {
if (_isSubscribedToTransitionsCollection)
{
_isSubscribedToTransitionsCollection = false;
Transitions.CollectionChanged -= TransitionsCollectionChanged;
}
RemoveTransitions(Transitions); RemoveTransitions(Transitions);
} }
} }
@ -110,6 +121,7 @@ namespace Avalonia.Animation
} }
newTransitions.CollectionChanged += TransitionsCollectionChanged; newTransitions.CollectionChanged += TransitionsCollectionChanged;
_isSubscribedToTransitionsCollection = true;
AddTransitions(toAdd); AddTransitions(toAdd);
} }

88
src/Avalonia.Controls/ScrollViewer.cs

@ -154,15 +154,15 @@ namespace Avalonia.Controls
/// <summary> /// <summary>
/// Defines the <see cref="HorizontalSnapPointsType"/> property. /// Defines the <see cref="HorizontalSnapPointsType"/> property.
/// </summary> /// </summary>
public static readonly StyledProperty<SnapPointsType> HorizontalSnapPointsTypeProperty = public static readonly AttachedProperty<SnapPointsType> HorizontalSnapPointsTypeProperty =
AvaloniaProperty.Register<ScrollViewer, SnapPointsType>( AvaloniaProperty.RegisterAttached<ScrollViewer, Control, SnapPointsType>(
nameof(HorizontalSnapPointsType)); nameof(HorizontalSnapPointsType));
/// <summary> /// <summary>
/// Defines the <see cref="VerticalSnapPointsType"/> property. /// Defines the <see cref="VerticalSnapPointsType"/> property.
/// </summary> /// </summary>
public static readonly StyledProperty<SnapPointsType> VerticalSnapPointsTypeProperty = public static readonly AttachedProperty<SnapPointsType> VerticalSnapPointsTypeProperty =
AvaloniaProperty.Register<ScrollViewer, SnapPointsType>( AvaloniaProperty.RegisterAttached<ScrollViewer, Control, SnapPointsType>(
nameof(VerticalSnapPointsType)); nameof(VerticalSnapPointsType));
/// <summary> /// <summary>
@ -625,6 +625,86 @@ namespace Avalonia.Controls
control.SetValue(HorizontalScrollBarVisibilityProperty, value); control.SetValue(HorizontalScrollBarVisibilityProperty, value);
} }
/// <summary>
/// Gets the value of the HorizontalSnapPointsType attached property.
/// </summary>
/// <param name="control">The control to read the value from.</param>
/// <returns>The value of the property.</returns>
public static SnapPointsType GetHorizontalSnapPointsType(Control control)
{
return control.GetValue(HorizontalSnapPointsTypeProperty);
}
/// <summary>
/// Gets the value of the HorizontalSnapPointsType attached property.
/// </summary>
/// <param name="control">The control to set the value on.</param>
/// <param name="value">The value of the property.</param>
public static void SetHorizontalSnapPointsType(Control control, SnapPointsType value)
{
control.SetValue(HorizontalSnapPointsTypeProperty, value);
}
/// <summary>
/// Gets the value of the VerticalSnapPointsType attached property.
/// </summary>
/// <param name="control">The control to read the value from.</param>
/// <returns>The value of the property.</returns>
public static SnapPointsType GetVerticalSnapPointsType(Control control)
{
return control.GetValue(VerticalSnapPointsTypeProperty);
}
/// <summary>
/// Gets the value of the VerticalSnapPointsType attached property.
/// </summary>
/// <param name="control">The control to set the value on.</param>
/// <param name="value">The value of the property.</param>
public static void SetVerticalSnapPointsType(Control control, SnapPointsType value)
{
control.SetValue(VerticalSnapPointsTypeProperty, value);
}
/// <summary>
/// Gets the value of the HorizontalSnapPointsAlignment attached property.
/// </summary>
/// <param name="control">The control to read the value from.</param>
/// <returns>The value of the property.</returns>
public static SnapPointsAlignment GetHorizontalSnapPointsAlignment(Control control)
{
return control.GetValue(HorizontalSnapPointsAlignmentProperty);
}
/// <summary>
/// Gets the value of the HorizontalSnapPointsAlignment attached property.
/// </summary>
/// <param name="control">The control to set the value on.</param>
/// <param name="value">The value of the property.</param>
public static void SetHorizontalSnapPointsAlignment(Control control, SnapPointsAlignment value)
{
control.SetValue(HorizontalSnapPointsAlignmentProperty, value);
}
/// <summary>
/// Gets the value of the VerticalSnapPointsAlignment attached property.
/// </summary>
/// <param name="control">The control to read the value from.</param>
/// <returns>The value of the property.</returns>
public static SnapPointsAlignment GetVerticalSnapPointsAlignment(Control control)
{
return control.GetValue(VerticalSnapPointsAlignmentProperty);
}
/// <summary>
/// Gets the value of the VerticalSnapPointsAlignment attached property.
/// </summary>
/// <param name="control">The control to set the value on.</param>
/// <param name="value">The value of the property.</param>
public static void SetVerticalSnapPointsAlignment(Control control, SnapPointsAlignment value)
{
control.SetValue(VerticalSnapPointsAlignmentProperty, value);
}
/// <summary> /// <summary>
/// Gets the value of the VerticalScrollBarVisibility attached property. /// Gets the value of the VerticalScrollBarVisibility attached property.
/// </summary> /// </summary>

2
src/tools/DevGenerators/CompositionGenerator/Generator.ListProxy.cs

@ -112,7 +112,7 @@ class Template
var defs = cl.Members.OfType<MethodDeclarationSyntax>().First(m => m.Identifier.Text == "InitializeDefaults"); var defs = cl.Members.OfType<MethodDeclarationSyntax>().First(m => m.Identifier.Text == "InitializeDefaults");
cl = cl.ReplaceNode(defs.Body, defs.Body.AddStatements( cl = cl.ReplaceNode(defs.Body!, defs.Body!.AddStatements(
ParseStatement($"_list = new ServerListProxyHelper<{itemType}, {serverItemType}>(this);"))); ParseStatement($"_list = new ServerListProxyHelper<{itemType}, {serverItemType}>(this);")));

4
src/tools/DevGenerators/CompositionGenerator/Generator.cs

@ -297,8 +297,8 @@ namespace Avalonia.SourceGenerator.CompositionGenerator
server = server.WithBaseList( server = server.WithBaseList(
server.BaseList?.AddTypes(SimpleBaseType(ParseTypeName(impl.ServerName)))); server.BaseList?.AddTypes(SimpleBaseType(ParseTypeName(impl.ServerName))));
client = client.AddMembers( if(ParseMemberDeclaration($"{impl.ServerName} {impl.Name}.Server => Server;") is { } member)
ParseMemberDeclaration($"{impl.ServerName} {impl.Name}.Server => Server;")); client = client.AddMembers(member);
} }

2
src/tools/DevGenerators/EnumMemberDictionaryGenerator.cs

@ -32,7 +32,7 @@ public class EnumMemberDictionaryGenerator : IIncrementalGenerator
).Collect(); ).Collect();
context.RegisterSourceOutput(all, static (context, methods) => context.RegisterSourceOutput(all, static (context, methods) =>
{ {
foreach (var typeGroup in methods.GroupBy(f => f.ContainingType, SymbolEqualityComparer.Default)) foreach (var typeGroup in methods.GroupBy<IMethodSymbol,ISymbol>(f => f.ContainingType, SymbolEqualityComparer.Default))
{ {
var classBuilder = new StringBuilder(); var classBuilder = new StringBuilder();
if (typeGroup.Key.ContainingNamespace != null) if (typeGroup.Key.ContainingNamespace != null)

2
src/tools/DevGenerators/GetProcAddressInitialization.cs

@ -34,7 +34,7 @@ public class GetProcAddressInitializationGenerator : IIncrementalGenerator
var all = fieldsWithAttribute.Collect(); var all = fieldsWithAttribute.Collect();
context.RegisterSourceOutput(all, static (context, methods) => context.RegisterSourceOutput(all, static (context, methods) =>
{ {
foreach (var typeGroup in methods.GroupBy(f => f.ContainingType, SymbolEqualityComparer.Default)) foreach (var typeGroup in methods.GroupBy<IMethodSymbol,ISymbol>(f => f.ContainingType, SymbolEqualityComparer.Default))
{ {
var nextContext = 0; var nextContext = 0;
var contexts = new Dictionary<string, int>(); var contexts = new Dictionary<string, int>();

Loading…
Cancel
Save