From 2f07f66740c2979ba0192b61bcf596ac54a082d6 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Wed, 9 Jan 2019 22:25:09 +0100 Subject: [PATCH 1/9] Avalonia.sln updated by VS. Every time VS opens the solution it makes this change. --- Avalonia.sln | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/Avalonia.sln b/Avalonia.sln index 3ed931933a..cf440972b2 100644 --- a/Avalonia.sln +++ b/Avalonia.sln @@ -1,4 +1,5 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 + +Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.27130.2027 MinimumVisualStudioVersion = 10.0.40219.1 @@ -130,6 +131,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Props", "Props", "{F3AC8BC1 ProjectSection(SolutionItems) = preProject build\Base.props = build\Base.props build\Binding.props = build\Binding.props + build\BuildTargets.targets = build\BuildTargets.targets build\JetBrains.Annotations.props = build\JetBrains.Annotations.props build\JetBrains.dotMemoryUnit.props = build\JetBrains.dotMemoryUnit.props build\Magick.NET-Q16-AnyCPU.props = build\Magick.NET-Q16-AnyCPU.props @@ -147,7 +149,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Props", "Props", "{F3AC8BC1 build\Splat.props = build\Splat.props build\System.Memory.props = build\System.Memory.props build\XUnit.props = build\XUnit.props - build\BuildTargets.targets = build\BuildTargets.targets EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Targets", "Targets", "{4D6FAF79-58B4-482F-9122-0668C346364C}" @@ -189,11 +190,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia", "packages\Avalon EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Desktop", "src\Avalonia.Desktop\Avalonia.Desktop.csproj", "{3C471044-3640-45E3-B1B2-16D2FF8399EE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Build.Tasks", "src\Avalonia.Build.Tasks\Avalonia.Build.Tasks.csproj", "{BF28998D-072C-439A-AFBB-2FE5021241E0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Build.Tasks", "src\Avalonia.Build.Tasks\Avalonia.Build.Tasks.csproj", "{BF28998D-072C-439A-AFBB-2FE5021241E0}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "nukebuild\_build.csproj", "{3F00BC43-5095-477F-93D8-E65B08179A00}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Animation.UnitTests", "tests\Avalonia.Animation.UnitTests\Avalonia.Animation.UnitTests.csproj", "{AF227847-E65C-4BE9-BCE9-B551357788E0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Animation.UnitTests", "tests\Avalonia.Animation.UnitTests\Avalonia.Animation.UnitTests.csproj", "{AF227847-E65C-4BE9-BCE9-B551357788E0}" EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution @@ -220,10 +221,6 @@ Global Release|iPhoneSimulator = Release|iPhoneSimulator EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {3F00BC43-5095-477F-93D8-E65B08179A00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3F00BC43-5095-477F-93D8-E65B08179A00}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3F00BC43-5095-477F-93D8-E65B08179A00}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3F00BC43-5095-477F-93D8-E65B08179A00}.Release|Any CPU.Build.0 = Release|Any CPU {B09B78D8-9B26-48B0-9149-D64A2F120F3F}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU {B09B78D8-9B26-48B0-9149-D64A2F120F3F}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU {B09B78D8-9B26-48B0-9149-D64A2F120F3F}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU @@ -1722,6 +1719,30 @@ Global {BF28998D-072C-439A-AFBB-2FE5021241E0}.Release|iPhone.Build.0 = Release|Any CPU {BF28998D-072C-439A-AFBB-2FE5021241E0}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {BF28998D-072C-439A-AFBB-2FE5021241E0}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {3F00BC43-5095-477F-93D8-E65B08179A00}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU + {3F00BC43-5095-477F-93D8-E65B08179A00}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU + {3F00BC43-5095-477F-93D8-E65B08179A00}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU + {3F00BC43-5095-477F-93D8-E65B08179A00}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU + {3F00BC43-5095-477F-93D8-E65B08179A00}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU + {3F00BC43-5095-477F-93D8-E65B08179A00}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU + {3F00BC43-5095-477F-93D8-E65B08179A00}.AppStore|Any CPU.ActiveCfg = Release|Any CPU + {3F00BC43-5095-477F-93D8-E65B08179A00}.AppStore|Any CPU.Build.0 = Release|Any CPU + {3F00BC43-5095-477F-93D8-E65B08179A00}.AppStore|iPhone.ActiveCfg = Release|Any CPU + {3F00BC43-5095-477F-93D8-E65B08179A00}.AppStore|iPhone.Build.0 = Release|Any CPU + {3F00BC43-5095-477F-93D8-E65B08179A00}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU + {3F00BC43-5095-477F-93D8-E65B08179A00}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU + {3F00BC43-5095-477F-93D8-E65B08179A00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3F00BC43-5095-477F-93D8-E65B08179A00}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3F00BC43-5095-477F-93D8-E65B08179A00}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {3F00BC43-5095-477F-93D8-E65B08179A00}.Debug|iPhone.Build.0 = Debug|Any CPU + {3F00BC43-5095-477F-93D8-E65B08179A00}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {3F00BC43-5095-477F-93D8-E65B08179A00}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {3F00BC43-5095-477F-93D8-E65B08179A00}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3F00BC43-5095-477F-93D8-E65B08179A00}.Release|Any CPU.Build.0 = Release|Any CPU + {3F00BC43-5095-477F-93D8-E65B08179A00}.Release|iPhone.ActiveCfg = Release|Any CPU + {3F00BC43-5095-477F-93D8-E65B08179A00}.Release|iPhone.Build.0 = Release|Any CPU + {3F00BC43-5095-477F-93D8-E65B08179A00}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {3F00BC43-5095-477F-93D8-E65B08179A00}.Release|iPhoneSimulator.Build.0 = Release|Any CPU {AF227847-E65C-4BE9-BCE9-B551357788E0}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU {AF227847-E65C-4BE9-BCE9-B551357788E0}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU {AF227847-E65C-4BE9-BCE9-B551357788E0}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU From 4b234f73dfb8604d7f13f1b23d91dc3da150f74d Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Thu, 10 Jan 2019 08:34:58 +0300 Subject: [PATCH 2/9] Run Avalonia.Base.UnitTests on netfx/mono --- build/NetFX.props | 5 ++ build/UnitTests.NetFX.props | 8 ++++ build/xunit.runner.mono.json | 1 + nukebuild/Build.cs | 47 +++++++++++-------- .../Avalonia.Base.UnitTests.csproj | 4 +- .../DataAnnotationsValidationPluginTests.cs | 24 +++++----- 6 files changed, 58 insertions(+), 31 deletions(-) create mode 100644 build/UnitTests.NetFX.props create mode 100644 build/xunit.runner.mono.json diff --git a/build/NetFX.props b/build/NetFX.props index d8b2daf13a..4d2841714b 100644 --- a/build/NetFX.props +++ b/build/NetFX.props @@ -3,4 +3,9 @@ /usr/lib/mono/4.6.1-api /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.6.1-api + + /usr/lib/mono/4.7-api/ + /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.7-api + + diff --git a/build/UnitTests.NetFX.props b/build/UnitTests.NetFX.props new file mode 100644 index 0000000000..e9a29d80fe --- /dev/null +++ b/build/UnitTests.NetFX.props @@ -0,0 +1,8 @@ + + + + + PreserveNewest + + + diff --git a/build/xunit.runner.mono.json b/build/xunit.runner.mono.json new file mode 100644 index 0000000000..4fb88b54c6 --- /dev/null +++ b/build/xunit.runner.mono.json @@ -0,0 +1 @@ +{ "appDomain": "denied" } diff --git a/nukebuild/Build.cs b/nukebuild/Build.cs index a14842cfd3..c8d35cd877 100644 --- a/nukebuild/Build.cs +++ b/nukebuild/Build.cs @@ -5,6 +5,7 @@ using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Threading; +using System.Xml.Linq; using Nuke.Common; using Nuke.Common.Git; using Nuke.Common.ProjectModel; @@ -92,16 +93,24 @@ partial class Build : NukeBuild ); }); - void RunCoreTest(string project, bool coreOnly = false) + void RunCoreTest(string project) { if(!project.EndsWith(".csproj")) project = System.IO.Path.Combine(project, System.IO.Path.GetFileName(project)+".csproj"); Information("Running tests from " + project); - var frameworks = new List(){"netcoreapp2.0"}; + XDocument xdoc; + using (var s = File.OpenRead(project)) + xdoc = XDocument.Load(s); + + List frameworks = null; + var targets = xdoc.Root.Descendants("TargetFrameworks").FirstOrDefault(); + if (targets != null) + frameworks = targets.Value.Split(';').Where(f => !string.IsNullOrWhiteSpace(f)).ToList(); + else + frameworks = new List {xdoc.Root.Descendants("TargetFramework").First().Value}; + foreach(var fw in frameworks) { - if(!fw.StartsWith("netcoreapp") && coreOnly) - continue; Information("Running for " + fw); DotNetTest(c => { @@ -124,18 +133,18 @@ partial class Build : NukeBuild .DependsOn(Compile) .Executes(() => { - RunCoreTest("./tests/Avalonia.Animation.UnitTests", false); - RunCoreTest("./tests/Avalonia.Base.UnitTests", false); - RunCoreTest("./tests/Avalonia.Controls.UnitTests", false); - RunCoreTest("./tests/Avalonia.Input.UnitTests", false); - RunCoreTest("./tests/Avalonia.Interactivity.UnitTests", false); - RunCoreTest("./tests/Avalonia.Layout.UnitTests", false); - RunCoreTest("./tests/Avalonia.Markup.UnitTests", false); - RunCoreTest("./tests/Avalonia.Markup.Xaml.UnitTests", false); - RunCoreTest("./tests/Avalonia.Styling.UnitTests", false); - RunCoreTest("./tests/Avalonia.Visuals.UnitTests", false); - RunCoreTest("./tests/Avalonia.Skia.UnitTests", false); - RunCoreTest("./tests/Avalonia.ReactiveUI.UnitTests", false); + RunCoreTest("./tests/Avalonia.Animation.UnitTests"); + RunCoreTest("./tests/Avalonia.Base.UnitTests"); + RunCoreTest("./tests/Avalonia.Controls.UnitTests"); + RunCoreTest("./tests/Avalonia.Input.UnitTests"); + RunCoreTest("./tests/Avalonia.Interactivity.UnitTests"); + RunCoreTest("./tests/Avalonia.Layout.UnitTests"); + RunCoreTest("./tests/Avalonia.Markup.UnitTests"); + RunCoreTest("./tests/Avalonia.Markup.Xaml.UnitTests"); + RunCoreTest("./tests/Avalonia.Styling.UnitTests"); + RunCoreTest("./tests/Avalonia.Visuals.UnitTests"); + RunCoreTest("./tests/Avalonia.Skia.UnitTests"); + RunCoreTest("./tests/Avalonia.ReactiveUI.UnitTests"); }); Target RunRenderTests => _ => _ @@ -143,9 +152,9 @@ partial class Build : NukeBuild .DependsOn(Compile) .Executes(() => { - RunCoreTest("./tests/Avalonia.Skia.RenderTests/Avalonia.Skia.RenderTests.csproj", true); + RunCoreTest("./tests/Avalonia.Skia.RenderTests/Avalonia.Skia.RenderTests.csproj"); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - RunCoreTest("./tests/Avalonia.Direct2D1.RenderTests/Avalonia.Direct2D1.RenderTests.csproj", true); + RunCoreTest("./tests/Avalonia.Direct2D1.RenderTests/Avalonia.Direct2D1.RenderTests.csproj"); }); Target RunDesignerTests => _ => _ @@ -153,7 +162,7 @@ partial class Build : NukeBuild .DependsOn(Compile) .Executes(() => { - RunCoreTest("./tests/Avalonia.DesignerSupport.Tests", false); + RunCoreTest("./tests/Avalonia.DesignerSupport.Tests"); }); [PackageExecutable("JetBrains.dotMemoryUnit", "dotMemoryUnit.exe")] readonly Tool DotMemoryUnit; diff --git a/tests/Avalonia.Base.UnitTests/Avalonia.Base.UnitTests.csproj b/tests/Avalonia.Base.UnitTests/Avalonia.Base.UnitTests.csproj index 373b3f7196..6e885f33be 100644 --- a/tests/Avalonia.Base.UnitTests/Avalonia.Base.UnitTests.csproj +++ b/tests/Avalonia.Base.UnitTests/Avalonia.Base.UnitTests.csproj @@ -1,9 +1,11 @@  - netcoreapp2.0 + netcoreapp2.0;net47 Library + true + diff --git a/tests/Avalonia.Base.UnitTests/Data/Core/Plugins/DataAnnotationsValidationPluginTests.cs b/tests/Avalonia.Base.UnitTests/Data/Core/Plugins/DataAnnotationsValidationPluginTests.cs index 2bffb7b84a..378c225e23 100644 --- a/tests/Avalonia.Base.UnitTests/Data/Core/Plugins/DataAnnotationsValidationPluginTests.cs +++ b/tests/Avalonia.Base.UnitTests/Data/Core/Plugins/DataAnnotationsValidationPluginTests.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.Linq; using Avalonia.Data; using Avalonia.Data.Core.Plugins; using Avalonia.UnitTests; @@ -86,17 +87,18 @@ namespace Avalonia.Markup.UnitTests.Data.Plugins validator.SetValue("123456", BindingPriority.LocalValue); validator.SetValue("abcdefghijklm", BindingPriority.LocalValue); - Assert.Equal(new[] - { - new BindingNotification(null), - new BindingNotification("123456"), - new BindingNotification( - new AggregateException( - new ValidationException("The PhoneNumber field is not a valid phone number."), - new ValidationException("The field PhoneNumber must be a string or array type with a maximum length of '10'.")), - BindingErrorType.DataValidationError, - "abcdefghijklm"), - }, result); + Assert.Equal(3, result.Count); + Assert.Equal(new BindingNotification(null), result[0]); + Assert.Equal(new BindingNotification("123456"), result[1]); + var errorResult = (BindingNotification)result[2]; + Assert.Equal(BindingErrorType.DataValidationError, errorResult.ErrorType); + Assert.Equal("abcdefghijklm", errorResult.Value); + var exceptions = ((AggregateException)(errorResult.Error)).InnerExceptions; + Assert.True(exceptions.Any(ex => + ex.Message.Contains("The PhoneNumber field is not a valid phone number."))); + Assert.True(exceptions.Any(ex => + ex.Message.Contains("The field PhoneNumber must be a string or array type with a maximum length of '10'."))); + } private class Data From feadefc1a18a517c94f8a673c74d77dd2ad44c23 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Thu, 10 Jan 2019 08:51:27 +0300 Subject: [PATCH 3/9] Run Mono/FullNET tests for all "core" libs except Avalonia.Controls --- .../Avalonia.Animation.UnitTests.csproj | 6 ++++-- .../Data/Core/ExpressionObserverTests_Property.cs | 7 ++++++- .../Avalonia.Input.UnitTests.csproj | 6 ++++-- .../Avalonia.Interactivity.UnitTests.csproj | 5 ++++- .../Avalonia.Markup.UnitTests.csproj | 6 ++++-- .../Avalonia.Markup.Xaml.UnitTests.csproj | 6 ++++-- .../Avalonia.Styling.UnitTests.csproj | 6 ++++-- .../Avalonia.Visuals.UnitTests.csproj | 7 +++++-- 8 files changed, 35 insertions(+), 14 deletions(-) diff --git a/tests/Avalonia.Animation.UnitTests/Avalonia.Animation.UnitTests.csproj b/tests/Avalonia.Animation.UnitTests/Avalonia.Animation.UnitTests.csproj index 1b2ba3c7de..ef515ce155 100644 --- a/tests/Avalonia.Animation.UnitTests/Avalonia.Animation.UnitTests.csproj +++ b/tests/Avalonia.Animation.UnitTests/Avalonia.Animation.UnitTests.csproj @@ -1,9 +1,11 @@  - netcoreapp2.0 + netcoreapp2.0;net47 Library + true + @@ -22,4 +24,4 @@ - \ No newline at end of file + diff --git a/tests/Avalonia.Base.UnitTests/Data/Core/ExpressionObserverTests_Property.cs b/tests/Avalonia.Base.UnitTests/Data/Core/ExpressionObserverTests_Property.cs index c90683959e..239c9d56aa 100644 --- a/tests/Avalonia.Base.UnitTests/Data/Core/ExpressionObserverTests_Property.cs +++ b/tests/Avalonia.Base.UnitTests/Data/Core/ExpressionObserverTests_Property.cs @@ -558,7 +558,12 @@ namespace Avalonia.Base.UnitTests.Data.Core var result = run(); result.Item1.Subscribe(x => { }); - GC.Collect(); + // Mono trickery + GC.Collect(2); + GC.WaitForPendingFinalizers(); + GC.WaitForPendingFinalizers(); + GC.Collect(2); + Assert.Null(result.Item2.Target); } diff --git a/tests/Avalonia.Input.UnitTests/Avalonia.Input.UnitTests.csproj b/tests/Avalonia.Input.UnitTests/Avalonia.Input.UnitTests.csproj index 1b2ba3c7de..ef515ce155 100644 --- a/tests/Avalonia.Input.UnitTests/Avalonia.Input.UnitTests.csproj +++ b/tests/Avalonia.Input.UnitTests/Avalonia.Input.UnitTests.csproj @@ -1,9 +1,11 @@  - netcoreapp2.0 + netcoreapp2.0;net47 Library + true + @@ -22,4 +24,4 @@ - \ No newline at end of file + diff --git a/tests/Avalonia.Interactivity.UnitTests/Avalonia.Interactivity.UnitTests.csproj b/tests/Avalonia.Interactivity.UnitTests/Avalonia.Interactivity.UnitTests.csproj index bc883d0251..6b19d81034 100644 --- a/tests/Avalonia.Interactivity.UnitTests/Avalonia.Interactivity.UnitTests.csproj +++ b/tests/Avalonia.Interactivity.UnitTests/Avalonia.Interactivity.UnitTests.csproj @@ -1,9 +1,12 @@  netcoreapp2.0 + netcoreapp2.0;net47 Library + true + @@ -20,4 +23,4 @@ - \ No newline at end of file + diff --git a/tests/Avalonia.Markup.UnitTests/Avalonia.Markup.UnitTests.csproj b/tests/Avalonia.Markup.UnitTests/Avalonia.Markup.UnitTests.csproj index 1680ecf798..aba5f2d469 100644 --- a/tests/Avalonia.Markup.UnitTests/Avalonia.Markup.UnitTests.csproj +++ b/tests/Avalonia.Markup.UnitTests/Avalonia.Markup.UnitTests.csproj @@ -1,9 +1,11 @@  - netcoreapp2.0 + netcoreapp2.0;net47 Library + true + @@ -23,4 +25,4 @@ - \ No newline at end of file + diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/Avalonia.Markup.Xaml.UnitTests.csproj b/tests/Avalonia.Markup.Xaml.UnitTests/Avalonia.Markup.Xaml.UnitTests.csproj index 735d5c421a..8b47bcec30 100644 --- a/tests/Avalonia.Markup.Xaml.UnitTests/Avalonia.Markup.Xaml.UnitTests.csproj +++ b/tests/Avalonia.Markup.Xaml.UnitTests/Avalonia.Markup.Xaml.UnitTests.csproj @@ -1,9 +1,11 @@  - netcoreapp2.0 + netcoreapp2.0;net47 Library + true + @@ -36,4 +38,4 @@ - \ No newline at end of file + diff --git a/tests/Avalonia.Styling.UnitTests/Avalonia.Styling.UnitTests.csproj b/tests/Avalonia.Styling.UnitTests/Avalonia.Styling.UnitTests.csproj index e65dd848dd..3fd280f7ab 100644 --- a/tests/Avalonia.Styling.UnitTests/Avalonia.Styling.UnitTests.csproj +++ b/tests/Avalonia.Styling.UnitTests/Avalonia.Styling.UnitTests.csproj @@ -1,10 +1,12 @@  - netcoreapp2.0 + netcoreapp2.0;net47 Library CS0067 + true + @@ -23,4 +25,4 @@ - \ No newline at end of file + diff --git a/tests/Avalonia.Visuals.UnitTests/Avalonia.Visuals.UnitTests.csproj b/tests/Avalonia.Visuals.UnitTests/Avalonia.Visuals.UnitTests.csproj index 2b559c9c56..50c2e580b0 100644 --- a/tests/Avalonia.Visuals.UnitTests/Avalonia.Visuals.UnitTests.csproj +++ b/tests/Avalonia.Visuals.UnitTests/Avalonia.Visuals.UnitTests.csproj @@ -1,8 +1,11 @@  - netcoreapp2.0 + netcoreapp2.0;net47 + Library + true + @@ -21,4 +24,4 @@ - \ No newline at end of file + From a75c8b985995fc1a7bc139b9f19ce4b444538811 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Thu, 10 Jan 2019 09:22:03 +0300 Subject: [PATCH 4/9] Adapted GridLayoutTests to run on Mono --- .../Avalonia.Controls.UnitTests.csproj | 6 ++- .../GridLayoutTests.cs | 53 +++++++++++-------- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/tests/Avalonia.Controls.UnitTests/Avalonia.Controls.UnitTests.csproj b/tests/Avalonia.Controls.UnitTests/Avalonia.Controls.UnitTests.csproj index b418d56fcd..aa470bce9d 100644 --- a/tests/Avalonia.Controls.UnitTests/Avalonia.Controls.UnitTests.csproj +++ b/tests/Avalonia.Controls.UnitTests/Avalonia.Controls.UnitTests.csproj @@ -1,10 +1,12 @@  - netcoreapp2.0 + netcoreapp2.0;net47 latest Library + true + @@ -26,4 +28,4 @@ - \ No newline at end of file + diff --git a/tests/Avalonia.Controls.UnitTests/GridLayoutTests.cs b/tests/Avalonia.Controls.UnitTests/GridLayoutTests.cs index fbb90de505..93163f4a92 100644 --- a/tests/Avalonia.Controls.UnitTests/GridLayoutTests.cs +++ b/tests/Avalonia.Controls.UnitTests/GridLayoutTests.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System.Collections; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using Avalonia.Controls.Utils; @@ -16,7 +17,7 @@ namespace Avalonia.Controls.UnitTests [InlineData("100, 200, 300", 600d, 600d, new[] { 100d, 200d, 300d })] [InlineData("100, 200, 300", 400d, 400d, new[] { 100d, 200d, 100d })] public void MeasureArrange_AllPixelLength_Correct(string length, double containerLength, - double expectedDesiredLength, IList expectedLengthList) + double expectedDesiredLength, IList expectedLengthList) { TestRowDefinitionsOnly(length, containerLength, expectedDesiredLength, expectedLengthList); } @@ -25,7 +26,7 @@ namespace Avalonia.Controls.UnitTests [InlineData("*,2*,3*", 0d, 0d, new[] { 0d, 0d, 0d })] [InlineData("*,2*,3*", 600d, 0d, new[] { 100d, 200d, 300d })] public void MeasureArrange_AllStarLength_Correct(string length, double containerLength, - double expectedDesiredLength, IList expectedLengthList) + double expectedDesiredLength, IList expectedLengthList) { TestRowDefinitionsOnly(length, containerLength, expectedDesiredLength, expectedLengthList); } @@ -36,7 +37,7 @@ namespace Avalonia.Controls.UnitTests [InlineData("100,2*,3*", 100d, 100d, new[] { 100d, 0d, 0d })] [InlineData("100,2*,3*", 50d, 50d, new[] { 50d, 0d, 0d })] public void MeasureArrange_MixStarPixelLength_Correct(string length, double containerLength, - double expectedDesiredLength, IList expectedLengthList) + double expectedDesiredLength, IList expectedLengthList) { TestRowDefinitionsOnly(length, containerLength, expectedDesiredLength, expectedLengthList); } @@ -49,7 +50,7 @@ namespace Avalonia.Controls.UnitTests [InlineData("100,200,Auto", 100d, 100d, new[] { 100d, 0d, 0d })] [InlineData("100,200,Auto", 50d, 50d, new[] { 50d, 0d, 0d })] public void MeasureArrange_MixAutoPixelLength_Correct(string length, double containerLength, - double expectedDesiredLength, IList expectedLengthList) + double expectedDesiredLength, IList expectedLengthList) { TestRowDefinitionsOnly(length, containerLength, expectedDesiredLength, expectedLengthList); } @@ -58,7 +59,7 @@ namespace Avalonia.Controls.UnitTests [InlineData("*,2*,Auto", 0d, 0d, new[] { 0d, 0d, 0d })] [InlineData("*,2*,Auto", 600d, 0d, new[] { 200d, 400d, 0d })] public void MeasureArrange_MixAutoStarLength_Correct(string length, double containerLength, - double expectedDesiredLength, IList expectedLengthList) + double expectedDesiredLength, IList expectedLengthList) { TestRowDefinitionsOnly(length, containerLength, expectedDesiredLength, expectedLengthList); } @@ -69,14 +70,24 @@ namespace Avalonia.Controls.UnitTests [InlineData("*,200,Auto", 200d, 200d, new[] { 0d, 200d, 0d })] [InlineData("*,200,Auto", 100d, 100d, new[] { 0d, 100d, 0d })] public void MeasureArrange_MixAutoStarPixelLength_Correct(string length, double containerLength, - double expectedDesiredLength, IList expectedLengthList) + double expectedDesiredLength, IList expectedLengthList) { TestRowDefinitionsOnly(length, containerLength, expectedDesiredLength, expectedLengthList); } + + /// + /// This is needed because Mono somehow converts double array to object array in attribute metadata + /// + static void AssertEqual(IList expected, IReadOnlyList actual) + { + var conv = expected.Cast().ToArray(); + Assert.Equal(conv, actual); + } + [SuppressMessage("ReSharper", "ParameterOnlyUsedForPreconditionCheck.Local")] private static void TestRowDefinitionsOnly(string length, double containerLength, - double expectedDesiredLength, IList expectedLengthList) + double expectedDesiredLength, IList expectedLengthList) { // Arrange var layout = new GridLayout(new RowDefinitions(length)); @@ -84,11 +95,11 @@ namespace Avalonia.Controls.UnitTests // Measure - Action & Assert var measure = layout.Measure(containerLength); Assert.Equal(expectedDesiredLength, measure.DesiredLength); - Assert.Equal(expectedLengthList, measure.LengthList); + AssertEqual(expectedLengthList, measure.LengthList); // Arrange - Action & Assert var arrange = layout.Arrange(containerLength, measure); - Assert.Equal(expectedLengthList, arrange.LengthList); + AssertEqual(expectedLengthList, arrange.LengthList); } [Theory] @@ -99,7 +110,7 @@ namespace Avalonia.Controls.UnitTests [InlineData("*,2*,Auto", 0d, new[] { Inf, Inf, 0d }, new[] { 0d, 0d, 0d })] [InlineData("*,200,Auto", 200d, new[] { Inf, 200d, 0d }, new[] { 0d, 200d, 0d })] public void MeasureArrange_InfiniteMeasure_Correct(string length, double expectedDesiredLength, - IList expectedMeasureList, IList expectedArrangeList) + IList expectedMeasureList, IList expectedArrangeList) { // Arrange var layout = new GridLayout(new RowDefinitions(length)); @@ -107,34 +118,34 @@ namespace Avalonia.Controls.UnitTests // Measure - Action & Assert var measure = layout.Measure(Inf); Assert.Equal(expectedDesiredLength, measure.DesiredLength); - Assert.Equal(expectedMeasureList, measure.LengthList); + AssertEqual(expectedMeasureList, measure.LengthList); // Arrange - Action & Assert var arrange = layout.Arrange(measure.DesiredLength, measure); - Assert.Equal(expectedArrangeList, arrange.LengthList); + AssertEqual(expectedArrangeList, arrange.LengthList); } [Theory] [InlineData("Auto,*,*", new[] { 100d, 100d, 100d }, 600d, 300d, new[] { 100d, 250d, 250d })] public void MeasureArrange_ChildHasSize_Correct(string length, - IList childLengthList, double containerLength, - double expectedDesiredLength, IList expectedLengthList) + IList childLengthList, double containerLength, + double expectedDesiredLength, IList expectedLengthList) { // Arrange var lengthList = new ColumnDefinitions(length); var layout = new GridLayout(lengthList); layout.AppendMeasureConventions( Enumerable.Range(0, lengthList.Count).ToDictionary(x => x, x => (x, 1)), - x => childLengthList[x]); + x => (double)childLengthList[x]); // Measure - Action & Assert var measure = layout.Measure(containerLength); Assert.Equal(expectedDesiredLength, measure.DesiredLength); - Assert.Equal(expectedLengthList, measure.LengthList); + AssertEqual(expectedLengthList, measure.LengthList); // Arrange - Action & Assert var arrange = layout.Arrange(containerLength, measure); - Assert.Equal(expectedLengthList, arrange.LengthList); + AssertEqual(expectedLengthList, arrange.LengthList); } [Theory] @@ -145,7 +156,7 @@ namespace Avalonia.Controls.UnitTests [InlineData(160d, 160d, new[] { 100d, 20d, 40d }, new[] { 100d, 20d, 40d })] public void MeasureArrange_ChildHasSizeAndHasMultiSpan_Correct( double containerLength, double expectedDesiredLength, - IList expectedMeasureLengthList, IList expectedArrangeLengthList) + IList expectedMeasureLengthList, IList expectedArrangeLengthList) { var length = "100,*,2*"; var childLengthList = new[] { 150d, 150d, 150d }; @@ -161,13 +172,13 @@ namespace Avalonia.Controls.UnitTests // Measure - Action & Assert var measure = layout.Measure(containerLength); Assert.Equal(expectedDesiredLength, measure.DesiredLength); - Assert.Equal(expectedMeasureLengthList, measure.LengthList); + AssertEqual(expectedMeasureLengthList, measure.LengthList); // Arrange - Action & Assert var arrange = layout.Arrange( double.IsInfinity(containerLength) ? measure.DesiredLength : containerLength, measure); - Assert.Equal(expectedArrangeLengthList, arrange.LengthList); + AssertEqual(expectedArrangeLengthList, arrange.LengthList); } } } From 0c47fc299acfe7f1d4bb9160c513cbe980744edf Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Thu, 10 Jan 2019 09:32:38 +0300 Subject: [PATCH 5/9] Print dotnet and mono versions --- nukebuild/Build.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/nukebuild/Build.cs b/nukebuild/Build.cs index c8d35cd877..bb31034299 100644 --- a/nukebuild/Build.cs +++ b/nukebuild/Build.cs @@ -57,6 +57,17 @@ partial class Build : NukeBuild Information("IsReleasable: " + Parameters.IsReleasable); Information("IsMyGetRelease: " + Parameters.IsMyGetRelease); Information("IsNuGetRelease: " + Parameters.IsNuGetRelease); + + void ExecWait(string preamble, string command, string args) + { + Console.WriteLine(preamble); + Process.Start(new ProcessStartInfo(command, args) {UseShellExecute = false}).WaitForExit(); + } + ExecWait("dotnet version:", "dotnet", "--version"); + if (Parameters.IsRunningOnUnix) + ExecWait("Mono version:", "mono", "--version"); + + } Target Clean => _ => _.Executes(() => From 8aea57118a02c40dedaf76a041583b8928f521d4 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Thu, 10 Jan 2019 13:58:12 +0300 Subject: [PATCH 6/9] Install Mono 5.18 for OSX Azure build --- azure-pipelines.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index bcd0082c6f..fd40118888 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -38,6 +38,13 @@ jobs: inputs: version: '2.1.403' + - task: CmdLine@2 + displayName: 'Install Mono 5.18' + inputs: + script: | + curl -o ./mono.pkg https://download.mono-project.com/archive/5.18.0/macos-10-universal/MonoFramework-MDK-5.18.0.225.macos10.xamarin.universal.pkg + sudo installer -verbose -pkg ./mono.pkg -target / + - task: Xcode@5 inputs: actions: 'build' From 97d624a9ae5cdac6ffe2cce42a485f2ea4a2cad9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro?= Date: Wed, 9 Jan 2019 22:39:00 +0000 Subject: [PATCH 7/9] Use nameof where possible. --- src/Avalonia.Animation/IterationCount.cs | 2 +- src/Avalonia.Base/Collections/AvaloniaDictionary.cs | 4 ++-- src/Avalonia.Base/Collections/AvaloniaList.cs | 2 +- src/Avalonia.Controls/Calendar/DatePicker.cs | 2 +- src/Avalonia.Controls/GridLength.cs | 4 ++-- src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs | 2 +- src/Avalonia.Styling/Styling/Setter.cs | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Avalonia.Animation/IterationCount.cs b/src/Avalonia.Animation/IterationCount.cs index eafc483868..e9cd0686d8 100644 --- a/src/Avalonia.Animation/IterationCount.cs +++ b/src/Avalonia.Animation/IterationCount.cs @@ -44,7 +44,7 @@ namespace Avalonia.Animation { if (type > IterationType.Infinite) { - throw new ArgumentException("Invalid value", "type"); + throw new ArgumentException("Invalid value", nameof(type)); } _type = type; diff --git a/src/Avalonia.Base/Collections/AvaloniaDictionary.cs b/src/Avalonia.Base/Collections/AvaloniaDictionary.cs index e8dc2a5ed7..4de4c540a0 100644 --- a/src/Avalonia.Base/Collections/AvaloniaDictionary.cs +++ b/src/Avalonia.Base/Collections/AvaloniaDictionary.cs @@ -148,7 +148,7 @@ namespace Avalonia.Collections { if (_inner.TryGetValue(key, out TValue value)) { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Count")); + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Count))); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs($"Item[{key}]")); if (CollectionChanged != null) @@ -209,7 +209,7 @@ namespace Avalonia.Collections private void NotifyAdd(TKey key, TValue value) { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Count")); + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Count))); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs($"Item[{key}]")); diff --git a/src/Avalonia.Base/Collections/AvaloniaList.cs b/src/Avalonia.Base/Collections/AvaloniaList.cs index d5a4e63003..4d4a561b08 100644 --- a/src/Avalonia.Base/Collections/AvaloniaList.cs +++ b/src/Avalonia.Base/Collections/AvaloniaList.cs @@ -511,7 +511,7 @@ namespace Avalonia.Collections /// private void NotifyCountChanged() { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Count")); + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Count))); } /// diff --git a/src/Avalonia.Controls/Calendar/DatePicker.cs b/src/Avalonia.Controls/Calendar/DatePicker.cs index 2270598623..70de8bec16 100644 --- a/src/Avalonia.Controls/Calendar/DatePicker.cs +++ b/src/Avalonia.Controls/Calendar/DatePicker.cs @@ -954,7 +954,7 @@ namespace Avalonia.Controls } else { - var dateValidationError = new DatePickerDateValidationErrorEventArgs(new ArgumentOutOfRangeException("text", "SelectedDate value is not valid."), text); + var dateValidationError = new DatePickerDateValidationErrorEventArgs(new ArgumentOutOfRangeException(nameof(text), "SelectedDate value is not valid."), text); OnDateValidationError(dateValidationError); if (dateValidationError.ThrowException) diff --git a/src/Avalonia.Controls/GridLength.cs b/src/Avalonia.Controls/GridLength.cs index f6a608cd71..02be95b647 100644 --- a/src/Avalonia.Controls/GridLength.cs +++ b/src/Avalonia.Controls/GridLength.cs @@ -56,12 +56,12 @@ namespace Avalonia.Controls { if (value < 0 || double.IsNaN(value) || double.IsInfinity(value)) { - throw new ArgumentException("Invalid value", "value"); + throw new ArgumentException("Invalid value", nameof(value)); } if (type < GridUnitType.Auto || type > GridUnitType.Star) { - throw new ArgumentException("Invalid value", "type"); + throw new ArgumentException("Invalid value", nameof(type)); } _type = type; diff --git a/src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs b/src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs index de68eb0ab0..57db1e19bb 100644 --- a/src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs +++ b/src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs @@ -487,7 +487,7 @@ namespace Avalonia.Controls { if (e == null) { - throw new ArgumentNullException("e"); + throw new ArgumentNullException(nameof(e)); } var handler = Spinned; diff --git a/src/Avalonia.Styling/Styling/Setter.cs b/src/Avalonia.Styling/Styling/Setter.cs index 54d0a7d40f..cfe17a4291 100644 --- a/src/Avalonia.Styling/Styling/Setter.cs +++ b/src/Avalonia.Styling/Styling/Setter.cs @@ -69,7 +69,7 @@ namespace Avalonia.Styling { throw new ArgumentException( "Cannot assign a control to Setter.Value. Wrap the control in a