diff --git a/.gitmodules b/.gitmodules index 0b2349ad42..6e9b10efa4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,9 +5,6 @@ path = src/Avalonia.HtmlRenderer/external url = https://github.com/AvaloniaUI/HTML-Renderer.git branch = perspex-pcl -[submodule "src/Markup/Avalonia.Markup.Xaml/OmniXAML"] - path = src/Markup/Avalonia.Markup.Xaml/OmniXAML - url = https://github.com/AvaloniaUI/OmniXAML.git -[submodule "src/Markup/Avalonia.Markup.Xaml/glass"] - path = src/Markup/Avalonia.Markup.Xaml/glass - url = https://github.com/SuperJMN/glass +[submodule "src/Markup/Avalonia.Markup.Xaml/PortableXaml/portable.xaml.github"] + path = src/Markup/Avalonia.Markup.Xaml/PortableXaml/portable.xaml.github + url = https://github.com/AvaloniaUI/Portable.Xaml.git diff --git a/.ncrunch/Avalonia.LinuxFramebuffer.v3.ncrunchproject b/.ncrunch/Avalonia.LinuxFramebuffer.v3.ncrunchproject new file mode 100644 index 0000000000..6800b4a3fe --- /dev/null +++ b/.ncrunch/Avalonia.LinuxFramebuffer.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/.ncrunch/Avalonia.Visuals.UnitTests.net461.v3.ncrunchproject b/.ncrunch/Avalonia.Visuals.UnitTests.net461.v3.ncrunchproject new file mode 100644 index 0000000000..6800b4a3fe --- /dev/null +++ b/.ncrunch/Avalonia.Visuals.UnitTests.net461.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/.ncrunch/Avalonia.Win32.Interop.v3.ncrunchproject b/.ncrunch/Avalonia.Win32.Interop.v3.ncrunchproject new file mode 100644 index 0000000000..6800b4a3fe --- /dev/null +++ b/.ncrunch/Avalonia.Win32.Interop.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 6b63176a89..7457a1d5bb 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -14,7 +14,7 @@ environment: secure: OtVfyN3ErqQrDTnWH2HDfJDlCiu/i4/X4wFmK3ZXXP7HmCiXYPSbTjMPwwdOxRaK MYGET_API_URL: https://www.myget.org/F/avalonia-ci/api/v2/package init: -- ps: (New-Object Net.WebClient).DownloadFile('https://raw.githubusercontent.com/appveyor/ci/master/scripts/xamarin-vs2017-151-fixed.targets', "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Microsoft.Common.Targets\ImportAfter\Xamarin.Common.targets") +- ps: if (Test-Path env:nuget_address) {[System.IO.File]::AppendAllText("C:\Windows\System32\drivers\etc\hosts", "`n$($env:nuget_address)`tapi.nuget.org")} install: - if not exist gtk-sharp-2.12.26.msi appveyor DownloadFile http://download.xamarin.com/GTKforWindows/Windows/gtk-sharp-2.12.26.msi - if not exist dotnet-1.0.1.exe appveyor DownloadFile https://go.microsoft.com/fwlink/?linkid=843448 -FileName "dotnet-1.0.1.exe" @@ -26,7 +26,6 @@ before_build: build_script: - ps: .\build.ps1 -Target "AppVeyor" -Platform "$env:platform" -Configuration "$env:configuration" after_build: -- tools\JetBrains.dotMemoryUnit\tools\dotMemoryUnit.exe -targetExecutable="%xunit20%\xunit.console.x86.exe" -returnTargetExitCode --"tests\Avalonia.LeakTests\bin\Release\Avalonia.LeakTests.dll" - "SET PATH=C:\\Python34;C:\\Python34\\Scripts;%PATH%" - pip install codecov - codecov -f "./artifacts/coverage.xml" diff --git a/build.cake b/build.cake index b3822271d4..6c2e554df4 100644 --- a/build.cake +++ b/build.cake @@ -4,8 +4,8 @@ #addin "nuget:?package=Polly&version=4.2.0" #addin "nuget:?package=NuGet.Core&version=2.12.0" +#tool "nuget:?package=xunit.runner.console&version=2.2.0" #tool "nuget:https://dotnet.myget.org/F/nuget-build/?package=NuGet.CommandLine&version=4.3.0-preview1-3980&prerelease" -#tool "nuget:?package=JetBrains.dotMemoryUnit&version=2.3.20160517.113140" #tool "JetBrains.ReSharper.CommandLineTools" /////////////////////////////////////////////////////////////////////////////// // TOOLS @@ -119,7 +119,6 @@ Task("Restore-NuGet-Packages") }}) .Execute(()=> { NuGetRestore(parameters.MSBuildSolution, new NuGetRestoreSettings { - ToolPath = "./tools/NuGet.CommandLine/tools/NuGet.exe", ToolTimeout = TimeSpan.FromMinutes(toolTimeout) }); }); @@ -194,6 +193,7 @@ Task("Run-Net-Core-Unit-Tests") Task("Run-Unit-Tests") .IsDependentOn("Run-Net-Core-Unit-Tests") .IsDependentOn("Build") + //.IsDependentOn("Run-Leak-Tests") .WithCriteria(() => !parameters.SkipTests) .Does(() => { @@ -206,13 +206,6 @@ Task("Run-Unit-Tests") .Select(name => MakeAbsolute(File("./tests/" + name + "/bin/" + parameters.DirSuffix + "/" + name + ".dll"))) .ToList(); - if (parameters.IsRunningOnWindows) - { - var leakTests = GetFiles("./tests/Avalonia.LeakTests/bin/" + parameters.DirSuffix + "/*.LeakTests.dll"); - - unitTests.AddRange(leakTests); - } - var toolPath = (parameters.IsPlatformAnyCPU || parameters.IsPlatformX86) ? "./tools/xunit.runner.console/tools/xunit.console.x86.exe" : "./tools/xunit.runner.console/tools/xunit.console.exe"; @@ -365,6 +358,44 @@ Task("Publish-NuGet") Information("Publish-NuGet Task failed, but continuing with next Task..."); }); +Task("Run-Leak-Tests") + .WithCriteria(parameters.IsRunningOnWindows) + .IsDependentOn("Build") + .Does(() => + { + DotNetCoreRestore("tests\\Avalonia.LeakTests\\toolproject\\tool.csproj"); + DotNetBuild("tests\\Avalonia.LeakTests\\toolproject\\tool.csproj", settings => settings.SetConfiguration("Release")); + var report = "tests\\Avalonia.LeakTests\\bin\\Release\\report.xml"; + if(System.IO.File.Exists(report)) + System.IO.File.Delete(report); + var proc = System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo + { + FileName="tests\\Avalonia.LeakTests\\toolproject\\bin\\dotMemoryUnit.exe", + Arguments="-targetExecutable=\"tools\\xunit.runner.console\\tools\\xunit.console.x86.exe\" -returnTargetExitCode -- tests\\Avalonia.LeakTests\\bin\\Release\\Avalonia.LeakTests.dll -xml tests\\Avalonia.LeakTests\\bin\\Release\\report.xml ", + UseShellExecute = false, + }); + var st = System.Diagnostics.Stopwatch.StartNew(); + while(!proc.HasExited && !System.IO.File.Exists(report)) + { + if(st.Elapsed.TotalSeconds>60) + { + Error("Timed out, probably a bug in dotMemoryUnit"); + proc.Kill(); + throw new Exception("dotMemory issue"); + } + proc.WaitForExit(100); + } + try{ + proc.Kill(); + }catch{} + var doc = System.Xml.Linq.XDocument.Load(report); + if(doc.Root.Descendants("assembly").Any(x=>x.Attribute("failed").Value.ToString() != "0")) + { + throw new Exception("Tests failed"); + } + + }); + Task("Inspect") .WithCriteria(parameters.IsRunningOnWindows) .IsDependentOn("Restore-NuGet-Packages") @@ -372,7 +403,8 @@ Task("Inspect") { var badIssues = new []{"PossibleNullReferenceException"}; var whitelist = new []{"tests", "src\\android", "src\\ios", - "src\\windows\\avalonia.designer", "src\\avalonia.htmlrenderer\\external"}; + "src\\windows\\avalonia.designer", "src\\avalonia.htmlrenderer\\external", + "src\\markup\\avalonia.markup.xaml\\portablexaml\\portable.xaml.github"}; Information("Running code inspections"); diff --git a/build/Markup.props b/build/Markup.props index 36c4cb28d8..5be0cfbf0c 100644 --- a/build/Markup.props +++ b/build/Markup.props @@ -5,5 +5,10 @@ + + + + + diff --git a/build/SharpDX.props b/build/SharpDX.props index e381bc03e6..69aa817a01 100644 --- a/build/SharpDX.props +++ b/build/SharpDX.props @@ -1,8 +1,9 @@  - - - - + + + + + diff --git a/build/UnitTests.NetCore.targets b/build/UnitTests.NetCore.targets index a8886fe028..13bb4ed230 100644 --- a/build/UnitTests.NetCore.targets +++ b/build/UnitTests.NetCore.targets @@ -25,5 +25,4 @@ - \ No newline at end of file diff --git a/build/XUnit.props b/build/XUnit.props index 27e0afc987..d59cee6536 100644 --- a/build/XUnit.props +++ b/build/XUnit.props @@ -12,4 +12,16 @@ + + true + + + + + true + + diff --git a/docs/tutorial/from-wpf.md b/docs/tutorial/from-wpf.md index 2db40cfd86..0eb6e80327 100644 --- a/docs/tutorial/from-wpf.md +++ b/docs/tutorial/from-wpf.md @@ -161,7 +161,7 @@ the same way that event class listeners are added](../spec/working-with-properti ## RenderTransforms and RenderTransformOrigin -RenderTransformOrigins are different in WPF and Avalonia: If you apply a `RenderTransform`, keep in mind that our default value for the RenderTransformOrigin is `RelativePoint.Middle`. In WPF the default value is `RelativePoint.TopLeft` (0, 0). In controls like Viewbox (currently being developed) the same code will lead to a different rendering behavior: +RenderTransformOrigins are different in WPF and Avalonia: If you apply a `RenderTransform`, keep in mind that our default value for the RenderTransformOrigin is `RelativePoint.Center`. In WPF the default value is `RelativePoint.TopLeft` (0, 0). In controls like Viewbox (currently being developed) the same code will lead to a different rendering behavior: In WPF: ![WPF](https://files.gitter.im/AvaloniaUI/Avalonia/cDrM/image.png) diff --git a/packages.cake b/packages.cake index 1a29695d82..0824dc6098 100644 --- a/packages.cake +++ b/packages.cake @@ -8,6 +8,42 @@ public class Packages public string NugetPackagesDir {get; private set;} public string SkiaSharpVersion {get; private set; } public string SkiaSharpLinuxVersion {get; private set; } + public Dictionary>> PackageVersions{get; private set;} + + + + class DependencyBuilder : List + { + Packages _parent; + public DependencyBuilder(Packages parent) + { + _parent = parent; + } + + string GetVersion(string name) + { + return _parent.PackageVersions[name].First().Item1; + } + + + public DependencyBuilder Dep(string name, params string[] fws) + { + if(fws.Length == 0) + Add(new NuSpecDependency() { Id = name, Version = GetVersion(name) }); + foreach(var fw in fws) + Add(new NuSpecDependency() { Id = name, TargetFramework = fw, Version = GetVersion(name) }); + return this; + } + public DependencyBuilder Deps(string[] fws, params string[] deps) + { + foreach(var fw in fws) + foreach(var name in deps) + Add(new NuSpecDependency() { Id = name, TargetFramework = fw, Version = GetVersion(name) }); + return this; + } + } + + //new NuSpecDependency() { Id = "System.Threading.ThreadPool", TargetFramework = "netcoreapp1.0", Version = "4.3.0" }, public Packages(ICakeContext context, Parameters parameters) { // NUGET NUSPECS @@ -26,7 +62,7 @@ public class Packages // Key: Package Id // Value is Tuple where Item1: Package Version, Item2: The *.csproj/*.props file path. var packageVersions = new Dictionary>>(); - + PackageVersions = packageVersions; System.IO.Directory.EnumerateFiles(((DirectoryPath)context.Directory("./build")).FullPath, "*.props", SearchOption.AllDirectories).ToList().ForEach(fileName => { @@ -81,6 +117,7 @@ public class Packages var SharpDXVersion = packageVersions["SharpDX"].FirstOrDefault().Item1; var SharpDXDirect2D1Version = packageVersions["SharpDX.Direct2D1"].FirstOrDefault().Item1; var SharpDXDirect3D11Version = packageVersions["SharpDX.Direct3D11"].FirstOrDefault().Item1; + var SharpDXDirect3D9Version = packageVersions["SharpDX.Direct3D9"].FirstOrDefault().Item1; var SharpDXDXGIVersion = packageVersions["SharpDX.DXGI"].FirstOrDefault().Item1; context.Information("Package: Serilog, version: {0}", SerilogVersion); @@ -93,6 +130,7 @@ public class Packages context.Information("Package: SharpDX, version: {0}", SharpDXVersion); context.Information("Package: SharpDX.Direct2D1, version: {0}", SharpDXDirect2D1Version); context.Information("Package: SharpDX.Direct3D11, version: {0}", SharpDXDirect3D11Version); + context.Information("Package: SharpDX.Direct3D9, version: {0}", SharpDXDirect3D9Version); context.Information("Package: SharpDX.DXGI, version: {0}", SharpDXDXGIVersion); var nugetPackagesDir = System.Environment.GetEnvironmentVariable("NUGET_HOME") @@ -148,12 +186,12 @@ public class Packages }; var coreLibrariesFiles = coreLibraries.Select((lib) => { - return (FilePath)context.File(lib[0] + lib[1] + "/bin/" + parameters.DirSuffix + "/netstandard1.1/" + lib[1] + lib[2]); + return (FilePath)context.File(lib[0] + lib[1] + "/bin/" + parameters.DirSuffix + "/netstandard1.3/" + lib[1] + lib[2]); }).ToList(); var coreLibrariesNuSpecContent = coreLibrariesFiles.Select((file) => { return new NuSpecContent { - Source = file.FullPath, Target = "lib/netstandard1.1" + Source = file.FullPath, Target = "lib/netstandard1.3" }; }); @@ -193,13 +231,12 @@ public class Packages new NuGetPackSettings() { Id = "Avalonia", - Dependencies = new [] + Dependencies = new DependencyBuilder(this) { new NuSpecDependency() { Id = "Serilog", Version = SerilogVersion }, new NuSpecDependency() { Id = "Splat", Version = SplatVersion }, new NuSpecDependency() { Id = "Sprache", Version = SpracheVersion }, new NuSpecDependency() { Id = "System.Reactive", Version = SystemReactiveVersion }, - new NuSpecDependency() { Id = "System.ValueTuple", Version = SystemValueTupleVersion }, //.NET Core new NuSpecDependency() { Id = "System.Threading.ThreadPool", TargetFramework = "netcoreapp1.0", Version = "4.3.0" }, new NuSpecDependency() { Id = "Microsoft.Extensions.DependencyModel", TargetFramework = "netcoreapp1.0", Version = "1.1.0" }, @@ -208,8 +245,11 @@ public class Packages new NuSpecDependency() { Id = "Serilog", TargetFramework = "netcoreapp1.0", Version = SerilogVersion }, new NuSpecDependency() { Id = "Sprache", TargetFramework = "netcoreapp1.0", Version = SpracheVersion }, new NuSpecDependency() { Id = "System.Reactive", TargetFramework = "netcoreapp1.0", Version = SystemReactiveVersion }, - new NuSpecDependency() { Id = "System.ValueTuple", TargetFramework = "netcoreapp1.0", Version = SystemValueTupleVersion } - }, + } + .Deps(new string[]{null, "netcoreapp1.0"}, + "System.ValueTuple", "System.ComponentModel.TypeConverter", "System.ComponentModel.Primitives", + "System.Runtime.Serialization.Primitives", "System.Xml.XmlDocument", "System.Xml.ReaderWriter") + .ToArray(), Files = coreLibrariesNuSpecContent .Concat(win32CoreLibrariesNuSpecContent).Concat(net45RuntimePlatform) .Concat(netcoreappCoreLibrariesNuSpecContent).Concat(netCoreRuntimePlatform) @@ -229,9 +269,9 @@ public class Packages }, Files = new [] { - new NuSpecContent { Source = "Avalonia.HtmlRenderer.dll", Target = "lib/netstandard1.1" } + new NuSpecContent { Source = "Avalonia.HtmlRenderer.dll", Target = "lib/netstandard1.3" } }, - BasePath = context.Directory("./src/Avalonia.HtmlRenderer/bin/" + parameters.DirSuffix + "/netstandard1.1"), + BasePath = context.Directory("./src/Avalonia.HtmlRenderer/bin/" + parameters.DirSuffix + "/netstandard1.3"), OutputDirectory = parameters.NugetRoot } }; @@ -345,7 +385,7 @@ public class Packages Files = new [] { new NuSpecContent { Source = "Avalonia.Win32/bin/" + parameters.DirSuffix + "/Avalonia.Win32.dll", Target = "lib/net45" }, - new NuSpecContent { Source = "Avalonia.Win32.NetStandard/bin/" + parameters.DirSuffix + "/netstandard1.1/Avalonia.Win32.dll", Target = "lib/netstandard1.1" } + new NuSpecContent { Source = "Avalonia.Win32.NetStandard/bin/" + parameters.DirSuffix + "/netstandard1.3/Avalonia.Win32.dll", Target = "lib/netstandard1.3" } }, BasePath = context.Directory("./src/Windows"), OutputDirectory = parameters.NugetRoot @@ -366,9 +406,9 @@ public class Packages }, Files = new [] { - new NuSpecContent { Source = "Avalonia.Direct2D1.dll", Target = "lib/net45" } + new NuSpecContent { Source = "Avalonia.Direct2D1.dll", Target = "lib/netstandard1.3" } }, - BasePath = context.Directory("./src/Windows/Avalonia.Direct2D1/bin/" + parameters.DirSuffix), + BasePath = context.Directory("./src/Windows/Avalonia.Direct2D1/bin/" + parameters.DirSuffix + "/netstandard1.3"), OutputDirectory = parameters.NugetRoot }, /////////////////////////////////////////////////////////////////////////////// @@ -400,9 +440,9 @@ public class Packages }, Files = new [] { - new NuSpecContent { Source = "Avalonia.Gtk3.dll", Target = "lib/netstandard1.1" } + new NuSpecContent { Source = "Avalonia.Gtk3.dll", Target = "lib/netstandard1.3" } }, - BasePath = context.Directory("./src/Gtk/Avalonia.Gtk3/bin/" + parameters.DirSuffix + "/netstandard1.1"), + BasePath = context.Directory("./src/Gtk/Avalonia.Gtk3/bin/" + parameters.DirSuffix + "/netstandard1.3"), OutputDirectory = parameters.NugetRoot }, /////////////////////////////////////////////////////////////////////////////// @@ -458,9 +498,9 @@ public class Packages new NuSpecDependency() { Id = "Avalonia.Skia.Desktop", TargetFramework="net45", Version = parameters.Version }, new NuSpecDependency() { Id = "Avalonia.Gtk3", TargetFramework="net45", Version = parameters.Version }, //.NET Core - new NuSpecDependency() { Id = "Avalonia.Win32", TargetFramework="netcoreapp1.1", Version = parameters.Version }, - new NuSpecDependency() { Id = "Avalonia.Skia.Desktop", TargetFramework="netcoreapp1.1", Version = parameters.Version }, - new NuSpecDependency() { Id = "Avalonia.Gtk3", TargetFramework="netcoreapp1.1", Version = parameters.Version } + new NuSpecDependency() { Id = "Avalonia.Win32", TargetFramework="netcoreapp1.0", Version = parameters.Version }, + new NuSpecDependency() { Id = "Avalonia.Skia.Desktop", TargetFramework="netcoreapp1.0", Version = parameters.Version }, + new NuSpecDependency() { Id = "Avalonia.Gtk3", TargetFramework="netcoreapp1.0", Version = parameters.Version } }, Files = new NuSpecContent[] { @@ -476,6 +516,7 @@ public class Packages { new NuSpecDependency() { Id = "Avalonia.Win32", Version = parameters.Version }, new NuSpecDependency() { Id = "Avalonia.Direct2D1", Version = parameters.Version }, + new NuSpecDependency() { Id = "SharpDX.Direct3D9", Version = SharpDXDirect3D9Version }, }, Files = new [] { diff --git a/samples/BindingTest/App.config b/samples/BindingTest/App.config index d9f870f27b..373b3a13f8 100644 --- a/samples/BindingTest/App.config +++ b/samples/BindingTest/App.config @@ -1,21 +1,21 @@ - + - + - - + + - - + + - - + + diff --git a/samples/BindingTest/BindingTest.csproj b/samples/BindingTest/BindingTest.csproj index 1c4e4f8169..8e78b0c2cd 100644 --- a/samples/BindingTest/BindingTest.csproj +++ b/samples/BindingTest/BindingTest.csproj @@ -9,7 +9,7 @@ Properties BindingTest BindingTest - v4.5 + v4.6.1 512 true @@ -162,5 +162,4 @@ - \ No newline at end of file diff --git a/samples/BindingTest/MainWindow.xaml b/samples/BindingTest/MainWindow.xaml index 95f671fd84..7d633bcd0c 100644 --- a/samples/BindingTest/MainWindow.xaml +++ b/samples/BindingTest/MainWindow.xaml @@ -44,6 +44,8 @@ + + diff --git a/samples/BindingTest/ViewModels/MainWindowViewModel.cs b/samples/BindingTest/ViewModels/MainWindowViewModel.cs index 4b58bf2279..2ec052c258 100644 --- a/samples/BindingTest/ViewModels/MainWindowViewModel.cs +++ b/samples/BindingTest/ViewModels/MainWindowViewModel.cs @@ -49,6 +49,9 @@ namespace BindingTest.ViewModels Thread.Sleep(1000); } }); + + CurrentTimeObservable = Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(1)) + .Select(x => DateTimeOffset.Now.ToString()); } public ObservableCollection Items { get; } @@ -85,6 +88,7 @@ namespace BindingTest.ViewModels private set { this.RaiseAndSetIfChanged(ref _currentTime, value); } } + public IObservable CurrentTimeObservable { get; } public ReactiveCommand StringValueCommand { get; } public DataAnnotationsErrorViewModel DataAnnotationsValidation { get; } = new DataAnnotationsErrorViewModel(); diff --git a/samples/ControlCatalog.Android/ControlCatalog.Android.csproj b/samples/ControlCatalog.Android/ControlCatalog.Android.csproj index 4db67a8b60..71e3c4169c 100644 --- a/samples/ControlCatalog.Android/ControlCatalog.Android.csproj +++ b/samples/ControlCatalog.Android/ControlCatalog.Android.csproj @@ -158,5 +158,4 @@ - \ No newline at end of file diff --git a/samples/ControlCatalog.Desktop/App.config b/samples/ControlCatalog.Desktop/App.config index 10a06d8258..68403e421f 100644 --- a/samples/ControlCatalog.Desktop/App.config +++ b/samples/ControlCatalog.Desktop/App.config @@ -1,21 +1,21 @@ - + - + - - + + - - + + - - + + diff --git a/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj b/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj index e215105149..a3940a3a7d 100644 --- a/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj +++ b/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj @@ -9,7 +9,7 @@ Properties ControlCatalog.Desktop ControlCatalog.Desktop - v4.5 + v4.6.1 512 true @@ -144,5 +144,4 @@ - \ No newline at end of file diff --git a/samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj b/samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj index 01d287ea83..d0c73b2553 100644 --- a/samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj +++ b/samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj @@ -181,5 +181,4 @@ - \ No newline at end of file diff --git a/samples/ControlCatalog/ControlCatalog.csproj b/samples/ControlCatalog/ControlCatalog.csproj index 2a9f8f70de..3f978fa7f4 100644 --- a/samples/ControlCatalog/ControlCatalog.csproj +++ b/samples/ControlCatalog/ControlCatalog.csproj @@ -1,6 +1,6 @@  - netstandard1.1 + netstandard1.3 False false diff --git a/samples/ControlCatalog/MainWindow.xaml.cs b/samples/ControlCatalog/MainWindow.xaml.cs index c7c61e2b4e..413794dfa2 100644 --- a/samples/ControlCatalog/MainWindow.xaml.cs +++ b/samples/ControlCatalog/MainWindow.xaml.cs @@ -10,6 +10,7 @@ namespace ControlCatalog { this.InitializeComponent(); this.AttachDevTools(); + Renderer.DrawDirtyRects = Renderer.DrawFps = true; } private void InitializeComponent() diff --git a/samples/RenderTest/App.config b/samples/RenderTest/App.config index 10a06d8258..68403e421f 100644 --- a/samples/RenderTest/App.config +++ b/samples/RenderTest/App.config @@ -1,21 +1,21 @@ - + - + - - + + - - + + - - + + diff --git a/samples/RenderTest/RenderTest.csproj b/samples/RenderTest/RenderTest.csproj index cf32316086..95f1479b6b 100644 --- a/samples/RenderTest/RenderTest.csproj +++ b/samples/RenderTest/RenderTest.csproj @@ -9,7 +9,7 @@ Properties RenderTest RenderTest - v4.5 + v4.6.1 512 true @@ -183,5 +183,4 @@ - \ No newline at end of file diff --git a/samples/VirtualizationTest/App.config b/samples/VirtualizationTest/App.config index 10a06d8258..68403e421f 100644 --- a/samples/VirtualizationTest/App.config +++ b/samples/VirtualizationTest/App.config @@ -1,21 +1,21 @@ - + - + - - + + - - + + - - + + diff --git a/samples/VirtualizationTest/VirtualizationTest.csproj b/samples/VirtualizationTest/VirtualizationTest.csproj index 9b9d8a94c6..327e659966 100644 --- a/samples/VirtualizationTest/VirtualizationTest.csproj +++ b/samples/VirtualizationTest/VirtualizationTest.csproj @@ -9,7 +9,7 @@ Properties VirtualizationTest VirtualizationTest - v4.5 + v4.6.1 512 true @@ -158,5 +158,4 @@ - \ No newline at end of file diff --git a/samples/interop/Direct3DInteropSample/Direct3DInteropSample.csproj b/samples/interop/Direct3DInteropSample/Direct3DInteropSample.csproj index d90a251173..da230d34c6 100644 --- a/samples/interop/Direct3DInteropSample/Direct3DInteropSample.csproj +++ b/samples/interop/Direct3DInteropSample/Direct3DInteropSample.csproj @@ -4,8 +4,8 @@ net461 - - + + %(Filename) @@ -31,5 +31,4 @@ - \ No newline at end of file diff --git a/samples/interop/Direct3DInteropSample/Program.cs b/samples/interop/Direct3DInteropSample/Program.cs index 7fb650a7a8..d5de5ccb4e 100644 --- a/samples/interop/Direct3DInteropSample/Program.cs +++ b/samples/interop/Direct3DInteropSample/Program.cs @@ -11,7 +11,7 @@ namespace Direct3DInteropSample { static void Main(string[] args) { - AppBuilder.Configure().UseWin32().UseDirect2D1().Start(); + AppBuilder.Configure().UseWin32(deferredRendering: false).UseDirect2D1().Start(); } } } diff --git a/samples/interop/GtkInteropDemo/GtkInteropDemo.csproj b/samples/interop/GtkInteropDemo/GtkInteropDemo.csproj index d9a61064f1..56fa426f3c 100644 --- a/samples/interop/GtkInteropDemo/GtkInteropDemo.csproj +++ b/samples/interop/GtkInteropDemo/GtkInteropDemo.csproj @@ -9,7 +9,7 @@ Properties GtkInteropDemo GtkInteropDemo - v4.6 + v4.6.1 512 true @@ -151,5 +151,4 @@ - \ No newline at end of file diff --git a/samples/interop/WindowsInteropTest/Program.cs b/samples/interop/WindowsInteropTest/Program.cs index 4770688ecf..fac06d74b0 100644 --- a/samples/interop/WindowsInteropTest/Program.cs +++ b/samples/interop/WindowsInteropTest/Program.cs @@ -15,7 +15,7 @@ namespace WindowsInteropTest { System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); - AppBuilder.Configure().UseWin32().UseSkia().SetupWithoutStarting(); + AppBuilder.Configure().UseWin32().UseDirect2D1().SetupWithoutStarting(); System.Windows.Forms.Application.Run(new SelectorForm()); } } diff --git a/samples/interop/WindowsInteropTest/WindowsInteropTest.csproj b/samples/interop/WindowsInteropTest/WindowsInteropTest.csproj index 1aad43a0ea..2fa3ba30b9 100644 --- a/samples/interop/WindowsInteropTest/WindowsInteropTest.csproj +++ b/samples/interop/WindowsInteropTest/WindowsInteropTest.csproj @@ -9,7 +9,7 @@ Properties WindowsInteropTest WindowsInteropTest - v4.6 + v4.6.1 512 true @@ -186,5 +186,4 @@ - \ No newline at end of file diff --git a/src/Android/Avalonia.Android/AndroidPlatform.cs b/src/Android/Avalonia.Android/AndroidPlatform.cs index e9b4ad0a6d..7134e7d1b4 100644 --- a/src/Android/Avalonia.Android/AndroidPlatform.cs +++ b/src/Android/Avalonia.Android/AndroidPlatform.cs @@ -52,13 +52,11 @@ namespace Avalonia.Android .Bind().ToTransient() .Bind().ToSingleton() .Bind().ToConstant(Instance) - .Bind().ToConstant(ImmediateRenderer.Factory) .Bind().ToConstant(new AndroidThreadingInterface()) .Bind().ToTransient() .Bind().ToConstant(Instance) .Bind().ToSingleton() .Bind().ToConstant(new DefaultRenderLoop(60)) - .Bind().ToConstant(new AssetLoader(app.GetType().Assembly)); SkiaPlatform.Initialize(); diff --git a/src/Android/Avalonia.Android/Avalonia.Android.csproj b/src/Android/Avalonia.Android/Avalonia.Android.csproj index 4babdc8bff..091fdcc4b5 100644 --- a/src/Android/Avalonia.Android/Avalonia.Android.csproj +++ b/src/Android/Avalonia.Android/Avalonia.Android.csproj @@ -133,8 +133,4 @@ - - - $(MSBuildToolsPath)\Roslyn - \ No newline at end of file diff --git a/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs b/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs index 0c62eb9060..6c8db17c71 100644 --- a/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs +++ b/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs @@ -13,6 +13,7 @@ using System.Reactive.Disposables; using Avalonia.Android.Platform.Input; using Avalonia.Controls; using Avalonia.Controls.Platform.Surfaces; +using Avalonia.Rendering; namespace Avalonia.Android.Platform.SkiaPlatform { @@ -85,7 +86,12 @@ namespace Avalonia.Android.Platform.SkiaPlatform public IPlatformHandle Handle => _view; public IEnumerable Surfaces => new object[] {this}; - + + public IRenderer CreateRenderer(IRenderRoot root) + { + return new ImmediateRenderer(root); + } + public virtual void Hide() { _view.Visibility = ViewStates.Invisible; diff --git a/src/Android/Avalonia.AndroidTestApplication/Avalonia.AndroidTestApplication.csproj b/src/Android/Avalonia.AndroidTestApplication/Avalonia.AndroidTestApplication.csproj index 826f1f0132..87d1f67986 100644 --- a/src/Android/Avalonia.AndroidTestApplication/Avalonia.AndroidTestApplication.csproj +++ b/src/Android/Avalonia.AndroidTestApplication/Avalonia.AndroidTestApplication.csproj @@ -157,5 +157,4 @@ - \ No newline at end of file diff --git a/src/Avalonia.Animation/Avalonia.Animation.csproj b/src/Avalonia.Animation/Avalonia.Animation.csproj index f02ec2f31c..8f832dabcf 100644 --- a/src/Avalonia.Animation/Avalonia.Animation.csproj +++ b/src/Avalonia.Animation/Avalonia.Animation.csproj @@ -1,6 +1,6 @@  - netstandard1.1 + netstandard1.3 false diff --git a/src/Avalonia.Base/Avalonia.Base.csproj b/src/Avalonia.Base/Avalonia.Base.csproj index cc458545e2..e0d12ce262 100644 --- a/src/Avalonia.Base/Avalonia.Base.csproj +++ b/src/Avalonia.Base/Avalonia.Base.csproj @@ -1,6 +1,6 @@  - netstandard1.1 + netstandard1.3 false diff --git a/src/Avalonia.Base/Collections/AvaloniaList.cs b/src/Avalonia.Base/Collections/AvaloniaList.cs index ace898b55f..a3c3015a38 100644 --- a/src/Avalonia.Base/Collections/AvaloniaList.cs +++ b/src/Avalonia.Base/Collections/AvaloniaList.cs @@ -220,7 +220,7 @@ namespace Avalonia.Collections /// /// Removes all items from the collection. /// - public void Clear() + public virtual void Clear() { if (this.Count > 0) { diff --git a/src/Avalonia.Base/Metadata/AmbientAttribute.cs b/src/Avalonia.Base/Metadata/AmbientAttribute.cs new file mode 100644 index 0000000000..db36953300 --- /dev/null +++ b/src/Avalonia.Base/Metadata/AmbientAttribute.cs @@ -0,0 +1,15 @@ +// 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; + +namespace Avalonia.Metadata +{ + /// + /// Defines the ambient class/property + /// + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property, Inherited = true)] + public class AmbientAttribute : Attribute + { + } +} diff --git a/src/Avalonia.Base/Metadata/TemplateContent.cs b/src/Avalonia.Base/Metadata/TemplateContent.cs new file mode 100644 index 0000000000..ecc16b04a2 --- /dev/null +++ b/src/Avalonia.Base/Metadata/TemplateContent.cs @@ -0,0 +1,15 @@ +// 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; + +namespace Avalonia.Metadata +{ + /// + /// Defines the property that contains the object's content in markup. + /// + [AttributeUsage(AttributeTargets.Property)] + public class TemplateContentAttribute : Attribute + { + } +} diff --git a/src/Avalonia.Base/Utilities/WeakObservable.cs b/src/Avalonia.Base/Utilities/WeakObservable.cs index c261cc0520..b1fe78c206 100644 --- a/src/Avalonia.Base/Utilities/WeakObservable.cs +++ b/src/Avalonia.Base/Utilities/WeakObservable.cs @@ -16,12 +16,13 @@ namespace Avalonia.Utilities /// Converts a .NET event conforming to the standard .NET event pattern into an observable /// sequence, subscribing weakly. /// + /// The type of target. /// The type of the event args. /// Object instance that exposes the event to convert. /// Name of the event to convert. /// - public static IObservable> FromEventPattern( - object target, + public static IObservable> FromEventPattern( + TTarget target, string eventName) where TEventArgs : EventArgs { diff --git a/src/Avalonia.Base/Utilities/WeakSubscriptionManager.cs b/src/Avalonia.Base/Utilities/WeakSubscriptionManager.cs index 356be2ba31..f1e8fa6f9b 100644 --- a/src/Avalonia.Base/Utilities/WeakSubscriptionManager.cs +++ b/src/Avalonia.Base/Utilities/WeakSubscriptionManager.cs @@ -17,22 +17,23 @@ namespace Avalonia.Utilities /// /// Subscribes to an event on an object using a weak subscription. /// - /// The type of the event arguments. + /// The type of the target. + /// The type of the event arguments. /// The event source. /// The name of the event. /// The subscriber. - public static void Subscribe(object target, string eventName, IWeakSubscriber subscriber) - where T : EventArgs + public static void Subscribe(TTarget target, string eventName, IWeakSubscriber subscriber) + where TEventArgs : EventArgs { - var dic = SubscriptionTypeStorage.Subscribers.GetOrCreateValue(target); - Subscription sub; + var dic = SubscriptionTypeStorage.Subscribers.GetOrCreateValue(target); + Subscription sub; if (!dic.TryGetValue(eventName, out sub)) { - dic[eventName] = sub = new Subscription(dic, target, eventName); + dic[eventName] = sub = new Subscription(dic, typeof(TTarget), target, eventName); } - sub.Add(new WeakReference>(subscriber)); + sub.Add(new WeakReference>(subscriber)); } /// @@ -84,19 +85,18 @@ namespace Avalonia.Utilities private WeakReference>[] _data = new WeakReference>[16]; private int _count = 0; - public Subscription(SubscriptionDic sdic, object target, string eventName) + public Subscription(SubscriptionDic sdic, Type targetType, object target, string eventName) { _sdic = sdic; _target = target; _eventName = eventName; - var t = target.GetType(); Dictionary evDic; - if (!Accessors.TryGetValue(t, out evDic)) - Accessors[t] = evDic = new Dictionary(); + if (!Accessors.TryGetValue(targetType, out evDic)) + Accessors[targetType] = evDic = new Dictionary(); if (!evDic.TryGetValue(eventName, out _info)) { - var ev = t.GetRuntimeEvents().FirstOrDefault(x => x.Name == eventName); + var ev = targetType.GetRuntimeEvents().FirstOrDefault(x => x.Name == eventName); if (ev == null) { diff --git a/src/Avalonia.Controls/Avalonia.Controls.csproj b/src/Avalonia.Controls/Avalonia.Controls.csproj index 37f348340c..037546b186 100644 --- a/src/Avalonia.Controls/Avalonia.Controls.csproj +++ b/src/Avalonia.Controls/Avalonia.Controls.csproj @@ -1,6 +1,6 @@  - netstandard1.1 + netstandard1.3 false diff --git a/src/Avalonia.Controls/Classes.cs b/src/Avalonia.Controls/Classes.cs index 02fd6e63bf..c897e86697 100644 --- a/src/Avalonia.Controls/Classes.cs +++ b/src/Avalonia.Controls/Classes.cs @@ -86,6 +86,20 @@ namespace Avalonia.Controls base.AddRange(c); } + /// + /// Remvoes all non-pseudoclasses from the collection. + /// + public override void Clear() + { + for (var i = Count - 1; i >= 0; --i) + { + if (!this[i].StartsWith(":")) + { + RemoveAt(i); + } + } + } + /// /// Inserts a style class into the collection. /// diff --git a/src/Avalonia.Controls/Control.cs b/src/Avalonia.Controls/Control.cs index 83a76cb1a7..eca5967a58 100644 --- a/src/Avalonia.Controls/Control.cs +++ b/src/Avalonia.Controls/Control.cs @@ -355,18 +355,28 @@ namespace Avalonia.Controls if (--_initCount == 0 && _isAttachedToLogicalTree) { - if (!_styled) - { - RegisterWithNameScope(); - ApplyStyling(); - _styled = true; - } + InitializeStylesIfNeeded(); - if (!IsInitialized) - { - IsInitialized = true; - Initialized?.Invoke(this, EventArgs.Empty); - } + InitializeIfNeeded(); + } + } + + private void InitializeStylesIfNeeded(bool force = false) + { + if (_initCount == 0 && (!_styled || force)) + { + RegisterWithNameScope(); + ApplyStyling(); + _styled = true; + } + } + + private void InitializeIfNeeded() + { + if (_initCount == 0 && !IsInitialized) + { + IsInitialized = true; + Initialized?.Invoke(this, EventArgs.Empty); } } @@ -580,11 +590,7 @@ namespace Avalonia.Controls { base.OnAttachedToVisualTreeCore(e); - if (!IsInitialized) - { - IsInitialized = true; - Initialized?.Invoke(this, EventArgs.Empty); - } + InitializeIfNeeded(); } /// @@ -752,12 +758,7 @@ namespace Avalonia.Controls { _isAttachedToLogicalTree = true; - if (_initCount == 0) - { - RegisterWithNameScope(); - ApplyStyling(); - _styled = true; - } + InitializeStylesIfNeeded(true); OnAttachedToLogicalTree(e); } diff --git a/src/Avalonia.Controls/Panel.cs b/src/Avalonia.Controls/Panel.cs index 793399841c..3272d3779b 100644 --- a/src/Avalonia.Controls/Panel.cs +++ b/src/Avalonia.Controls/Panel.cs @@ -64,9 +64,12 @@ namespace Avalonia.Controls { Contract.Requires(value != null); - VisualChildren.Clear(); - _children.Clear(); - _children.AddRange(value); + if (_children != value) + { + VisualChildren.Clear(); + _children.Clear(); + _children.AddRange(value); + } } } diff --git a/src/Avalonia.Controls/Platform/ITopLevelImpl.cs b/src/Avalonia.Controls/Platform/ITopLevelImpl.cs index ba3ecb99c5..60e25d2be6 100644 --- a/src/Avalonia.Controls/Platform/ITopLevelImpl.cs +++ b/src/Avalonia.Controls/Platform/ITopLevelImpl.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using Avalonia.Input; using Avalonia.Input.Raw; +using Avalonia.Rendering; using JetBrains.Annotations; namespace Avalonia.Platform @@ -60,6 +61,12 @@ namespace Avalonia.Platform /// Action ScalingChanged { get; set; } + /// + /// Creates a new renderer for the toplevel. + /// + /// The toplevel. + IRenderer CreateRenderer(IRenderRoot root); + /// /// Invalidates a rect on the toplevel. /// diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs index d2e8085d8c..92ab12f82e 100644 --- a/src/Avalonia.Controls/TextBox.cs +++ b/src/Avalonia.Controls/TextBox.cs @@ -236,6 +236,11 @@ namespace Avalonia.Controls { _presenter = e.NameScope.Get("PART_TextPresenter"); _presenter.Cursor = new Cursor(StandardCursorType.Ibeam); + + if(IsFocused) + { + _presenter.ShowCaret(); + } } protected override void OnGotFocus(GotFocusEventArgs e) @@ -254,7 +259,7 @@ namespace Avalonia.Controls } else { - _presenter.ShowCaret(); + _presenter?.ShowCaret(); } } @@ -263,7 +268,7 @@ namespace Avalonia.Controls base.OnLostFocus(e); SelectionStart = 0; SelectionEnd = 0; - _presenter.HideCaret(); + _presenter?.HideCaret(); } protected override void OnTextInput(TextInputEventArgs e) diff --git a/src/Avalonia.Controls/ToolTip.cs b/src/Avalonia.Controls/ToolTip.cs index 22bc589a36..e1b69637af 100644 --- a/src/Avalonia.Controls/ToolTip.cs +++ b/src/Avalonia.Controls/ToolTip.cs @@ -106,24 +106,28 @@ namespace Avalonia.Controls if (control != null && control.IsVisible && control.GetVisualRoot() != null) { var cp = (control.GetVisualRoot() as IInputRoot)?.MouseDevice?.GetPosition(control); - var position = control.PointToScreen(cp ?? new Point(0, 0)) + new Vector(0, 22); - if (s_popup == null) + if (cp.HasValue && control.IsVisible && new Rect(control.Bounds.Size).Contains(cp.Value)) { - s_popup = new PopupRoot(); - s_popup.Content = new ToolTip(); - } - else - { - ((ISetLogicalParent)s_popup).SetParent(null); - } + var position = control.PointToScreen(cp.Value) + new Vector(0, 22); + + if (s_popup == null) + { + s_popup = new PopupRoot(); + s_popup.Content = new ToolTip(); + } + else + { + ((ISetLogicalParent)s_popup).SetParent(null); + } ((ISetLogicalParent)s_popup).SetParent(control); - ((ToolTip)s_popup.Content).Content = GetTip(control); - s_popup.Position = position; - s_popup.Show(); + ((ToolTip)s_popup.Content).Content = GetTip(control); + s_popup.Position = position; + s_popup.Show(); - s_current = control; + s_current = control; + } } } diff --git a/src/Avalonia.Controls/TopLevel.cs b/src/Avalonia.Controls/TopLevel.cs index a0a8f6b27e..f8db0e2a5b 100644 --- a/src/Avalonia.Controls/TopLevel.cs +++ b/src/Avalonia.Controls/TopLevel.cs @@ -90,8 +90,7 @@ namespace Avalonia.Controls _renderInterface = TryGetService(dependencyResolver); var renderLoop = TryGetService(dependencyResolver); - var rendererFactory = TryGetService(dependencyResolver); - Renderer = rendererFactory?.CreateRenderer(this, renderLoop); + Renderer = impl.CreateRenderer(this); impl.SetInputRoot(this); @@ -181,6 +180,9 @@ namespace Avalonia.Controls /// double ILayoutRoot.LayoutScaling => PlatformImpl?.Scaling ?? 1; + /// + double IRenderRoot.RenderScaling => PlatformImpl?.Scaling ?? 1; + IStyleHost IStyleHost.StylingParent { get { return AvaloniaLocator.Current.GetService(); } diff --git a/src/Avalonia.Controls/Window.cs b/src/Avalonia.Controls/Window.cs index a94609122a..9f0bb82b29 100644 --- a/src/Avalonia.Controls/Window.cs +++ b/src/Avalonia.Controls/Window.cs @@ -244,8 +244,14 @@ namespace Avalonia.Controls /// public override void Hide() { + if (!IsVisible) + { + return; + } + using (BeginAutoSizing()) { + Renderer?.Stop(); PlatformImpl?.Hide(); } @@ -272,6 +278,7 @@ namespace Avalonia.Controls using (BeginAutoSizing()) { PlatformImpl?.Show(); + Renderer?.Start(); } } @@ -318,6 +325,8 @@ namespace Avalonia.Controls var modal = PlatformImpl?.ShowDialog(); var result = new TaskCompletionSource(); + Renderer?.Start(); + Observable.FromEventPattern( x => this.Closed += x, x => this.Closed -= x) diff --git a/src/Avalonia.Controls/WindowBase.cs b/src/Avalonia.Controls/WindowBase.cs index 73d6d8c7cc..50068d280d 100644 --- a/src/Avalonia.Controls/WindowBase.cs +++ b/src/Avalonia.Controls/WindowBase.cs @@ -136,6 +136,7 @@ namespace Avalonia.Controls try { + Renderer?.Stop(); PlatformImpl?.Hide(); IsVisible = false; } @@ -164,6 +165,7 @@ namespace Avalonia.Controls } PlatformImpl?.Show(); + Renderer?.Start(); } finally { diff --git a/src/Avalonia.DesignerSupport/Avalonia.DesignerSupport.csproj b/src/Avalonia.DesignerSupport/Avalonia.DesignerSupport.csproj index be0b98b24c..a68e8760f2 100644 --- a/src/Avalonia.DesignerSupport/Avalonia.DesignerSupport.csproj +++ b/src/Avalonia.DesignerSupport/Avalonia.DesignerSupport.csproj @@ -1,6 +1,6 @@  - netstandard1.1 + netstandard1.3 false diff --git a/src/Avalonia.DesignerSupport/DesignerAssist.cs b/src/Avalonia.DesignerSupport/DesignerAssist.cs index 8d30f3cf25..2f5fc79147 100644 --- a/src/Avalonia.DesignerSupport/DesignerAssist.cs +++ b/src/Avalonia.DesignerSupport/DesignerAssist.cs @@ -5,8 +5,6 @@ using System.IO; using System.Linq; using System.Reflection; using System.Text; -using OmniXaml; -using OmniXaml.ObjectAssembler; using Avalonia.Controls; using Avalonia.Controls.Platform; using Avalonia.Markup.Xaml; diff --git a/src/Avalonia.Diagnostics/Avalonia.Diagnostics.csproj b/src/Avalonia.Diagnostics/Avalonia.Diagnostics.csproj index e4752f6662..be3f397283 100644 --- a/src/Avalonia.Diagnostics/Avalonia.Diagnostics.csproj +++ b/src/Avalonia.Diagnostics/Avalonia.Diagnostics.csproj @@ -1,6 +1,6 @@  - netstandard1.1 + netstandard1.3 false diff --git a/src/Avalonia.DotNetFrameworkRuntime/Avalonia.DotNetFrameworkRuntime.csproj b/src/Avalonia.DotNetFrameworkRuntime/Avalonia.DotNetFrameworkRuntime.csproj index b475c4b3ff..2fbcba40c8 100644 --- a/src/Avalonia.DotNetFrameworkRuntime/Avalonia.DotNetFrameworkRuntime.csproj +++ b/src/Avalonia.DotNetFrameworkRuntime/Avalonia.DotNetFrameworkRuntime.csproj @@ -9,7 +9,7 @@ Properties Avalonia.DotNetFrameworkRuntime Avalonia.DotNetFrameworkRuntime - v4.5 + v4.6.1 512 @@ -69,5 +69,4 @@ - \ No newline at end of file diff --git a/src/Avalonia.HtmlRenderer/Avalonia.HtmlRenderer.csproj b/src/Avalonia.HtmlRenderer/Avalonia.HtmlRenderer.csproj index b1fc7a4278..f715217e42 100644 --- a/src/Avalonia.HtmlRenderer/Avalonia.HtmlRenderer.csproj +++ b/src/Avalonia.HtmlRenderer/Avalonia.HtmlRenderer.csproj @@ -1,6 +1,6 @@  - netstandard1.1 + netstandard1.3 False False false diff --git a/src/Avalonia.Input/Avalonia.Input.csproj b/src/Avalonia.Input/Avalonia.Input.csproj index e9e74e24fe..b5482ebce1 100644 --- a/src/Avalonia.Input/Avalonia.Input.csproj +++ b/src/Avalonia.Input/Avalonia.Input.csproj @@ -1,6 +1,6 @@  - netstandard1.1 + netstandard1.3 false diff --git a/src/Avalonia.Interactivity/Avalonia.Interactivity.csproj b/src/Avalonia.Interactivity/Avalonia.Interactivity.csproj index ab9ab88a37..9d22de86b3 100644 --- a/src/Avalonia.Interactivity/Avalonia.Interactivity.csproj +++ b/src/Avalonia.Interactivity/Avalonia.Interactivity.csproj @@ -1,6 +1,6 @@  - netstandard1.1 + netstandard1.3 false diff --git a/src/Avalonia.Layout/Avalonia.Layout.csproj b/src/Avalonia.Layout/Avalonia.Layout.csproj index 45a40d2fd4..d0260391d8 100644 --- a/src/Avalonia.Layout/Avalonia.Layout.csproj +++ b/src/Avalonia.Layout/Avalonia.Layout.csproj @@ -1,6 +1,6 @@  - netstandard1.1 + netstandard1.3 false diff --git a/src/Avalonia.Logging.Serilog/Avalonia.Logging.Serilog.csproj b/src/Avalonia.Logging.Serilog/Avalonia.Logging.Serilog.csproj index 9aa81c19f9..508ede7f7d 100644 --- a/src/Avalonia.Logging.Serilog/Avalonia.Logging.Serilog.csproj +++ b/src/Avalonia.Logging.Serilog/Avalonia.Logging.Serilog.csproj @@ -1,6 +1,6 @@  - netstandard1.1 + netstandard1.3 false diff --git a/src/Avalonia.ReactiveUI/Avalonia.ReactiveUI.csproj b/src/Avalonia.ReactiveUI/Avalonia.ReactiveUI.csproj index 28522d8849..2d66b62eab 100644 --- a/src/Avalonia.ReactiveUI/Avalonia.ReactiveUI.csproj +++ b/src/Avalonia.ReactiveUI/Avalonia.ReactiveUI.csproj @@ -1,6 +1,6 @@  - netstandard1.1 + netstandard1.3 False false diff --git a/src/Avalonia.Styling/Avalonia.Styling.csproj b/src/Avalonia.Styling/Avalonia.Styling.csproj index 5965645391..6bf37b522b 100644 --- a/src/Avalonia.Styling/Avalonia.Styling.csproj +++ b/src/Avalonia.Styling/Avalonia.Styling.csproj @@ -1,6 +1,6 @@  - netstandard1.1 + netstandard1.3 false diff --git a/src/Avalonia.Styling/Styling/Style.cs b/src/Avalonia.Styling/Styling/Style.cs index c050ff0e75..3dfd9118af 100644 --- a/src/Avalonia.Styling/Styling/Style.cs +++ b/src/Avalonia.Styling/Styling/Style.cs @@ -13,10 +13,10 @@ namespace Avalonia.Styling /// public class Style : IStyle { - private static Dictionary> _applied = + private static Dictionary> _applied = new Dictionary>(); - private Dictionary _resources; + private StyleResources _resources; /// /// Initializes a new instance of the class. @@ -37,13 +37,13 @@ namespace Avalonia.Styling /// /// Gets or sets a dictionary of style resources. /// - public IDictionary Resources + public StyleResources Resources { get { if (_resources == null) { - _resources = new Dictionary(); + _resources = new StyleResources(); } return _resources; @@ -51,11 +51,16 @@ namespace Avalonia.Styling set { + var resources = Resources; - - foreach (var i in value) + if (!Equals(resources, value)) { - resources.Add(i); + foreach (var i in value) + { + resources[i.Key] = i.Value; + //resources.Add(i.Key, i.Value); + //(resources as IDictionary).Add(i); + } } } } @@ -69,7 +74,7 @@ namespace Avalonia.Styling /// Gets or sets the style's setters. /// [Content] - public IEnumerable Setters { get; set; } = new List(); + public IList Setters { get; set; } = new List(); /// /// Attaches the style to a control if the style's selector matches. diff --git a/src/Avalonia.Styling/Styling/StyleResources.cs b/src/Avalonia.Styling/Styling/StyleResources.cs new file mode 100644 index 0000000000..e447c6adfd --- /dev/null +++ b/src/Avalonia.Styling/Styling/StyleResources.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Avalonia.Styling +{ + /// + /// Holds resources for a . + /// + public class StyleResources : IDictionary, IDictionary + { + private Dictionary _inner = new Dictionary(); + + public object this[string key] + { + get { return _inner[key]; } + set { _inner[key] = value; } + } + + public int Count => _inner.Count; + + ICollection IDictionary.Keys => _inner.Keys; + + ICollection IDictionary.Values => _inner.Values; + + bool ICollection>.IsReadOnly => false; + + object IDictionary.this[object key] + { + get { return ((IDictionary)_inner)[key]; } + set { ((IDictionary)_inner)[key] = value; } + } + + ICollection IDictionary.Keys => _inner.Keys; + + ICollection IDictionary.Values => _inner.Values; + + bool ICollection.IsSynchronized => false; + + object ICollection.SyncRoot => ((IDictionary)_inner).SyncRoot; + + bool IDictionary.IsFixedSize => false; + + bool IDictionary.IsReadOnly => false; + + public void Add(string key, object value) => _inner.Add(key, value); + + public void Clear() => _inner.Clear(); + + public bool ContainsKey(string key) => _inner.ContainsKey(key); + + public bool Remove(string key) => _inner.Remove(key); + + public IEnumerator> GetEnumerator() => _inner.GetEnumerator(); + + public bool TryGetValue(string key, out object value) => _inner.TryGetValue(key, out value); + + bool ICollection>.Contains(KeyValuePair item) + { + return ((IDictionary)_inner).Contains(item); + } + + void ICollection>.Add(KeyValuePair item) + { + ((IDictionary)_inner).Add(item); + } + + void ICollection>.CopyTo(KeyValuePair[] array, int arrayIndex) + { + ((IDictionary)_inner).CopyTo(array, arrayIndex); + } + + bool ICollection>.Remove(KeyValuePair item) + { + return ((IDictionary)_inner).Remove(item); + } + + void ICollection.CopyTo(Array array, int index) => ((IDictionary)_inner).CopyTo(array, index); + + IEnumerator IEnumerable.GetEnumerator() => _inner.GetEnumerator(); + + IDictionaryEnumerator IDictionary.GetEnumerator() => ((IDictionary)_inner).GetEnumerator(); + + void IDictionary.Add(object key, object value) => ((IDictionary)_inner).Add(key, value); + + bool IDictionary.Contains(object key) => ((IDictionary)_inner).Contains(key); + + void IDictionary.Remove(object key) => ((IDictionary)_inner).Remove(key); + } +} diff --git a/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj b/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj index be1d798e2d..4e980680d9 100644 --- a/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj +++ b/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj @@ -1,6 +1,6 @@  - netstandard1.1 + netstandard1.3 false diff --git a/src/Avalonia.Themes.Default/CheckBox.xaml b/src/Avalonia.Themes.Default/CheckBox.xaml index e88e93eac6..2fc19b2679 100644 --- a/src/Avalonia.Themes.Default/CheckBox.xaml +++ b/src/Avalonia.Themes.Default/CheckBox.xaml @@ -1,10 +1,11 @@ +"; + + var styles = AvaloniaXamlLoader.Parse(xaml); + + Assert.Equal(1, styles.Count); + + var style = (Style)styles[0]; + + var setters = style.Setters.Cast().ToArray(); + + Assert.Equal(2, setters.Length); + + Assert.Equal(TextBlock.BackgroundProperty, setters[0].Property); + Assert.Equal(Brushes.White.Color, ((ISolidColorBrush)setters[0].Value).Color); + + Assert.Equal(TextBlock.WidthProperty, setters[1].Property); + Assert.Equal(100.0, setters[1].Value); + } + + [Fact] + public void Style_Setter_With_AttachedProperty_Is_Parsed() + { + var xaml = @" + + +"; + + var styles = AvaloniaXamlLoader.Parse(xaml); + + Assert.Equal(1, styles.Count); + + var style = (Style)styles[0]; + + var setters = style.Setters.Cast().ToArray(); + + Assert.Equal(1, setters.Length); + + Assert.Equal(TextBlock.FontSizeProperty, setters[0].Property); + Assert.Equal(21.0, setters[0].Value); + } + + [Fact] + public void Complex_Style_Is_Parsed() + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var xaml = @" + + + +"; + var styles = AvaloniaXamlLoader.Parse(xaml); + + Assert.Equal(1, styles.Count); + + var style = (Style)styles[0]; + + var setters = style.Setters.Cast().ToArray(); + + Assert.Equal(3, setters.Length); + + Assert.Equal(CheckBox.BorderBrushProperty, setters[0].Property); + Assert.Equal(CheckBox.BorderThicknessProperty, setters[1].Property); + Assert.Equal(CheckBox.TemplateProperty, setters[2].Property); + + Assert.IsType(setters[0].Value); + Assert.IsType(setters[1].Value); + Assert.IsType(setters[2].Value); + } + } + + [Fact] + public void Style_Resources_Are_Built() + { + var xaml = @" +"; + + var style = AvaloniaXamlLoader.Parse "; + + var style = AvaloniaXamlLoader.Parse + + +"; + + + var window = AvaloniaXamlLoader.Parse(xaml); + var tracker = (InitializationOrderTracker)window.Content; + + //ensure binding is set and operational first + Assert.Equal(100.0, tracker.Tag); + + Assert.Equal("EndInit 0", tracker.Order.Last()); + } + } + + [Fact] + public void BeginInit_Matches_EndInit() + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var xaml = @" + + +"; + + var window = AvaloniaXamlLoader.Parse(xaml); + var tracker = (InitializationOrderTracker)window.Content; + + Assert.Equal(0, tracker.InitState); + } + } + + [Fact] + public void DeferedXamlLoader_Should_Preserve_NamespacesContext() + { + var xaml = +@" + + + + + +"; + + var contentControl = AvaloniaXamlLoader.Parse(xaml); + var template = contentControl.ContentTemplate; + + Assert.NotNull(template); + + var txt = (TextBlock)template.Build(null); + + Assert.Equal((object)NonControl.StringProperty, txt.Tag); + } + + [Fact] + public void Binding_To_List_AvaloniaProperty_Is_Operational() + { + using (UnitTestApplication.Start(TestServices.MockWindowingPlatform)) + { + var xaml = @" + + +"; + + var window = AvaloniaXamlLoader.Parse(xaml); + var listBox = (ListBox)window.Content; + + var vm = new SelectedItemsViewModel() + { + Items = new string[] { "foo", "bar", "baz" } + }; + + window.DataContext = vm; + + Assert.Equal(vm.Items, listBox.Items); + + Assert.Equal(vm.SelectedItems, listBox.SelectedItems); + } + } + + private class SelectedItemsViewModel : INotifyPropertyChanged + { + public string[] Items { get; set; } + + public event PropertyChangedEventHandler PropertyChanged; + + private IList _selectedItems = new AvaloniaList(); + + public IList SelectedItems + { + get { return _selectedItems; } + set + { + _selectedItems = value; + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(SelectedItems))); + } + } + } } -} +} \ No newline at end of file diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/Xaml/BindingTests.cs b/tests/Avalonia.Markup.Xaml.UnitTests/Xaml/BindingTests.cs index a66d6ac6d8..a44d09dee7 100644 --- a/tests/Avalonia.Markup.Xaml.UnitTests/Xaml/BindingTests.cs +++ b/tests/Avalonia.Markup.Xaml.UnitTests/Xaml/BindingTests.cs @@ -1,6 +1,7 @@ // 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.Reactive.Subjects; using Avalonia.Controls; using Avalonia.UnitTests; using Xunit; @@ -83,7 +84,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.Xaml [Fact] public void Can_Bind_To_DataContext_Of_Anchor_On_Non_Control() { - using (UnitTestApplication.Start(TestServices.StyledWindow)) + using (UnitTestApplication.Start(TestServices.MockWindowingPlatform)) { var xaml = @" "; - var loader = new AvaloniaXamlLoader(); - var window = (Window)loader.Load(xaml); + + var window = AvaloniaXamlLoader.Parse(xaml); var textBlock = (TextBlock)window.Content; - window.ApplyTemplate(); + textBlock.Tag = "foo"; Assert.Equal("foo", textBlock.Text); } @@ -169,7 +171,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.Xaml [Fact] public void Longform_Binding_To_Self_Works() { - using (UnitTestApplication.Start(TestServices.StyledWindow)) + using (UnitTestApplication.Start(TestServices.MockWindowingPlatform)) { var xaml = @" + +"; + var loader = new AvaloniaXamlLoader(); + var window = (Window)loader.Load(xaml); + var textBlock = (TextBlock)window.Content; + var observable = new BehaviorSubject("foo"); + + window.DataContext = new { Observable = observable }; + window.ApplyTemplate(); + + Assert.Equal("foo", textBlock.Text); + observable.OnNext("bar"); + Assert.Equal("bar", textBlock.Text); + } + } } -} +} \ No newline at end of file diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/Xaml/BindingTests_RelativeSource.cs b/tests/Avalonia.Markup.Xaml.UnitTests/Xaml/BindingTests_RelativeSource.cs new file mode 100644 index 0000000000..9125e1e643 --- /dev/null +++ b/tests/Avalonia.Markup.Xaml.UnitTests/Xaml/BindingTests_RelativeSource.cs @@ -0,0 +1,129 @@ +// 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 Avalonia.Controls; +using Avalonia.UnitTests; +using Xunit; + +namespace Avalonia.Markup.Xaml.UnitTests.Xaml +{ + public class BindingTests_RelativeSource + { + [Fact] + public void Binding_To_DataContext_Works() + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var xaml = @" + +