Browse Source

Merge branch 'master' into textboxfixbugs

pull/733/head
AndrewSt 10 years ago
committed by GitHub
parent
commit
97af2b4587
  1. 25
      build.cake
  2. 26
      samples/ControlCatalog.Android/ControlCatalog.Android.v2.ncrunchproject
  3. 2
      src/Android/Avalonia.Android/Platform/SkiaPlatform/MainWindowImpl.cs
  4. 2
      src/Avalonia.Animation/Avalonia.Animation.csproj
  5. 1
      src/Avalonia.Base/Avalonia.Base.csproj
  6. 2
      src/Avalonia.Base/AvaloniaObject.cs
  7. 5
      src/Avalonia.Base/AvaloniaPropertyRegistry.cs
  8. 1
      src/Avalonia.Base/Collections/AvaloniaDictionary.cs
  9. 2
      src/Avalonia.Base/Collections/AvaloniaList.cs
  10. 2
      src/Avalonia.Base/Data/InstancedBinding.cs
  11. 3
      src/Avalonia.Base/Platform/IPlatformThreadingInterface.cs
  12. 1
      src/Avalonia.Base/PriorityBindingEntry.cs
  13. 6
      src/Avalonia.Controls/AppBuilderBase.cs
  14. 1
      src/Avalonia.Controls/Avalonia.Controls.csproj
  15. 1
      src/Avalonia.Controls/Classes.cs
  16. 5
      src/Avalonia.Controls/Generators/TreeItemContainerGenerator.cs
  17. 3
      src/Avalonia.Controls/HotkeyManager.cs
  18. 2
      src/Avalonia.Controls/Platform/PlatformManager.cs
  19. 5
      src/Avalonia.Controls/Presenters/CarouselPresenter.cs
  20. 2
      src/Avalonia.Controls/Presenters/ItemVirtualizer.cs
  21. 1
      src/Avalonia.Controls/Presenters/ItemVirtualizerSimple.cs
  22. 2
      src/Avalonia.Controls/Presenters/TextPresenter.cs
  23. 2
      src/Avalonia.Controls/ScrollViewer.cs
  24. 31
      src/Avalonia.Controls/TextBox.cs
  25. 1
      src/Avalonia.Controls/TopLevel.cs
  26. 1
      src/Avalonia.Diagnostics/Avalonia.Diagnostics.csproj
  27. 3
      src/Avalonia.Diagnostics/ViewModels/DevToolsViewModel.cs
  28. 22
      src/Avalonia.DotNetFrameworkRuntime/AppBuilder.cs
  29. 1
      src/Avalonia.DotNetFrameworkRuntime/Avalonia.DotNetFrameworkRuntime.csproj
  30. 1
      src/Avalonia.Input/Avalonia.Input.csproj
  31. 1
      src/Avalonia.Input/Navigation/DirectionalNavigation.cs
  32. 1
      src/Avalonia.Interactivity/Avalonia.Interactivity.csproj
  33. 1
      src/Avalonia.Layout/Avalonia.Layout.csproj
  34. 3
      src/Avalonia.Logging.Serilog/Avalonia.Logging.Serilog.csproj
  35. 12
      src/Avalonia.Logging.Serilog/SerilogLogger.cs
  36. 1
      src/Avalonia.SceneGraph/Avalonia.SceneGraph.csproj
  37. 24
      src/Avalonia.SceneGraph/Media/DrawingContext.cs
  38. 11
      src/Avalonia.SceneGraph/Media/FormattedText.cs
  39. 1
      src/Avalonia.SceneGraph/Media/Imaging/RenderTargetBitmap.cs
  40. 1
      src/Avalonia.SceneGraph/Media/MatrixTransform.cs
  41. 8
      src/Avalonia.SceneGraph/Media/PathMarkupParser.cs
  42. 1
      src/Avalonia.SceneGraph/Media/RotateTransform.cs
  43. 1
      src/Avalonia.SceneGraph/Media/ScaleTransform.cs
  44. 2
      src/Avalonia.SceneGraph/Media/StreamGeometry.cs
  45. 1
      src/Avalonia.SceneGraph/Media/Transform.cs
  46. 1
      src/Avalonia.SceneGraph/Media/TranslateTransform.cs
  47. 1
      src/Avalonia.Styling/Avalonia.Styling.csproj
  48. 6
      src/Avalonia.Styling/Styling/SelectorMatch.cs
  49. 1
      src/Avalonia.Styling/Styling/Style.cs
  50. 1
      src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj
  51. 2
      src/Gtk/Avalonia.Gtk/EmbeddableImpl.cs
  52. 4
      src/Gtk/Avalonia.Gtk/WindowImplBase.cs
  53. 12
      src/Markup/Avalonia.Markup.Xaml/AvaloniaXamlLoader.cs
  54. 1
      src/Markup/Avalonia.Markup/Avalonia.Markup.csproj
  55. 12
      src/Shared/PlatformSupport/AssetLoader.cs
  56. 1
      src/Windows/Avalonia.Direct2D1/Avalonia.Direct2D1.csproj
  57. 4
      src/Windows/Avalonia.Direct2D1/Media/StreamGeometryImpl.cs
  58. 1
      src/Windows/Avalonia.Win32/Avalonia.Win32.csproj
  59. 3
      tests/Avalonia.Base.UnitTests/AvaloniaObjectTests_Direct.cs
  60. 2
      tests/Avalonia.Controls.UnitTests/Primitives/TabStripTests.cs
  61. 98
      tests/Avalonia.Input.UnitTests/KeyboardNavigationTests_Arrows.cs
  62. 121
      tests/Avalonia.Input.UnitTests/KeyboardNavigationTests_Tab.cs
  63. 4
      tests/Avalonia.Interactivity.UnitTests/Properties/AssemblyInfo.cs
  64. 2
      tests/Avalonia.Markup.UnitTests/Data/BindingExpressionTests.cs
  65. 2
      tests/Avalonia.Markup.UnitTests/Data/ExpressionObserverTests_DataValidation.cs
  66. 3
      tests/Avalonia.Markup.UnitTests/Data/Plugins/DataAnnotationsValidationPluginTests.cs
  67. 1
      tests/Avalonia.SceneGraph.UnitTests/Avalonia.SceneGraph.UnitTests.csproj
  68. 28
      tests/Avalonia.SceneGraph.UnitTests/Media/FormattedTextTests.cs
  69. 1
      tests/Avalonia.SceneGraph.UnitTests/Media/PathMarkupParserTests.cs
  70. 2
      tests/Avalonia.Styling.UnitTests/TestControlBase.cs
  71. 1
      tests/Avalonia.UnitTests/Avalonia.UnitTests.csproj
  72. 33
      tests/Avalonia.UnitTests/InvariantCultureFixture.cs

25
build.cake

@ -635,21 +635,19 @@ Task("Run-Unit-Tests")
.WithCriteria(() => !skipTests) .WithCriteria(() => !skipTests)
.Does(() => .Does(() =>
{ {
var pattern = "./tests/Avalonia.*.UnitTests/bin/" + dirSuffix + "/Avalonia.*.UnitTests.dll"; var unitTests = GetDirectories("./tests/Avalonia.*.UnitTests")
.Select(dir => System.IO.Path.GetFileName(dir.FullPath))
Func<IFileSystemInfo, bool> ExcludeWindowsTests = i => { .Where(name => isRunningOnWindows ? true : !(name.IndexOf("Direct2D", StringComparison.OrdinalIgnoreCase) >= 0))
return !(i.Path.FullPath.IndexOf("Direct2D", StringComparison.OrdinalIgnoreCase) >= 0); .Select(name => MakeAbsolute(File("./tests/" + name + "/bin/" + dirSuffix + "/" + name + ".dll")))
}; .ToList();
var unitTests = isRunningOnWindows ? GetFiles(pattern) : GetFiles(pattern, ExcludeWindowsTests);
if (isRunningOnWindows) if (isRunningOnWindows)
{ {
var windowsTests = GetFiles("./tests/Avalonia.DesignerSupport.Tests/bin/" + dirSuffix + "/*Tests.dll") + var windowsTests = GetFiles("./tests/Avalonia.DesignerSupport.Tests/bin/" + dirSuffix + "/*.Tests.dll") +
GetFiles("./tests/Avalonia.LeakTests/bin/" + dirSuffix + "/*Tests.dll") + GetFiles("./tests/Avalonia.LeakTests/bin/" + dirSuffix + "/*.LeakTests.dll") +
GetFiles("./tests/Avalonia.RenderTests/bin/" + dirSuffix + "/*Tests.dll"); GetFiles("./tests/Avalonia.RenderTests/bin/" + dirSuffix + "/*.RenderTests.dll");
unitTests += windowsTests; unitTests.AddRange(windowsTests);
} }
var toolPath = (isPlatformAnyCPU || isPlatformX86) ? var toolPath = (isPlatformAnyCPU || isPlatformX86) ?
@ -662,10 +660,7 @@ Task("Run-Unit-Tests")
Parallelism = ParallelismOption.None Parallelism = ParallelismOption.None
}; };
if (isRunningOnWindows) settings.NoAppDomain = !isRunningOnWindows;
{
settings.NoAppDomain = false;
}
foreach (var file in unitTests) foreach (var file in unitTests)
{ {

26
samples/ControlCatalog.Android/ControlCatalog.Android.v2.ncrunchproject

@ -0,0 +1,26 @@
<ProjectConfiguration>
<AutoDetectNugetBuildDependencies>true</AutoDetectNugetBuildDependencies>
<BuildPriority>1000</BuildPriority>
<CopyReferencedAssembliesToWorkspace>false</CopyReferencedAssembliesToWorkspace>
<ConsiderInconclusiveTestsAsPassing>false</ConsiderInconclusiveTestsAsPassing>
<PreloadReferencedAssemblies>false</PreloadReferencedAssemblies>
<AllowDynamicCodeContractChecking>true</AllowDynamicCodeContractChecking>
<AllowStaticCodeContractChecking>false</AllowStaticCodeContractChecking>
<AllowCodeAnalysis>false</AllowCodeAnalysis>
<IgnoreThisComponentCompletely>true</IgnoreThisComponentCompletely>
<RunPreBuildEvents>false</RunPreBuildEvents>
<RunPostBuildEvents>false</RunPostBuildEvents>
<PreviouslyBuiltSuccessfully>false</PreviouslyBuiltSuccessfully>
<InstrumentAssembly>true</InstrumentAssembly>
<PreventSigningOfAssembly>false</PreventSigningOfAssembly>
<AnalyseExecutionTimes>true</AnalyseExecutionTimes>
<DetectStackOverflow>true</DetectStackOverflow>
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
<DefaultTestTimeout>60000</DefaultTestTimeout>
<UseBuildConfiguration />
<UseBuildPlatform />
<ProxyProcessPath />
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
<MSTestThreadApartmentState>STA</MSTestThreadApartmentState>
<BuildProcessArchitecture>x86</BuildProcessArchitecture>
</ProjectConfiguration>

2
src/Android/Avalonia.Android/Platform/SkiaPlatform/MainWindowImpl.cs

@ -14,7 +14,7 @@ namespace Avalonia.Android.Platform.SkiaPlatform
{ {
} }
public WindowState WindowState public new WindowState WindowState
{ {
get { return WindowState.Normal; } get { return WindowState.Normal; }
set { } set { }

2
src/Avalonia.Animation/Avalonia.Animation.csproj

@ -25,6 +25,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Avalonia.Animation.XML</DocumentationFile> <DocumentationFile>bin\Debug\Avalonia.Animation.XML</DocumentationFile>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
@ -35,6 +36,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Avalonia.Animation.XML</DocumentationFile> <DocumentationFile>bin\Release\Avalonia.Animation.XML</DocumentationFile>
<NoWarn>CS1591</NoWarn> <NoWarn>CS1591</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included --> <!-- A reference to the entire .NET Framework is automatically included -->

1
src/Avalonia.Base/Avalonia.Base.csproj

@ -38,6 +38,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Avalonia.Base.XML</DocumentationFile> <DocumentationFile>bin\Release\Avalonia.Base.XML</DocumentationFile>
<NoWarn>CS1591</NoWarn> <NoWarn>CS1591</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="..\Shared\SharedAssemblyInfo.cs"> <Compile Include="..\Shared\SharedAssemblyInfo.cs">

2
src/Avalonia.Base/AvaloniaObject.cs

@ -164,9 +164,7 @@ namespace Avalonia
set set
{ {
var metadata = binding.Property.GetMetadata(GetType());
var sourceBinding = value as IBinding; var sourceBinding = value as IBinding;
this.Bind(binding.Property, sourceBinding); this.Bind(binding.Property, sourceBinding);
} }
} }

5
src/Avalonia.Base/AvaloniaPropertyRegistry.cs

@ -64,8 +64,6 @@ namespace Avalonia
{ {
Contract.Requires<ArgumentNullException>(type != null); Contract.Requires<ArgumentNullException>(type != null);
var i = type.GetTypeInfo();
while (type != null) while (type != null)
{ {
// Ensure the type's static ctor has been run. // Ensure the type's static ctor has been run.
@ -265,7 +263,8 @@ namespace Avalonia
/// <param name="property">The property.</param> /// <param name="property">The property.</param>
/// <remarks> /// <remarks>
/// You won't usually want to call this method directly, instead use the /// You won't usually want to call this method directly, instead use the
/// <see cref="AvaloniaProperty.Register"/> method. /// <see cref="AvaloniaProperty.Register{TOwner, TValue}(string, TValue, bool, Data.BindingMode, Func{TOwner, TValue, TValue}, Action{IAvaloniaObject, bool})"/>
/// method.
/// </remarks> /// </remarks>
public void Register(Type type, AvaloniaProperty property) public void Register(Type type, AvaloniaProperty property)
{ {

1
src/Avalonia.Base/Collections/AvaloniaDictionary.cs

@ -207,7 +207,6 @@ namespace Avalonia.Collections
if (CollectionChanged != null) if (CollectionChanged != null)
{ {
var val = new KeyValuePair<TKey, TValue>(key, value);
var e = new NotifyCollectionChangedEventArgs( var e = new NotifyCollectionChangedEventArgs(
NotifyCollectionChangedAction.Add, NotifyCollectionChangedAction.Add,
new[] { new KeyValuePair<TKey, TValue>(key, value) }, new[] { new KeyValuePair<TKey, TValue>(key, value) },

2
src/Avalonia.Base/Collections/AvaloniaList.cs

@ -397,8 +397,6 @@ namespace Avalonia.Collections
{ {
Contract.Requires<ArgumentNullException>(items != null); Contract.Requires<ArgumentNullException>(items != null);
var list = (items as IList) ?? items.ToList();
foreach (var i in items) foreach (var i in items)
{ {
// TODO: Optimize to only send as many notifications as necessary. // TODO: Optimize to only send as many notifications as necessary.

2
src/Avalonia.Base/Data/InstancedBinding.cs

@ -12,7 +12,7 @@ namespace Avalonia.Data
/// <remarks> /// <remarks>
/// Whereas an <see cref="IBinding"/> holds a description of a binding such as "Bind to the X /// Whereas an <see cref="IBinding"/> holds a description of a binding such as "Bind to the X
/// property on a control's DataContext"; this class represents a binding that has been /// property on a control's DataContext"; this class represents a binding that has been
/// *instanced* by calling <see cref="IBinding.Initiate(IAvaloniaObject, AvaloniaProperty, object)"/> /// *instanced* by calling <see cref="IBinding.Initiate(IAvaloniaObject, AvaloniaProperty, object, bool)"/>
/// on a target object. /// on a target object.
/// ///
/// When a binding is initiated, it can return one of 3 possible sources for the binding: /// When a binding is initiated, it can return one of 3 possible sources for the binding:

3
src/Avalonia.Base/Platform/IPlatformThreadingInterface.cs

@ -21,9 +21,6 @@ namespace Avalonia.Platform
/// <returns>An <see cref="IDisposable"/> used to stop the timer.</returns> /// <returns>An <see cref="IDisposable"/> used to stop the timer.</returns>
IDisposable StartTimer(TimeSpan interval, Action tick); IDisposable StartTimer(TimeSpan interval, Action tick);
/// <summary>
/// Sends a message that causes <see cref="ProcessMessage"/> to exit.
/// </summary>
void Signal(); void Signal();
bool CurrentThreadIsLoopThread { get; } bool CurrentThreadIsLoopThread { get; }

1
src/Avalonia.Base/PriorityBindingEntry.cs

@ -21,7 +21,6 @@ namespace Avalonia
/// <param name="index"> /// <param name="index">
/// The binding index. Later bindings should have higher indexes. /// The binding index. Later bindings should have higher indexes.
/// </param> /// </param>
/// <param name="validation">The validation settings for the binding.</param>
public PriorityBindingEntry(PriorityLevel owner, int index) public PriorityBindingEntry(PriorityLevel owner, int index)
{ {
_owner = owner; _owner = owner;

6
src/Avalonia.Controls/AppBuilderBase.cs

@ -9,9 +9,9 @@ using Avalonia.Platform;
namespace Avalonia.Controls namespace Avalonia.Controls
{ {
/// <summary> /// <summary>
/// Initializes up platform-specific services for an <see cref="Application"/>. /// Base class for initializing platform-specific services for an <see cref="Application"/>.
/// </summary> /// </summary>
/// <typeparam name="TAppBuilder"></typeparam> /// <typeparam name="TAppBuilder">The type of the AppBuilder class itself.</typeparam>
public abstract class AppBuilderBase<TAppBuilder> where TAppBuilder : AppBuilderBase<TAppBuilder>, new() public abstract class AppBuilderBase<TAppBuilder> where TAppBuilder : AppBuilderBase<TAppBuilder>, new()
{ {
/// <summary> /// <summary>
@ -140,6 +140,7 @@ namespace Avalonia.Controls
/// Specifies a windowing subsystem to use. /// Specifies a windowing subsystem to use.
/// </summary> /// </summary>
/// <param name="initializer">The method to call to initialize the windowing subsystem.</param> /// <param name="initializer">The method to call to initialize the windowing subsystem.</param>
/// <param name="name">The name of the windowing subsystem.</param>
/// <returns>An <typeparamref name="TAppBuilder"/> instance.</returns> /// <returns>An <typeparamref name="TAppBuilder"/> instance.</returns>
public TAppBuilder UseWindowingSubsystem(Action initializer, string name = "") public TAppBuilder UseWindowingSubsystem(Action initializer, string name = "")
{ {
@ -159,6 +160,7 @@ namespace Avalonia.Controls
/// Specifies a rendering subsystem to use. /// Specifies a rendering subsystem to use.
/// </summary> /// </summary>
/// <param name="initializer">The method to call to initialize the rendering subsystem.</param> /// <param name="initializer">The method to call to initialize the rendering subsystem.</param>
/// <param name="name">The name of the rendering subsystem.</param>
/// <returns>An <typeparamref name="TAppBuilder"/> instance.</returns> /// <returns>An <typeparamref name="TAppBuilder"/> instance.</returns>
public TAppBuilder UseRenderingSubsystem(Action initializer, string name = "") public TAppBuilder UseRenderingSubsystem(Action initializer, string name = "")
{ {

1
src/Avalonia.Controls/Avalonia.Controls.csproj

@ -38,6 +38,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Avalonia.Controls.XML</DocumentationFile> <DocumentationFile>bin\Release\Avalonia.Controls.XML</DocumentationFile>
<NoWarn>CS1591</NoWarn> <NoWarn>CS1591</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="..\Shared\SharedAssemblyInfo.cs"> <Compile Include="..\Shared\SharedAssemblyInfo.cs">

1
src/Avalonia.Controls/Classes.cs

@ -197,7 +197,6 @@ namespace Avalonia.Controls
/// <param name="count">The number of items to remove.</param> /// <param name="count">The number of items to remove.</param>
public override void RemoveRange(int index, int count) public override void RemoveRange(int index, int count)
{ {
var names = GetRange(index, count);
base.RemoveRange(index, count); base.RemoveRange(index, count);
} }

5
src/Avalonia.Controls/Generators/TreeItemContainerGenerator.cs

@ -124,11 +124,6 @@ namespace Avalonia.Controls.Generators
return false; return false;
} }
/// <summary>
/// Gets the data template for the specified item.
/// </summary>
/// <param name="item">The item.</param>
/// <returns>The template.</returns>
private ITreeDataTemplate GetTreeDataTemplate(object item, IDataTemplate primary) private ITreeDataTemplate GetTreeDataTemplate(object item, IDataTemplate primary)
{ {
var template = Owner.FindDataTemplate(item, primary) ?? FuncDataTemplate.Default; var template = Owner.FindDataTemplate(item, primary) ?? FuncDataTemplate.Default;

3
src/Avalonia.Controls/HotkeyManager.cs

@ -30,8 +30,9 @@ namespace Avalonia.Controls
public void Execute(object parameter) => GetCommand()?.Execute(parameter); public void Execute(object parameter) => GetCommand()?.Execute(parameter);
//Implementation isn't needed in this case #pragma warning disable 67 // Event not used
public event EventHandler CanExecuteChanged; public event EventHandler CanExecuteChanged;
#pragma warning restore 67
} }

2
src/Avalonia.Controls/Platform/PlatformManager.cs

@ -11,7 +11,6 @@ namespace Avalonia.Controls.Platform
=> AvaloniaLocator.Current.GetService<IPlatformSettings>(); => AvaloniaLocator.Current.GetService<IPlatformSettings>();
static bool s_designerMode; static bool s_designerMode;
private static double _designerScalingFactor = 1;
public static IRenderTarget CreateRenderTarget(ITopLevelImpl window) public static IRenderTarget CreateRenderTarget(ITopLevelImpl window)
{ {
@ -28,7 +27,6 @@ namespace Avalonia.Controls.Platform
public static void SetDesignerScalingFactor(double factor) public static void SetDesignerScalingFactor(double factor)
{ {
_designerScalingFactor = factor;
} }
public static IWindowImpl CreateWindow() public static IWindowImpl CreateWindow()

5
src/Avalonia.Controls/Presenters/CarouselPresenter.cs

@ -97,7 +97,9 @@ namespace Avalonia.Controls.Presenters
/// <inheritdoc/> /// <inheritdoc/>
protected override void PanelCreated(IPanel panel) protected override void PanelCreated(IPanel panel)
{ {
var task = MoveToPage(-1, SelectedIndex); #pragma warning disable 4014
MoveToPage(-1, SelectedIndex);
#pragma warning restore 4014
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -139,7 +141,6 @@ namespace Avalonia.Controls.Presenters
if (toIndex != -1) if (toIndex != -1)
{ {
var item = Items.Cast<object>().ElementAt(toIndex);
to = GetOrCreateContainer(toIndex); to = GetOrCreateContainer(toIndex);
} }

2
src/Avalonia.Controls/Presenters/ItemVirtualizer.cs

@ -16,8 +16,6 @@ namespace Avalonia.Controls.Presenters
/// </summary> /// </summary>
internal abstract class ItemVirtualizer : IVirtualizingController, IDisposable internal abstract class ItemVirtualizer : IVirtualizingController, IDisposable
{ {
private bool disposedValue;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ItemVirtualizer"/> class. /// Initializes a new instance of the <see cref="ItemVirtualizer"/> class.
/// </summary> /// </summary>

1
src/Avalonia.Controls/Presenters/ItemVirtualizerSimple.cs

@ -359,7 +359,6 @@ namespace Avalonia.Controls.Presenters
var count = Math.Min(Math.Abs(delta), panel.Children.Count); var count = Math.Min(Math.Abs(delta), panel.Children.Count);
var move = count < panel.Children.Count; var move = count < panel.Children.Count;
var first = delta < 0 && move ? panel.Children.Count + delta : 0; var first = delta < 0 && move ? panel.Children.Count + delta : 0;
var containers = panel.Children.GetRange(first, count).ToList();
for (var i = 0; i < count; ++i) for (var i = 0; i < count; ++i)
{ {

2
src/Avalonia.Controls/Presenters/TextPresenter.cs

@ -219,7 +219,7 @@ namespace Avalonia.Controls.Presenters
{ {
var text = Text; var text = Text;
if (!string.IsNullOrWhiteSpace(text)) if (!string.IsNullOrEmpty(text))
{ {
return base.MeasureOverride(availableSize); return base.MeasureOverride(availableSize);
} }

2
src/Avalonia.Controls/ScrollViewer.cs

@ -157,7 +157,7 @@ namespace Avalonia.Controls
/// </summary> /// </summary>
public ScrollViewer() public ScrollViewer()
{ {
var extentAndViewport = Observable.CombineLatest( Observable.CombineLatest(
this.GetObservable(ExtentProperty), this.GetObservable(ExtentProperty),
this.GetObservable(ViewportProperty)) this.GetObservable(ViewportProperty))
.Select(x => new { Extent = x[0], Viewport = x[1] }); .Select(x => new { Extent = x[0], Viewport = x[1] });

31
src/Avalonia.Controls/TextBox.cs

@ -105,7 +105,7 @@ namespace Avalonia.Controls
public TextBox() public TextBox()
{ {
var canScrollHorizontally = this.GetObservable(TextWrappingProperty) this.GetObservable(TextWrappingProperty)
.Select(x => x == TextWrapping.NoWrap) .Select(x => x == TextWrapping.NoWrap)
.Subscribe(x => CanScrollHorizontally = x); .Subscribe(x => CanScrollHorizontally = x);
@ -380,8 +380,20 @@ namespace Avalonia.Controls
if (!DeleteSelection() && CaretIndex > 0) if (!DeleteSelection() && CaretIndex > 0)
{ {
SetTextInternal(text.Substring(0, caretIndex - 1) + text.Substring(caretIndex)); var removedCharacters = 1;
--CaretIndex; // handle deleting /r/n
// you don't ever want to leave a dangling /r around. So, if deleting /n, check to see if
// a /r should also be deleted.
if (CaretIndex > 1 &&
text[CaretIndex - 1] == '\n' &&
text[CaretIndex - 2] == '\r')
{
removedCharacters = 2;
}
SetTextInternal(text.Substring(0, caretIndex - removedCharacters) + text.Substring(caretIndex));
CaretIndex -= removedCharacters;
SelectionStart = SelectionEnd = CaretIndex;
} }
break; break;
@ -394,7 +406,18 @@ namespace Avalonia.Controls
if (!DeleteSelection() && caretIndex < text.Length) if (!DeleteSelection() && caretIndex < text.Length)
{ {
SetTextInternal(text.Substring(0, caretIndex) + text.Substring(caretIndex + 1)); var removedCharacters = 1;
// handle deleting /r/n
// you don't ever want to leave a dangling /r around. So, if deleting /n, check to see if
// a /r should also be deleted.
if (CaretIndex < text.Length - 1 &&
text[caretIndex + 1] == '\n' &&
text[caretIndex] == '\r')
{
removedCharacters = 2;
}
SetTextInternal(text.Substring(0, caretIndex) + text.Substring(caretIndex + removedCharacters));
} }
break; break;

1
src/Avalonia.Controls/TopLevel.cs

@ -88,7 +88,6 @@ namespace Avalonia.Controls
PlatformImpl = impl; PlatformImpl = impl;
dependencyResolver = dependencyResolver ?? AvaloniaLocator.Current; dependencyResolver = dependencyResolver ?? AvaloniaLocator.Current;
var renderInterface = TryGetService<IPlatformRenderInterface>(dependencyResolver);
var styler = TryGetService<IStyler>(dependencyResolver); var styler = TryGetService<IStyler>(dependencyResolver);
_accessKeyHandler = TryGetService<IAccessKeyHandler>(dependencyResolver); _accessKeyHandler = TryGetService<IAccessKeyHandler>(dependencyResolver);
_inputManager = TryGetService<IInputManager>(dependencyResolver); _inputManager = TryGetService<IInputManager>(dependencyResolver);

1
src/Avalonia.Diagnostics/Avalonia.Diagnostics.csproj

@ -38,6 +38,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Avalonia.Diagnostics.XML</DocumentationFile> <DocumentationFile>bin\Release\Avalonia.Diagnostics.XML</DocumentationFile>
<NoWarn>CS1591</NoWarn> <NoWarn>CS1591</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included --> <!-- A reference to the entire .NET Framework is automatically included -->

3
src/Avalonia.Diagnostics/ViewModels/DevToolsViewModel.cs

@ -11,8 +11,6 @@ namespace Avalonia.Diagnostics.ViewModels
{ {
internal class DevToolsViewModel : ReactiveObject internal class DevToolsViewModel : ReactiveObject
{ {
private IControl _root;
private ReactiveObject _content; private ReactiveObject _content;
private int _selectedTab; private int _selectedTab;
@ -27,7 +25,6 @@ namespace Avalonia.Diagnostics.ViewModels
public DevToolsViewModel(IControl root) public DevToolsViewModel(IControl root)
{ {
_root = root;
_logicalTree = new TreePageViewModel(LogicalTreeNode.Create(root)); _logicalTree = new TreePageViewModel(LogicalTreeNode.Create(root));
_visualTree = new TreePageViewModel(VisualTreeNode.Create(root)); _visualTree = new TreePageViewModel(VisualTreeNode.Create(root));

22
src/Avalonia.DotNetFrameworkRuntime/AppBuilder.cs

@ -1,27 +1,39 @@
using System; using System;
using System.Collections.Generic; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Platform; using Avalonia.Platform;
using Avalonia.Shared.PlatformSupport; using Avalonia.Shared.PlatformSupport;
using System.IO;
namespace Avalonia namespace Avalonia
{ {
/// <summary>
/// Initializes platform-specific services for an <see cref="Application"/>.
/// </summary>
public sealed class AppBuilder : AppBuilderBase<AppBuilder> public sealed class AppBuilder : AppBuilderBase<AppBuilder>
{ {
public AppBuilder() : base(new StandardRuntimePlatform(), () => StandardRuntimePlatformServices.Register()) /// <summary>
/// Initializes a new instance of the <see cref="AppBuilder"/> class.
/// </summary>
public AppBuilder()
: base(new StandardRuntimePlatform(), () => StandardRuntimePlatformServices.Register())
{ {
} }
/// <summary>
/// Initializes a new instance of the <see cref="AppBuilder"/> class.
/// </summary>
/// <param name="app">The <see cref="Application"/> instance.</param>
public AppBuilder(Application app) : this() public AppBuilder(Application app) : this()
{ {
Instance = app; Instance = app;
} }
/// <summary>
/// Instructs the <see cref="AppBuilder"/> to use the best settings for the platform.
/// </summary>
/// <returns>An <see cref="AppBuilder"/> instance.</returns>
public AppBuilder UsePlatformDetect() public AppBuilder UsePlatformDetect()
{ {
var os = RuntimePlatform.GetRuntimeInfo().OperatingSystem; var os = RuntimePlatform.GetRuntimeInfo().OperatingSystem;

1
src/Avalonia.DotNetFrameworkRuntime/Avalonia.DotNetFrameworkRuntime.csproj

@ -31,6 +31,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Avalonia.DotNetFrameworkRuntime.xml</DocumentationFile> <DocumentationFile>bin\Release\Avalonia.DotNetFrameworkRuntime.xml</DocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />

1
src/Avalonia.Input/Avalonia.Input.csproj

@ -38,6 +38,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Avalonia.Input.XML</DocumentationFile> <DocumentationFile>bin\Release\Avalonia.Input.XML</DocumentationFile>
<NoWarn>CS1591</NoWarn> <NoWarn>CS1591</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included --> <!-- A reference to the entire .NET Framework is automatically included -->

1
src/Avalonia.Input/Navigation/DirectionalNavigation.cs

@ -90,7 +90,6 @@ namespace Avalonia.Input.Navigation
/// <returns>The element's focusable descendents.</returns> /// <returns>The element's focusable descendents.</returns>
private static IEnumerable<IInputElement> GetFocusableDescendents(IInputElement element) private static IEnumerable<IInputElement> GetFocusableDescendents(IInputElement element)
{ {
var mode = KeyboardNavigation.GetDirectionalNavigation((InputElement)element);
var children = element.GetVisualChildren().OfType<IInputElement>(); var children = element.GetVisualChildren().OfType<IInputElement>();
foreach (var child in children) foreach (var child in children)

1
src/Avalonia.Interactivity/Avalonia.Interactivity.csproj

@ -38,6 +38,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Avalonia.Interactivity.XML</DocumentationFile> <DocumentationFile>bin\Release\Avalonia.Interactivity.XML</DocumentationFile>
<NoWarn>CS1591</NoWarn> <NoWarn>CS1591</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included --> <!-- A reference to the entire .NET Framework is automatically included -->

1
src/Avalonia.Layout/Avalonia.Layout.csproj

@ -38,6 +38,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Avalonia.Layout.XML</DocumentationFile> <DocumentationFile>bin\Release\Avalonia.Layout.XML</DocumentationFile>
<NoWarn>CS1591</NoWarn> <NoWarn>CS1591</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included --> <!-- A reference to the entire .NET Framework is automatically included -->

3
src/Avalonia.Logging.Serilog/Avalonia.Logging.Serilog.csproj

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
@ -34,6 +34,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Avalonia.Logging.Serilog.XML</DocumentationFile> <DocumentationFile>bin\Release\Avalonia.Logging.Serilog.XML</DocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="SerilogLogger.cs" /> <Compile Include="SerilogLogger.cs" />

12
src/Avalonia.Logging.Serilog/SerilogLogger.cs

@ -8,21 +8,33 @@ using SerilogLogEventLevel = Serilog.Events.LogEventLevel;
namespace Avalonia.Logging.Serilog namespace Avalonia.Logging.Serilog
{ {
/// <summary>
/// Sends log output to serilog.
/// </summary>
public class SerilogLogger : ILogSink public class SerilogLogger : ILogSink
{ {
private readonly ILogger _output; private readonly ILogger _output;
private readonly Dictionary<string, ILogger> _areas = new Dictionary<string, ILogger>(); private readonly Dictionary<string, ILogger> _areas = new Dictionary<string, ILogger>();
/// <summary>
/// Initializes a new instance of the <see cref="SerilogLogger"/> class.
/// </summary>
/// <param name="output">The serilog logger to use.</param>
public SerilogLogger(ILogger output) public SerilogLogger(ILogger output)
{ {
_output = output; _output = output;
} }
/// <summary>
/// Initializes the Avalonia logging with a new instance of a <see cref="SerilogLogger"/>.
/// </summary>
/// <param name="output">The serilog logger to use.</param>
public static void Initialize(ILogger output) public static void Initialize(ILogger output)
{ {
Logger.Sink = new SerilogLogger(output); Logger.Sink = new SerilogLogger(output);
} }
/// <inheritdoc/>
public void Log( public void Log(
AvaloniaLogEventLevel level, AvaloniaLogEventLevel level,
string area, string area,

1
src/Avalonia.SceneGraph/Avalonia.SceneGraph.csproj

@ -38,6 +38,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Avalonia.SceneGraph.XML</DocumentationFile> <DocumentationFile>bin\Release\Avalonia.SceneGraph.XML</DocumentationFile>
<NoWarn>CS1591</NoWarn> <NoWarn>CS1591</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included --> <!-- A reference to the entire .NET Framework is automatically included -->

24
src/Avalonia.SceneGraph/Media/DrawingContext.cs

@ -208,6 +208,9 @@ namespace Avalonia.Media
/// Pushes an opacity mask. /// Pushes an opacity mask.
/// </summary> /// </summary>
/// <param name="mask">The opacity mask.</param> /// <param name="mask">The opacity mask.</param>
/// <param name="bounds">
/// The size of the brush's target area. TODO: Are we sure this is needed?
/// </param>
/// <returns>A disposable to undo the opacity mask.</returns> /// <returns>A disposable to undo the opacity mask.</returns>
public PushedState PushOpacityMask(IBrush mask, Rect bounds) public PushedState PushOpacityMask(IBrush mask, Rect bounds)
{ {
@ -216,15 +219,24 @@ namespace Avalonia.Media
} }
/// <summary> /// <summary>
/// Pushes a matrix transformation. /// Pushes a matrix post-transformation.
/// </summary> /// </summary>
/// <param name="matrix">The matrix</param> /// <param name="matrix">The matrix</param>
/// <returns>A disposable used to undo the transformation.</returns> /// <returns>A disposable used to undo the transformation.</returns>
public PushedState PushPostTransform(Matrix matrix) => PushSetTransform(CurrentTransform*matrix); public PushedState PushPostTransform(Matrix matrix) => PushSetTransform(CurrentTransform*matrix);
/// <summary>
/// Pushes a matrix pre-transformation.
/// </summary>
/// <param name="matrix">The matrix</param>
/// <returns>A disposable used to undo the transformation.</returns>
public PushedState PushPreTransform(Matrix matrix) => PushSetTransform(matrix*CurrentTransform); public PushedState PushPreTransform(Matrix matrix) => PushSetTransform(matrix*CurrentTransform);
/// <summary>
/// Sets the current matrix transformation.
/// </summary>
/// <param name="matrix">The matrix</param>
/// <returns>A disposable used to undo the transformation.</returns>
PushedState PushSetTransform(Matrix matrix) PushedState PushSetTransform(Matrix matrix)
{ {
var oldMatrix = CurrentTransform; var oldMatrix = CurrentTransform;
@ -233,7 +245,10 @@ namespace Avalonia.Media
return new PushedState(this, PushedState.PushedStateType.Matrix, oldMatrix); return new PushedState(this, PushedState.PushedStateType.Matrix, oldMatrix);
} }
/// <summary>
/// Pushes a new transform context.
/// </summary>
/// <returns>A disposable used to undo the transformation.</returns>
public PushedState PushTransformContainer() public PushedState PushTransformContainer()
{ {
_transformContainers.Push(new TransformContainer(CurrentTransform, _currentContainerTransform)); _transformContainers.Push(new TransformContainer(CurrentTransform, _currentContainerTransform));
@ -242,6 +257,9 @@ namespace Avalonia.Media
return new PushedState(this, PushedState.PushedStateType.MatrixContainer); return new PushedState(this, PushedState.PushedStateType.MatrixContainer);
} }
/// <summary>
/// Disposes of any resources held by the <see cref="DrawingContext"/>.
/// </summary>
public void Dispose() public void Dispose()
{ {
while (_states.Count != 0) while (_states.Count != 0)

11
src/Avalonia.SceneGraph/Media/FormattedText.cs

@ -33,7 +33,16 @@ namespace Avalonia.Media
{ {
Contract.Requires<ArgumentNullException>(text != null); Contract.Requires<ArgumentNullException>(text != null);
Contract.Requires<ArgumentNullException>(fontFamilyName != null); Contract.Requires<ArgumentNullException>(fontFamilyName != null);
Contract.Requires<ArgumentException>(fontSize > 0);
if (fontSize <= 0)
{
throw new ArgumentException("FontSize must be greater than 0");
}
if (fontWeight <= 0)
{
throw new ArgumentException("FontWeight must be greater than 0");
}
Text = text; Text = text;
FontFamilyName = fontFamilyName; FontFamilyName = fontFamilyName;

1
src/Avalonia.SceneGraph/Media/Imaging/RenderTargetBitmap.cs

@ -4,6 +4,7 @@
using System; using System;
using Avalonia.Platform; using Avalonia.Platform;
using Avalonia.Rendering; using Avalonia.Rendering;
using Avalonia.VisualTree;
namespace Avalonia.Media.Imaging namespace Avalonia.Media.Imaging
{ {

1
src/Avalonia.SceneGraph/Media/MatrixTransform.cs

@ -2,6 +2,7 @@
// Licensed under the MIT license. See licence.md file in the project root for full license information. // Licensed under the MIT license. See licence.md file in the project root for full license information.
using System; using System;
using Avalonia.VisualTree;
namespace Avalonia.Media namespace Avalonia.Media
{ {

8
src/Avalonia.SceneGraph/Media/PathMarkupParser.cs

@ -32,18 +32,14 @@ namespace Avalonia.Media
{'1', FillRule.NonZero } {'1', FillRule.NonZero }
}; };
private StreamGeometry _geometry;
private readonly StreamGeometryContext _context; private readonly StreamGeometryContext _context;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="PathMarkupParser"/> class. /// Initializes a new instance of the <see cref="PathMarkupParser"/> class.
/// </summary> /// </summary>
/// <param name="geometry">The geometry in which the path should be stored.</param> /// <param name="context">The context for the geometry.</param>
/// <param name="context">The context for <paramref name="geometry"/>.</param> public PathMarkupParser(StreamGeometryContext context)
public PathMarkupParser(StreamGeometry geometry, StreamGeometryContext context)
{ {
_geometry = geometry;
_context = context; _context = context;
} }

1
src/Avalonia.SceneGraph/Media/RotateTransform.cs

@ -2,6 +2,7 @@
// Licensed under the MIT license. See licence.md file in the project root for full license information. // Licensed under the MIT license. See licence.md file in the project root for full license information.
using System; using System;
using Avalonia.VisualTree;
namespace Avalonia.Media namespace Avalonia.Media
{ {

1
src/Avalonia.SceneGraph/Media/ScaleTransform.cs

@ -2,6 +2,7 @@
// Licensed under the MIT license. See licence.md file in the project root for full license information. // Licensed under the MIT license. See licence.md file in the project root for full license information.
using System; using System;
using Avalonia.VisualTree;
namespace Avalonia.Media namespace Avalonia.Media
{ {

2
src/Avalonia.SceneGraph/Media/StreamGeometry.cs

@ -39,7 +39,7 @@ namespace Avalonia.Media
using (StreamGeometryContext ctx = result.Open()) using (StreamGeometryContext ctx = result.Open())
{ {
PathMarkupParser parser = new PathMarkupParser(result, ctx); PathMarkupParser parser = new PathMarkupParser(ctx);
parser.Parse(s); parser.Parse(s);
return result; return result;
} }

1
src/Avalonia.SceneGraph/Media/Transform.cs

@ -3,6 +3,7 @@
using System; using System;
using Avalonia.Animation; using Avalonia.Animation;
using Avalonia.VisualTree;
namespace Avalonia.Media namespace Avalonia.Media
{ {

1
src/Avalonia.SceneGraph/Media/TranslateTransform.cs

@ -2,6 +2,7 @@
// Licensed under the MIT license. See licence.md file in the project root for full license information. // Licensed under the MIT license. See licence.md file in the project root for full license information.
using System; using System;
using Avalonia.VisualTree;
namespace Avalonia.Media namespace Avalonia.Media
{ {

1
src/Avalonia.Styling/Avalonia.Styling.csproj

@ -38,6 +38,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Avalonia.Styling.XML</DocumentationFile> <DocumentationFile>bin\Release\Avalonia.Styling.XML</DocumentationFile>
<NoWarn>CS1591</NoWarn> <NoWarn>CS1591</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="..\Shared\SharedAssemblyInfo.cs"> <Compile Include="..\Shared\SharedAssemblyInfo.cs">

6
src/Avalonia.Styling/Styling/SelectorMatch.cs

@ -6,12 +6,12 @@ using System;
namespace Avalonia.Styling namespace Avalonia.Styling
{ {
/// <summary> /// <summary>
/// Holds the result of a <see cref="FuncSelector"/> match. /// Holds the result of a <see cref="Selector"/> match.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// There are two types of selectors - ones whose match can never change for a particular /// There are two types of selectors - ones whose match can never change for a particular
/// control (such as <see cref="Selectors.OfType{T}(FuncSelector)"/>) and ones whose result can /// control (such as <see cref="Selectors.OfType(Selector, Type)"/>) and ones whose result can
/// change over time (such as <see cref="Selectors.Class(FuncSelector, string)"/>. For the first /// change over time (such as <see cref="Selectors.Class(Selector, string)"/>. For the first
/// category of selectors, the value of <see cref="ImmediateResult"/> will be set but for the /// category of selectors, the value of <see cref="ImmediateResult"/> will be set but for the
/// second, <see cref="ImmediateResult"/> will be null and <see cref="ObservableResult"/> will /// second, <see cref="ImmediateResult"/> will be null and <see cref="ObservableResult"/> will
/// hold an observable which tracks the match. /// hold an observable which tracks the match.

1
src/Avalonia.Styling/Styling/Style.cs

@ -82,7 +82,6 @@ namespace Avalonia.Styling
{ {
if (Selector != null) if (Selector != null)
{ {
var description = "Style " + Selector.ToString();
var match = Selector.Match(control); var match = Selector.Match(control);
if (match.ImmediateResult != false) if (match.ImmediateResult != false)

1
src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj

@ -36,6 +36,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Avalonia.Themes.Default.XML</DocumentationFile> <DocumentationFile>bin\Release\Avalonia.Themes.Default.XML</DocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included --> <!-- A reference to the entire .NET Framework is automatically included -->

2
src/Gtk/Avalonia.Gtk/EmbeddableImpl.cs

@ -14,7 +14,9 @@ namespace Avalonia.Gtk
{ {
class EmbeddableImpl : WindowImplBase, IEmbeddableWindowImpl class EmbeddableImpl : WindowImplBase, IEmbeddableWindowImpl
{ {
#pragma warning disable CS0067 // Method not used
public event Action LostFocus; public event Action LostFocus;
#pragma warning restore CS0067
public EmbeddableImpl(DrawingArea area) : base(area) public EmbeddableImpl(DrawingArea area) : base(area)
{ {

4
src/Gtk/Avalonia.Gtk/WindowImplBase.cs

@ -134,7 +134,7 @@ namespace Avalonia.Gtk
public void Invalidate(Rect rect) public void Invalidate(Rect rect)
{ {
if (_window.GdkWindow != null) if (_window?.GdkWindow != null)
_window.GdkWindow.InvalidateRect( _window.GdkWindow.InvalidateRect(
new Rectangle((int) rect.X, (int) rect.Y, (int) rect.Width, (int) rect.Height), true); new Rectangle((int) rect.X, (int) rect.Y, (int) rect.Width, (int) rect.Height), true);
} }
@ -306,7 +306,9 @@ namespace Avalonia.Gtk
public void Dispose() public void Dispose()
{ {
_window.Hide();
_window.Dispose(); _window.Dispose();
_window = null;
} }
} }
} }

12
src/Markup/Avalonia.Markup.Xaml/AvaloniaXamlLoader.cs

@ -8,14 +8,14 @@ using System.Reflection;
using System.Text; using System.Text;
using OmniXaml; using OmniXaml;
using Avalonia.Platform; using Avalonia.Platform;
using Avalonia.Markup.Xaml.Context;
using Avalonia.Markup.Xaml.Styling;
using OmniXaml.ObjectAssembler;
using Avalonia.Controls;
using Avalonia.Markup.Xaml.Data;
namespace Avalonia.Markup.Xaml namespace Avalonia.Markup.Xaml
{ {
using Context;
using Controls;
using Data;
using OmniXaml.ObjectAssembler;
using System.Linq;
/// <summary> /// <summary>
/// Loads XAML for a avalonia application. /// Loads XAML for a avalonia application.
/// </summary> /// </summary>
@ -47,7 +47,7 @@ namespace Avalonia.Markup.Xaml
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// TODO: Making this internal for now as I'm not sure that this is the correct /// TODO: Making this internal for now as I'm not sure that this is the correct
/// thing to do, but its needd by <see cref="StyleInclude"/> to get the URL of /// thing to do, but its needed by <see cref="StyleInclude"/> to get the URL of
/// the currently loading XAML file, as we can't use the OmniXAML parsing context /// the currently loading XAML file, as we can't use the OmniXAML parsing context
/// there. Maybe we need a way to inject OmniXAML context into the objects its /// there. Maybe we need a way to inject OmniXAML context into the objects its
/// constructing? /// constructing?

1
src/Markup/Avalonia.Markup/Avalonia.Markup.csproj

@ -36,6 +36,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Avalonia.Markup.XML</DocumentationFile> <DocumentationFile>bin\Release\Avalonia.Markup.XML</DocumentationFile>
<NoWarn>CS1591</NoWarn> <NoWarn>CS1591</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="..\..\Shared\SharedAssemblyInfo.cs"> <Compile Include="..\..\Shared\SharedAssemblyInfo.cs">

12
src/Shared/PlatformSupport/AssetLoader.cs

@ -20,6 +20,12 @@ namespace Avalonia.Shared.PlatformSupport
private AssemblyDescriptor _defaultAssembly; private AssemblyDescriptor _defaultAssembly;
/// <summary>
/// Initializes a new instance of the <see cref="AssetLoader"/> class.
/// </summary>
/// <param name="assembly">
/// The default assembly from which to load assets for which no assembly is specified.
/// </param>
public AssetLoader(Assembly assembly = null) public AssetLoader(Assembly assembly = null)
{ {
if (assembly == null) if (assembly == null)
@ -28,6 +34,10 @@ namespace Avalonia.Shared.PlatformSupport
_defaultAssembly = new AssemblyDescriptor(assembly); _defaultAssembly = new AssemblyDescriptor(assembly);
} }
/// <summary>
/// Sets the default assembly from which to load assets for which no assembly is specified.
/// </summary>
/// <param name="assembly">The default assembly.</param>
public void SetDefaultAssembly(Assembly assembly) public void SetDefaultAssembly(Assembly assembly)
{ {
_defaultAssembly = new AssemblyDescriptor(assembly); _defaultAssembly = new AssemblyDescriptor(assembly);
@ -73,8 +83,6 @@ namespace Avalonia.Shared.PlatformSupport
{ {
if (!uri.IsAbsoluteUri || uri.Scheme == "resm") if (!uri.IsAbsoluteUri || uri.Scheme == "resm")
{ {
var uriQueryParams = ParseQueryString(uri);
var baseUriQueryParams = uri != null ? ParseQueryString(uri) : null;
var asm = GetAssembly(uri) ?? GetAssembly(baseUri) ?? _defaultAssembly; var asm = GetAssembly(uri) ?? GetAssembly(baseUri) ?? _defaultAssembly;
if (asm == null && _defaultAssembly == null) if (asm == null && _defaultAssembly == null)

1
src/Windows/Avalonia.Direct2D1/Avalonia.Direct2D1.csproj

@ -34,6 +34,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Avalonia.Direct2D1.XML</DocumentationFile> <DocumentationFile>bin\Release\Avalonia.Direct2D1.XML</DocumentationFile>
<NoWarn>CS1591</NoWarn> <NoWarn>CS1591</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="SharpDX, Version=3.0.2.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL"> <Reference Include="SharpDX, Version=3.0.2.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">

4
src/Windows/Avalonia.Direct2D1/Media/StreamGeometryImpl.cs

@ -8,7 +8,7 @@ using D2DGeometry = SharpDX.Direct2D1.Geometry;
namespace Avalonia.Direct2D1.Media namespace Avalonia.Direct2D1.Media
{ {
/// <summary> /// <summary>
/// A Direct2D implementation of a <see cref="StreamGeometry"/>. /// A Direct2D implementation of a <see cref="Avalonia.Media.StreamGeometry"/>.
/// </summary> /// </summary>
public class StreamGeometryImpl : GeometryImpl, IStreamGeometryImpl public class StreamGeometryImpl : GeometryImpl, IStreamGeometryImpl
{ {
@ -56,7 +56,7 @@ namespace Avalonia.Direct2D1.Media
/// Opens the geometry to start defining it. /// Opens the geometry to start defining it.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// A <see cref="StreamGeometryContext"/> which can be used to define the geometry. /// An <see cref="Avalonia.Platform.IStreamGeometryContextImpl"/> which can be used to define the geometry.
/// </returns> /// </returns>
public IStreamGeometryContextImpl Open() public IStreamGeometryContextImpl Open()
{ {

1
src/Windows/Avalonia.Win32/Avalonia.Win32.csproj

@ -36,6 +36,7 @@
<DocumentationFile>bin\Release\Avalonia.Win32.XML</DocumentationFile> <DocumentationFile>bin\Release\Avalonia.Win32.XML</DocumentationFile>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<NoWarn>CS1591</NoWarn> <NoWarn>CS1591</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />

3
tests/Avalonia.Base.UnitTests/AvaloniaObjectTests_Direct.cs

@ -337,7 +337,6 @@ namespace Avalonia.Base.UnitTests
[Fact] [Fact]
public void Property_Notifies_Initialized() public void Property_Notifies_Initialized()
{ {
Class1 target;
bool raised = false; bool raised = false;
Class1.FooProperty.Initialized.Subscribe(e => Class1.FooProperty.Initialized.Subscribe(e =>
@ -346,7 +345,7 @@ namespace Avalonia.Base.UnitTests
(string)e.NewValue == "initial" && (string)e.NewValue == "initial" &&
e.Priority == BindingPriority.Unset); e.Priority == BindingPriority.Unset);
target = new Class1(); var target = new Class1();
Assert.True(raised); Assert.True(raised);
} }

2
tests/Avalonia.Controls.UnitTests/Primitives/TabStripTests.cs

@ -19,8 +19,10 @@ namespace Avalonia.Controls.UnitTests.Primitives
{ {
var items = new[] var items = new[]
{ {
#pragma warning disable CS0252 // Possible unintended reference comparison; left hand side needs cast
Mock.Of<IHeadered>(x => x.Header == "foo"), Mock.Of<IHeadered>(x => x.Header == "foo"),
Mock.Of<IHeadered>(x => x.Header == "bar"), Mock.Of<IHeadered>(x => x.Header == "bar"),
#pragma warning restore CS0252 // Possible unintended reference comparison; left hand side needs cast
}; };
var target = new TabStrip var target = new TabStrip

98
tests/Avalonia.Input.UnitTests/KeyboardNavigationTests_Arrows.cs

@ -13,7 +13,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Down_Continue_Returns_Down_Control_In_Container() public void Down_Continue_Returns_Down_Control_In_Container()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -21,7 +20,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue,
Children = new Controls Children = new Controls
@ -30,7 +29,7 @@ namespace Avalonia.Input.UnitTests
(current = new Button { Name = "Button2" }), (current = new Button { Name = "Button2" }),
(next = new Button { Name = "Button3" }), (next = new Button { Name = "Button3" }),
} }
}), },
new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue,
@ -52,7 +51,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Down_Continue_Returns_First_Control_In_Down_Sibling_Container() public void Down_Continue_Returns_First_Control_In_Down_Sibling_Container()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -60,7 +58,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue,
Children = new Controls Children = new Controls
@ -69,7 +67,7 @@ namespace Avalonia.Input.UnitTests
new Button { Name = "Button2" }, new Button { Name = "Button2" },
(current = new Button { Name = "Button3" }), (current = new Button { Name = "Button3" }),
} }
}), },
new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue,
@ -91,7 +89,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Down_Continue_Returns_Down_Sibling() public void Down_Continue_Returns_Down_Sibling()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -99,7 +96,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue,
Children = new Controls Children = new Controls
@ -108,7 +105,7 @@ namespace Avalonia.Input.UnitTests
new Button { Name = "Button2" }, new Button { Name = "Button2" },
(current = new Button { Name = "Button3" }), (current = new Button { Name = "Button3" }),
} }
}), },
(next = new Button { Name = "Button4" }), (next = new Button { Name = "Button4" }),
} }
}; };
@ -121,7 +118,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Down_Continue_Returns_First_Control_In_Down_Uncle_Container() public void Down_Continue_Returns_First_Control_In_Down_Uncle_Container()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -133,7 +129,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue,
Children = new Controls Children = new Controls
@ -142,7 +138,7 @@ namespace Avalonia.Input.UnitTests
new Button { Name = "Button2" }, new Button { Name = "Button2" },
(current = new Button { Name = "Button3" }), (current = new Button { Name = "Button3" }),
} }
}), },
}, },
}, },
new StackPanel new StackPanel
@ -185,7 +181,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Down_Continue_Wraps() public void Down_Continue_Wraps()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -199,7 +194,7 @@ namespace Avalonia.Input.UnitTests
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue,
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue,
Children = new Controls Children = new Controls
@ -208,7 +203,7 @@ namespace Avalonia.Input.UnitTests
new Button { Name = "Button2" }, new Button { Name = "Button2" },
new Button { Name = "Button3" }, new Button { Name = "Button3" },
} }
}), },
}, },
}, },
new StackPanel new StackPanel
@ -232,7 +227,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Down_Cycle_Returns_Down_Control_In_Container() public void Down_Cycle_Returns_Down_Control_In_Container()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -240,7 +234,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Cycle, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Cycle,
Children = new Controls Children = new Controls
@ -249,7 +243,7 @@ namespace Avalonia.Input.UnitTests
(current = new Button { Name = "Button2" }), (current = new Button { Name = "Button2" }),
(next = new Button { Name = "Button3" }), (next = new Button { Name = "Button3" }),
} }
}), },
new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
@ -270,7 +264,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Down_Cycle_Wraps_To_First() public void Down_Cycle_Wraps_To_First()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -278,7 +271,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Cycle, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Cycle,
Children = new Controls Children = new Controls
@ -287,7 +280,7 @@ namespace Avalonia.Input.UnitTests
new Button { Name = "Button2" }, new Button { Name = "Button2" },
(current = new Button { Name = "Button3" }), (current = new Button { Name = "Button3" }),
} }
}), },
new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
@ -308,7 +301,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Down_Contained_Returns_Down_Control_In_Container() public void Down_Contained_Returns_Down_Control_In_Container()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -316,7 +308,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Contained, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Contained,
Children = new Controls Children = new Controls
@ -325,7 +317,7 @@ namespace Avalonia.Input.UnitTests
(current = new Button { Name = "Button2" }), (current = new Button { Name = "Button2" }),
(next = new Button { Name = "Button3" }), (next = new Button { Name = "Button3" }),
} }
}), },
new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Contained, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Contained,
@ -347,24 +339,22 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Down_Contained_Stops_At_End() public void Down_Contained_Stops_At_End()
{ {
StackPanel container;
Button current; Button current;
Button next;
var top = new StackPanel var top = new StackPanel
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Contained, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Contained,
Children = new Controls Children = new Controls
{ {
(next = new Button { Name = "Button1" }), new Button { Name = "Button1" },
new Button { Name = "Button2" }, new Button { Name = "Button2" },
(current = new Button { Name = "Button3" }), (current = new Button { Name = "Button3" }),
} }
}), },
new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Contained, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Contained,
@ -386,14 +376,13 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Down_None_Does_Nothing() public void Down_None_Does_Nothing()
{ {
StackPanel container;
Button current; Button current;
var top = new StackPanel var top = new StackPanel
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.None, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.None,
Children = new Controls Children = new Controls
@ -402,7 +391,7 @@ namespace Avalonia.Input.UnitTests
(current = new Button { Name = "Button2" }), (current = new Button { Name = "Button2" }),
new Button { Name = "Button3" }, new Button { Name = "Button3" },
} }
}), },
new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Contained, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Contained,
@ -424,7 +413,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Up_Continue_Returns_Up_Control_In_Container() public void Up_Continue_Returns_Up_Control_In_Container()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -432,7 +420,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue,
Children = new Controls Children = new Controls
@ -441,7 +429,7 @@ namespace Avalonia.Input.UnitTests
(next = new Button { Name = "Button2" }), (next = new Button { Name = "Button2" }),
(current = new Button { Name = "Button3" }), (current = new Button { Name = "Button3" }),
} }
}), },
new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Contained, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Contained,
@ -463,7 +451,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Up_Continue_Returns_Last_Control_In_Up_Sibling_Container() public void Up_Continue_Returns_Last_Control_In_Up_Sibling_Container()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -471,7 +458,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue,
Children = new Controls Children = new Controls
@ -480,7 +467,7 @@ namespace Avalonia.Input.UnitTests
new Button { Name = "Button2" }, new Button { Name = "Button2" },
(next = new Button { Name = "Button3" }), (next = new Button { Name = "Button3" }),
} }
}), },
new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue,
@ -502,7 +489,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Up_Continue_Returns_Last_Child_Of_Sibling() public void Up_Continue_Returns_Last_Child_Of_Sibling()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -511,7 +497,7 @@ namespace Avalonia.Input.UnitTests
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue,
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue,
Children = new Controls Children = new Controls
@ -520,7 +506,7 @@ namespace Avalonia.Input.UnitTests
new Button { Name = "Button2" }, new Button { Name = "Button2" },
(next = new Button { Name = "Button3" }), (next = new Button { Name = "Button3" }),
} }
}), },
(current = new Button { Name = "Button4" }), (current = new Button { Name = "Button4" }),
} }
}; };
@ -533,7 +519,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Up_Continue_Returns_Last_Control_In_Up_Nephew_Container() public void Up_Continue_Returns_Last_Control_In_Up_Nephew_Container()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -545,7 +530,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue,
Children = new Controls Children = new Controls
@ -554,7 +539,7 @@ namespace Avalonia.Input.UnitTests
new Button { Name = "Button2" }, new Button { Name = "Button2" },
(next = new Button { Name = "Button3" }), (next = new Button { Name = "Button3" }),
} }
}), },
}, },
}, },
new StackPanel new StackPanel
@ -578,7 +563,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Up_Continue_Wraps() public void Up_Continue_Wraps()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -590,7 +574,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue,
Children = new Controls Children = new Controls
@ -599,7 +583,7 @@ namespace Avalonia.Input.UnitTests
new Button { Name = "Button2" }, new Button { Name = "Button2" },
new Button { Name = "Button3" }, new Button { Name = "Button3" },
} }
}), },
}, },
}, },
new StackPanel new StackPanel
@ -643,7 +627,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Up_Cycle_Returns_Up_Control_In_Container() public void Up_Cycle_Returns_Up_Control_In_Container()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -651,7 +634,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Cycle, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Cycle,
Children = new Controls Children = new Controls
@ -660,7 +643,7 @@ namespace Avalonia.Input.UnitTests
(current = new Button { Name = "Button2" }), (current = new Button { Name = "Button2" }),
new Button { Name = "Button3" }, new Button { Name = "Button3" },
} }
}), },
new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Cycle, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Cycle,
@ -682,7 +665,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Up_Cycle_Wraps_To_Last() public void Up_Cycle_Wraps_To_Last()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -690,7 +672,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Cycle, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Cycle,
Children = new Controls Children = new Controls
@ -699,7 +681,7 @@ namespace Avalonia.Input.UnitTests
new Button { Name = "Button2" }, new Button { Name = "Button2" },
(next = new Button { Name = "Button3" }), (next = new Button { Name = "Button3" }),
} }
}), },
new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Cycle, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Cycle,
@ -721,7 +703,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Up_Contained_Returns_Up_Control_In_Container() public void Up_Contained_Returns_Up_Control_In_Container()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -729,7 +710,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Contained, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Contained,
Children = new Controls Children = new Controls
@ -738,7 +719,7 @@ namespace Avalonia.Input.UnitTests
(current = new Button { Name = "Button2" }), (current = new Button { Name = "Button2" }),
new Button { Name = "Button3" }, new Button { Name = "Button3" },
} }
}), },
new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Contained, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Contained,
@ -760,14 +741,13 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Up_Contained_Stops_At_Beginning() public void Up_Contained_Stops_At_Beginning()
{ {
StackPanel container;
Button current; Button current;
var top = new StackPanel var top = new StackPanel
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Contained, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Contained,
Children = new Controls Children = new Controls
@ -776,7 +756,7 @@ namespace Avalonia.Input.UnitTests
new Button { Name = "Button2" }, new Button { Name = "Button2" },
new Button { Name = "Button3" }, new Button { Name = "Button3" },
} }
}), },
new StackPanel new StackPanel
{ {
[KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Contained, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Contained,

121
tests/Avalonia.Input.UnitTests/KeyboardNavigationTests_Tab.cs

@ -13,7 +13,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Next_Continue_Returns_Next_Control_In_Container() public void Next_Continue_Returns_Next_Control_In_Container()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -21,7 +20,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
{ {
@ -29,7 +28,7 @@ namespace Avalonia.Input.UnitTests
(current = new Button { Name = "Button2" }), (current = new Button { Name = "Button2" }),
(next = new Button { Name = "Button3" }), (next = new Button { Name = "Button3" }),
} }
}), },
new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
@ -50,7 +49,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Next_Continue_Returns_First_Control_In_Next_Sibling_Container() public void Next_Continue_Returns_First_Control_In_Next_Sibling_Container()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -58,7 +56,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
{ {
@ -66,7 +64,7 @@ namespace Avalonia.Input.UnitTests
new Button { Name = "Button2" }, new Button { Name = "Button2" },
(current = new Button { Name = "Button3" }), (current = new Button { Name = "Button3" }),
} }
}), },
new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
@ -87,7 +85,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Next_Continue_Doesnt_Enter_Panel_With_TabNavigation_None() public void Next_Continue_Doesnt_Enter_Panel_With_TabNavigation_None()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -95,7 +92,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
{ {
@ -103,7 +100,7 @@ namespace Avalonia.Input.UnitTests
new Button { Name = "Button2" }, new Button { Name = "Button2" },
(current = new Button { Name = "Button3" }), (current = new Button { Name = "Button3" }),
} }
}), },
new StackPanel new StackPanel
{ {
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.None, [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.None,
@ -131,7 +128,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Next_Continue_Returns_Next_Sibling() public void Next_Continue_Returns_Next_Sibling()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -139,7 +135,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
{ {
@ -147,7 +143,7 @@ namespace Avalonia.Input.UnitTests
new Button { Name = "Button2" }, new Button { Name = "Button2" },
(current = new Button { Name = "Button3" }), (current = new Button { Name = "Button3" }),
} }
}), },
(next = new Button { Name = "Button4" }), (next = new Button { Name = "Button4" }),
} }
}; };
@ -160,7 +156,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Next_Continue_Returns_First_Control_In_Next_Uncle_Container() public void Next_Continue_Returns_First_Control_In_Next_Uncle_Container()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -172,7 +167,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
{ {
@ -180,7 +175,7 @@ namespace Avalonia.Input.UnitTests
new Button { Name = "Button2" }, new Button { Name = "Button2" },
(current = new Button { Name = "Button3" }), (current = new Button { Name = "Button3" }),
} }
}), },
}, },
}, },
new StackPanel new StackPanel
@ -221,7 +216,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Next_Continue_Wraps() public void Next_Continue_Wraps()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -233,7 +227,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
{ {
@ -241,7 +235,7 @@ namespace Avalonia.Input.UnitTests
new Button { Name = "Button2" }, new Button { Name = "Button2" },
new Button { Name = "Button3" }, new Button { Name = "Button3" },
} }
}), },
}, },
}, },
new StackPanel new StackPanel
@ -264,7 +258,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Next_Cycle_Returns_Next_Control_In_Container() public void Next_Cycle_Returns_Next_Control_In_Container()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -272,7 +265,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Cycle, [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Cycle,
Children = new Controls Children = new Controls
@ -281,7 +274,7 @@ namespace Avalonia.Input.UnitTests
(current = new Button { Name = "Button2" }), (current = new Button { Name = "Button2" }),
(next = new Button { Name = "Button3" }), (next = new Button { Name = "Button3" }),
} }
}), },
new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
@ -302,7 +295,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Next_Cycle_Wraps_To_First() public void Next_Cycle_Wraps_To_First()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -310,7 +302,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Cycle, [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Cycle,
Children = new Controls Children = new Controls
@ -319,7 +311,7 @@ namespace Avalonia.Input.UnitTests
new Button { Name = "Button2" }, new Button { Name = "Button2" },
(current = new Button { Name = "Button3" }), (current = new Button { Name = "Button3" }),
} }
}), },
new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
@ -340,7 +332,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Next_Contained_Returns_Next_Control_In_Container() public void Next_Contained_Returns_Next_Control_In_Container()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -348,7 +339,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Contained, [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Contained,
Children = new Controls Children = new Controls
@ -357,7 +348,7 @@ namespace Avalonia.Input.UnitTests
(current = new Button { Name = "Button2" }), (current = new Button { Name = "Button2" }),
(next = new Button { Name = "Button3" }), (next = new Button { Name = "Button3" }),
} }
}), },
new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
@ -378,24 +369,22 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Next_Contained_Stops_At_End() public void Next_Contained_Stops_At_End()
{ {
StackPanel container;
Button current; Button current;
Button next;
var top = new StackPanel var top = new StackPanel
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Contained, [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Contained,
Children = new Controls Children = new Controls
{ {
(next = new Button { Name = "Button1" }), new Button { Name = "Button1" },
new Button { Name = "Button2" }, new Button { Name = "Button2" },
(current = new Button { Name = "Button3" }), (current = new Button { Name = "Button3" }),
} }
}), },
new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
@ -416,7 +405,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Next_Once_Moves_To_Next_Container() public void Next_Once_Moves_To_Next_Container()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -424,7 +412,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Once, [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Once,
Children = new Controls Children = new Controls
@ -433,7 +421,7 @@ namespace Avalonia.Input.UnitTests
(current = new Button { Name = "Button2" }), (current = new Button { Name = "Button2" }),
new Button { Name = "Button3" }, new Button { Name = "Button3" },
} }
}), },
new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
@ -494,7 +482,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Next_None_Moves_To_Next_Container() public void Next_None_Moves_To_Next_Container()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -502,7 +489,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.None, [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.None,
Children = new Controls Children = new Controls
@ -511,7 +498,7 @@ namespace Avalonia.Input.UnitTests
(current = new Button { Name = "Button2" }), (current = new Button { Name = "Button2" }),
new Button { Name = "Button3" }, new Button { Name = "Button3" },
} }
}), },
new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
@ -572,7 +559,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Previous_Continue_Returns_Previous_Control_In_Container() public void Previous_Continue_Returns_Previous_Control_In_Container()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -580,7 +566,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
{ {
@ -588,7 +574,7 @@ namespace Avalonia.Input.UnitTests
(next = new Button { Name = "Button2" }), (next = new Button { Name = "Button2" }),
(current = new Button { Name = "Button3" }), (current = new Button { Name = "Button3" }),
} }
}), },
new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
@ -609,7 +595,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Previous_Continue_Returns_Last_Control_In_Previous_Sibling_Container() public void Previous_Continue_Returns_Last_Control_In_Previous_Sibling_Container()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -617,7 +602,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
{ {
@ -625,7 +610,7 @@ namespace Avalonia.Input.UnitTests
new Button { Name = "Button2" }, new Button { Name = "Button2" },
(next = new Button { Name = "Button3" }), (next = new Button { Name = "Button3" }),
} }
}), },
new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
@ -646,7 +631,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Previous_Continue_Returns_Last_Child_Of_Sibling() public void Previous_Continue_Returns_Last_Child_Of_Sibling()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -654,7 +638,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
{ {
@ -662,7 +646,7 @@ namespace Avalonia.Input.UnitTests
new Button { Name = "Button2" }, new Button { Name = "Button2" },
(next = new Button { Name = "Button3" }), (next = new Button { Name = "Button3" }),
} }
}), },
(current = new Button { Name = "Button4" }), (current = new Button { Name = "Button4" }),
} }
}; };
@ -675,7 +659,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Previous_Continue_Returns_Last_Control_In_Previous_Nephew_Container() public void Previous_Continue_Returns_Last_Control_In_Previous_Nephew_Container()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -687,7 +670,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
{ {
@ -695,7 +678,7 @@ namespace Avalonia.Input.UnitTests
new Button { Name = "Button2" }, new Button { Name = "Button2" },
(next = new Button { Name = "Button3" }), (next = new Button { Name = "Button3" }),
} }
}), },
}, },
}, },
new StackPanel new StackPanel
@ -718,7 +701,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Previous_Continue_Wraps() public void Previous_Continue_Wraps()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -730,7 +712,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
{ {
@ -738,7 +720,7 @@ namespace Avalonia.Input.UnitTests
new Button { Name = "Button2" }, new Button { Name = "Button2" },
new Button { Name = "Button3" }, new Button { Name = "Button3" },
} }
}), },
}, },
}, },
new StackPanel new StackPanel
@ -780,7 +762,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Previous_Cycle_Returns_Previous_Control_In_Container() public void Previous_Cycle_Returns_Previous_Control_In_Container()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -788,7 +769,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Cycle, [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Cycle,
Children = new Controls Children = new Controls
@ -797,7 +778,7 @@ namespace Avalonia.Input.UnitTests
(current = new Button { Name = "Button2" }), (current = new Button { Name = "Button2" }),
new Button { Name = "Button3" }, new Button { Name = "Button3" },
} }
}), },
new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
@ -818,7 +799,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Previous_Cycle_Wraps_To_Last() public void Previous_Cycle_Wraps_To_Last()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -826,7 +806,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Cycle, [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Cycle,
Children = new Controls Children = new Controls
@ -835,7 +815,7 @@ namespace Avalonia.Input.UnitTests
new Button { Name = "Button2" }, new Button { Name = "Button2" },
(next = new Button { Name = "Button3" }), (next = new Button { Name = "Button3" }),
} }
}), },
new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
@ -856,7 +836,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Previous_Contained_Returns_Previous_Control_In_Container() public void Previous_Contained_Returns_Previous_Control_In_Container()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -864,7 +843,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Contained, [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Contained,
Children = new Controls Children = new Controls
@ -873,7 +852,7 @@ namespace Avalonia.Input.UnitTests
(current = new Button { Name = "Button2" }), (current = new Button { Name = "Button2" }),
new Button { Name = "Button3" }, new Button { Name = "Button3" },
} }
}), },
new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
@ -894,24 +873,22 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Previous_Contained_Stops_At_Beginning() public void Previous_Contained_Stops_At_Beginning()
{ {
StackPanel container;
Button current; Button current;
Button next;
var top = new StackPanel var top = new StackPanel
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Contained, [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Contained,
Children = new Controls Children = new Controls
{ {
(current = new Button { Name = "Button1" }), (current = new Button { Name = "Button1" }),
new Button { Name = "Button2" }, new Button { Name = "Button2" },
(next = new Button { Name = "Button3" }), new Button { Name = "Button3" },
} }
}), },
new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
@ -932,7 +909,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Previous_Once_Moves_To_Previous_Container() public void Previous_Once_Moves_To_Previous_Container()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -940,7 +916,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls
{ {
@ -948,7 +924,7 @@ namespace Avalonia.Input.UnitTests
new Button { Name = "Button2" }, new Button { Name = "Button2" },
(next = new Button { Name = "Button3" }), (next = new Button { Name = "Button3" }),
} }
}), },
new StackPanel new StackPanel
{ {
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Once, [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Once,
@ -1010,7 +986,6 @@ namespace Avalonia.Input.UnitTests
[Fact] [Fact]
public void Previous_Once_Moves_To_First_Element() public void Previous_Once_Moves_To_First_Element()
{ {
StackPanel container;
Button current; Button current;
Button next; Button next;
@ -1018,7 +993,7 @@ namespace Avalonia.Input.UnitTests
{ {
Children = new Controls Children = new Controls
{ {
(container = new StackPanel new StackPanel
{ {
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Once, [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Once,
Children = new Controls Children = new Controls
@ -1027,7 +1002,7 @@ namespace Avalonia.Input.UnitTests
new Button { Name = "Button2" }, new Button { Name = "Button2" },
new Button { Name = "Button3" }, new Button { Name = "Button3" },
} }
}), },
new StackPanel new StackPanel
{ {
Children = new Controls Children = new Controls

4
tests/Avalonia.Interactivity.UnitTests/Properties/AssemblyInfo.cs

@ -2,5 +2,9 @@
// Licensed under the MIT license. See licence.md file in the project root for full license information. // Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Reflection; using System.Reflection;
using Xunit;
[assembly: AssemblyTitle("Avalonia.Interactive.UnitTests")] [assembly: AssemblyTitle("Avalonia.Interactive.UnitTests")]
// Don't run tests in parallel.
[assembly: CollectionBehavior(DisableTestParallelization = true)]

2
tests/Avalonia.Markup.UnitTests/Data/BindingExpressionTests.cs

@ -14,7 +14,7 @@ using Xunit;
namespace Avalonia.Markup.UnitTests.Data namespace Avalonia.Markup.UnitTests.Data
{ {
public class BindingExpressionTests public class BindingExpressionTests : IClassFixture<InvariantCultureFixture>
{ {
[Fact] [Fact]
public async void Should_Get_Simple_Property_Value() public async void Should_Get_Simple_Property_Value()

2
tests/Avalonia.Markup.UnitTests/Data/ExpressionObserverTests_DataValidation.cs

@ -13,7 +13,7 @@ using Xunit;
namespace Avalonia.Markup.UnitTests.Data namespace Avalonia.Markup.UnitTests.Data
{ {
public class ExpressionObserverTests_DataValidation public class ExpressionObserverTests_DataValidation : IClassFixture<InvariantCultureFixture>
{ {
[Fact] [Fact]
public void Doesnt_Send_DataValidationError_When_DataValidatation_Not_Enabled() public void Doesnt_Send_DataValidationError_When_DataValidatation_Not_Enabled()

3
tests/Avalonia.Markup.UnitTests/Data/Plugins/DataAnnotationsValidationPluginTests.cs

@ -6,11 +6,12 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Avalonia.Data; using Avalonia.Data;
using Avalonia.Markup.Data.Plugins; using Avalonia.Markup.Data.Plugins;
using Avalonia.UnitTests;
using Xunit; using Xunit;
namespace Avalonia.Markup.UnitTests.Data.Plugins namespace Avalonia.Markup.UnitTests.Data.Plugins
{ {
public class DataAnnotationsValidationPluginTests public class DataAnnotationsValidationPluginTests : IClassFixture<InvariantCultureFixture>
{ {
[Fact] [Fact]
public void Should_Match_Property_With_ValidatorAttribute() public void Should_Match_Property_With_ValidatorAttribute()

1
tests/Avalonia.SceneGraph.UnitTests/Avalonia.SceneGraph.UnitTests.csproj

@ -77,6 +77,7 @@
<Otherwise /> <Otherwise />
</Choose> </Choose>
<ItemGroup> <ItemGroup>
<Compile Include="Media\FormattedTextTests.cs" />
<Compile Include="Media\PathMarkupParserTests.cs" /> <Compile Include="Media\PathMarkupParserTests.cs" />
<Compile Include="RelativeRectComparer.cs" /> <Compile Include="RelativeRectComparer.cs" />
<Compile Include="RelativeRectTests.cs" /> <Compile Include="RelativeRectTests.cs" />

28
tests/Avalonia.SceneGraph.UnitTests/Media/FormattedTextTests.cs

@ -0,0 +1,28 @@
using System;
using Avalonia.Media;
using Xunit;
namespace Avalonia.SceneGraph.UnitTests.Media
{
public class FormattedTextTests
{
[Fact]
public void Exception_Should_Be_Thrown_If_FontSize_0()
{
Assert.Throws<ArgumentException>(() => new FormattedText(
"foo",
"Ariel",
0));
}
[Fact]
public void Exception_Should_Be_Thrown_If_FontWeight_0()
{
Assert.Throws<ArgumentException>(() => new FormattedText(
"foo",
"Ariel",
12,
fontWeight: 0));
}
}
}

1
tests/Avalonia.SceneGraph.UnitTests/Media/PathMarkupParserTests.cs

@ -92,7 +92,6 @@ namespace Avalonia.SceneGraph.UnitTests.Media
.ToConstant(Mock.Of<IPlatformRenderInterface>()); .ToConstant(Mock.Of<IPlatformRenderInterface>());
return new PathMarkupParser( return new PathMarkupParser(
new StreamGeometry(),
new StreamGeometryContext(implMock != null ? implMock.Object : Mock.Of<IStreamGeometryContextImpl>())); new StreamGeometryContext(implMock != null ? implMock.Object : Mock.Of<IStreamGeometryContextImpl>()));
} }
} }

2
tests/Avalonia.Styling.UnitTests/TestControlBase.cs

@ -17,7 +17,9 @@ namespace Avalonia.Styling.UnitTests
SubscribeCheckObservable = new TestObservable(); SubscribeCheckObservable = new TestObservable();
} }
#pragma warning disable CS0067 // Event not used
public event EventHandler<AvaloniaPropertyChangedEventArgs> PropertyChanged; public event EventHandler<AvaloniaPropertyChangedEventArgs> PropertyChanged;
#pragma warning restore CS0067
public string Name { get; set; } public string Name { get; set; }

1
tests/Avalonia.UnitTests/Avalonia.UnitTests.csproj

@ -54,6 +54,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="InvariantCultureFixture.cs" />
<Compile Include="NotifyingBase.cs" /> <Compile Include="NotifyingBase.cs" />
<Compile Include="TestLogSink.cs" /> <Compile Include="TestLogSink.cs" />
<Compile Include="TestTemplatedRoot.cs" /> <Compile Include="TestTemplatedRoot.cs" />

33
tests/Avalonia.UnitTests/InvariantCultureFixture.cs

@ -0,0 +1,33 @@
// Copyright (c) The Avalonia Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Globalization;
using System.Threading;
namespace Avalonia.UnitTests
{
/// <summary>
/// Runs tests in the invariant culture.
/// </summary>
/// <remarks>
/// Some tests check exception messages, and those from the .NET framework will be translated.
/// Use this fixture to set the current culture to the invariant culture.
/// </remarks>
public class InvariantCultureFixture : IDisposable
{
private CultureInfo _restore;
public InvariantCultureFixture()
{
_restore = Thread.CurrentThread.CurrentUICulture;
Thread.CurrentThread.CurrentUICulture =
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
}
public void Dispose()
{
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture = _restore;
}
}
}
Loading…
Cancel
Save