diff --git a/azure-pipelines-integrationtests.yml b/azure-pipelines-integrationtests.yml
index 5735da19ab..7221fe4657 100644
--- a/azure-pipelines-integrationtests.yml
+++ b/azure-pipelines-integrationtests.yml
@@ -1,11 +1,3 @@
-# Starter pipeline
-# Start with a minimal pipeline that you can customize to build and deploy your code.
-# Add steps that build, run tests, deploy, and more:
-# https://aka.ms/yaml
-
-trigger:
-- master
-
jobs:
- job: Mac
pool:
@@ -25,6 +17,7 @@ jobs:
- script: system_profiler SPDisplaysDataType |grep Resolution
- script: |
+ sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
pkill node
appium &
pkill IntegrationTestApp
diff --git a/samples/IntegrationTestApp/IntegrationTestApp.csproj b/samples/IntegrationTestApp/IntegrationTestApp.csproj
index 0a761d70ba..1356eeb526 100644
--- a/samples/IntegrationTestApp/IntegrationTestApp.csproj
+++ b/samples/IntegrationTestApp/IntegrationTestApp.csproj
@@ -19,6 +19,7 @@
+
diff --git a/src/Avalonia.Base/Rendering/Composition/CompositingRenderer.cs b/src/Avalonia.Base/Rendering/Composition/CompositingRenderer.cs
index 01299e4ffa..df3a70b3e6 100644
--- a/src/Avalonia.Base/Rendering/Composition/CompositingRenderer.cs
+++ b/src/Avalonia.Base/Rendering/Composition/CompositingRenderer.cs
@@ -225,7 +225,7 @@ public class CompositingRenderer : IRendererWithCompositor
sortedChildren.Dispose();
}
else
- foreach (var ch in v.GetVisualChildren())
+ foreach (var ch in visualChildren)
{
var compositionChild = ch.CompositionVisual;
if (compositionChild != null)
diff --git a/src/Avalonia.Base/StyledElement.cs b/src/Avalonia.Base/StyledElement.cs
index 82e948eea8..cbdf3c3c1e 100644
--- a/src/Avalonia.Base/StyledElement.cs
+++ b/src/Avalonia.Base/StyledElement.cs
@@ -803,8 +803,11 @@ namespace Avalonia
if (theme.HasChildren)
{
- foreach (var child in theme.Children)
- ApplyStyle(child, null, type);
+ var children = theme.Children;
+ for (var i = 0; i < children.Count; i++)
+ {
+ ApplyStyle(children[i], null, type);
+ }
}
}
@@ -816,8 +819,11 @@ namespace Avalonia
if (host.IsStylesInitialized)
{
- foreach (var style in host.Styles)
- ApplyStyle(style, host, FrameType.Style);
+ var styles = host.Styles;
+ for (var i = 0; i < styles.Count; ++i)
+ {
+ ApplyStyle(styles[i], host, FrameType.Style);
+ }
}
}
@@ -826,8 +832,11 @@ namespace Avalonia
if (style is Style s)
s.TryAttach(this, host, type);
- foreach (var child in style.Children)
- ApplyStyle(child, host, type);
+ var children = style.Children;
+ for (var i = 0; i < children.Count; i++)
+ {
+ ApplyStyle(children[i], host, type);
+ }
}
private void ReevaluateImplicitTheme()
diff --git a/src/Avalonia.Base/Styling/OrSelector.cs b/src/Avalonia.Base/Styling/OrSelector.cs
index c5ef9a0b2b..3b0aa03492 100644
--- a/src/Avalonia.Base/Styling/OrSelector.cs
+++ b/src/Avalonia.Base/Styling/OrSelector.cs
@@ -71,9 +71,9 @@ namespace Avalonia.Styling
var activators = new OrActivatorBuilder();
var neverThisInstance = false;
- foreach (var selector in _selectors)
+ for (var i = 0; i < _selectors.Count; i++)
{
- var match = selector.Match(control, parent, subscribe);
+ var match = _selectors[i].Match(control, parent, subscribe);
switch (match.Result)
{
@@ -108,16 +108,19 @@ namespace Avalonia.Styling
internal override void ValidateNestingSelector(bool inControlTheme)
{
- foreach (var selector in _selectors)
- selector.ValidateNestingSelector(inControlTheme);
+ for (var i = 0; i < _selectors.Count; i++)
+ {
+ _selectors[i].ValidateNestingSelector(inControlTheme);
+ }
}
private Type? EvaluateTargetType()
{
Type? result = null;
- foreach (var selector in _selectors)
+ for (var i = 0; i < _selectors.Count; i++)
{
+ var selector = _selectors[i];
if (selector.TargetType == null)
{
return null;
diff --git a/src/Avalonia.Base/Styling/TypeNameAndClassSelector.cs b/src/Avalonia.Base/Styling/TypeNameAndClassSelector.cs
index 7883fd23ab..f8670cfdb3 100644
--- a/src/Avalonia.Base/Styling/TypeNameAndClassSelector.cs
+++ b/src/Avalonia.Base/Styling/TypeNameAndClassSelector.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using Avalonia.Controls;
using Avalonia.Styling.Activators;
using Avalonia.Utilities;
@@ -15,7 +14,7 @@ namespace Avalonia.Styling
internal class TypeNameAndClassSelector : Selector
{
private readonly Selector? _previous;
- private readonly Lazy> _classes = new Lazy>(() => new List());
+ private List? _classes;
private Type? _targetType;
private string? _selectorString;
@@ -81,7 +80,7 @@ namespace Avalonia.Styling
///
/// The style classes which the selector matches.
///
- public IList Classes => _classes.Value;
+ public IList Classes => _classes ??= new();
///
public override string ToString(Style? owner)
@@ -122,16 +121,16 @@ namespace Avalonia.Styling
return SelectorMatch.NeverThisInstance;
}
- if (_classes.IsValueCreated && _classes.Value.Count > 0)
+ if (_classes is { Count: > 0 })
{
if (subscribe)
{
- var observable = new StyleClassActivator((Classes)control.Classes, _classes.Value);
+ var observable = new StyleClassActivator(control.Classes, _classes);
return new SelectorMatch(observable);
}
- if (!StyleClassActivator.AreClassesMatching(control.Classes, Classes))
+ if (!StyleClassActivator.AreClassesMatching(control.Classes, _classes))
{
return SelectorMatch.NeverThisInstance;
}
@@ -172,9 +171,9 @@ namespace Avalonia.Styling
builder.Append(Name);
}
- if (_classes.IsValueCreated && _classes.Value.Count > 0)
+ if (_classes is { Count: > 0 })
{
- foreach (var c in Classes)
+ foreach (var c in _classes)
{
if (!c.StartsWith(":"))
{
diff --git a/src/Avalonia.Base/Utilities/AvaloniaPropertyDictionary.cs b/src/Avalonia.Base/Utilities/AvaloniaPropertyDictionary.cs
index 5cac2ef658..0589abb2dd 100644
--- a/src/Avalonia.Base/Utilities/AvaloniaPropertyDictionary.cs
+++ b/src/Avalonia.Base/Utilities/AvaloniaPropertyDictionary.cs
@@ -304,13 +304,9 @@ namespace Avalonia.Utilities
{
if (_entryCount == _entries!.Length)
{
- const double growthFactor = 1.2;
- var newSize = (int)(_entryCount * growthFactor);
-
- if (newSize == _entryCount)
- {
- newSize++;
- }
+ var newSize = _entryCount == DefaultInitialCapacity ?
+ DefaultInitialCapacity * 2 :
+ (int)(_entryCount * 1.5);
var destEntries = new Entry[newSize];
diff --git a/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/CompiledBindings/CompiledBindingPath.cs b/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/CompiledBindings/CompiledBindingPath.cs
index 2b62d33349..f196231a6b 100644
--- a/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/CompiledBindings/CompiledBindingPath.cs
+++ b/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/CompiledBindings/CompiledBindingPath.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
-using System.Linq;
using System.Reflection;
using Avalonia.Controls;
using Avalonia.Data.Core;
@@ -13,13 +12,14 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings
{
public class CompiledBindingPath
{
- private readonly List _elements = new List();
+ private readonly ICompiledBindingPathElement[] _elements;
- public CompiledBindingPath() { }
+ public CompiledBindingPath()
+ => _elements = Array.Empty();
- internal CompiledBindingPath(IEnumerable bindingPath, object rawSource)
+ internal CompiledBindingPath(ICompiledBindingPathElement[] elements, object rawSource)
{
- _elements = new List(bindingPath);
+ _elements = elements;
RawSource = rawSource;
}
@@ -78,13 +78,13 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings
internal IEnumerable Elements => _elements;
- internal SourceMode SourceMode => _elements.OfType().Any()
+ internal SourceMode SourceMode => Array.Exists(_elements, e => e is IControlSourceBindingPathElement)
? SourceMode.Control : SourceMode.Data;
internal object RawSource { get; }
public override string ToString()
- => string.Concat(_elements);
+ => string.Concat((IEnumerable) _elements);
}
public class CompiledBindingPathBuilder
@@ -169,7 +169,7 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings
return this;
}
- public CompiledBindingPath Build() => new CompiledBindingPath(_elements, _rawSource);
+ public CompiledBindingPath Build() => new CompiledBindingPath(_elements.ToArray(), _rawSource);
}
public interface ICompiledBindingPathElement