From 321bd156647e959ad5f3089b2d00ba9a8cafe094 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Sat, 15 Sep 2018 15:01:02 -0500 Subject: [PATCH] Merge desktop runtime support libraries. Fixes #1899. --- .gitignore | 4 -- build/Avalonia.csproj | 13 ----- build/CoreLibraries.props | 3 +- build/SampleApp.props | 7 +-- .../Avalonia.Desktop/Avalonia.Desktop.csproj | 13 +++++ packages/Avalonia/Avalonia.csproj | 13 +++++ samples/BindingDemo/App.config | 22 ------- samples/ControlCatalog.Desktop/App.config | 22 ------- .../ControlCatalog.NetCore.csproj | 3 + samples/ControlCatalog/App.config | 22 ------- samples/ControlCatalog/ControlCatalog.csproj | 14 +---- samples/Previewer/Previewer.csproj | 2 + samples/RemoteDemo/RemoteDemo.csproj | 1 + samples/interop/WindowsInteropTest/App.config | 18 ------ .../WindowsInteropTest.csproj | 6 +- .../AppBuilder.cs | 0 .../Avalonia.DesktopRuntime.csproj | 16 +++++ .../RuntimeInfo.cs | 5 +- src/Avalonia.DotNetCoreRuntime/AppBuilder.cs | 58 ------------------- .../Avalonia.DotNetCoreRuntime.csproj | 19 ------ .../Avalonia.DotNetFrameworkRuntime.csproj | 18 ------ .../RuntimeInfo.cs | 44 -------------- .../Avalonia.ReactiveUI.csproj | 2 +- src/Gtk/Avalonia.Gtk3/Avalonia.Gtk3.csproj | 1 + .../Avalonia.LinuxFramebuffer.csproj | 3 +- .../StandardRuntimePlatform.cs | 2 +- src/Skia/Avalonia.Skia/Avalonia.Skia.csproj | 1 + .../Avalonia.Direct2D1.csproj | 2 +- .../Avalonia.Win32.Interop.csproj | 2 +- .../Avalonia.Win32/Avalonia.Win32.csproj | 1 + src/iOS/Avalonia.iOS/Avalonia.iOS.csproj | 2 +- .../Avalonia.DesignerSupport.TestApp.csproj | 8 +-- .../Avalonia.Direct2D1.RenderTests.csproj | 4 +- .../Avalonia.Skia.RenderTests.csproj | 4 +- 34 files changed, 74 insertions(+), 281 deletions(-) delete mode 100644 build/Avalonia.csproj create mode 100644 packages/Avalonia.Desktop/Avalonia.Desktop.csproj create mode 100644 packages/Avalonia/Avalonia.csproj delete mode 100644 samples/BindingDemo/App.config delete mode 100644 samples/ControlCatalog.Desktop/App.config delete mode 100644 samples/ControlCatalog/App.config delete mode 100644 samples/interop/WindowsInteropTest/App.config rename src/{Avalonia.DotNetFrameworkRuntime => Avalonia.DesktopRuntime}/AppBuilder.cs (100%) create mode 100644 src/Avalonia.DesktopRuntime/Avalonia.DesktopRuntime.csproj rename src/{Avalonia.DotNetCoreRuntime => Avalonia.DesktopRuntime}/RuntimeInfo.cs (97%) delete mode 100644 src/Avalonia.DotNetCoreRuntime/AppBuilder.cs delete mode 100644 src/Avalonia.DotNetCoreRuntime/Avalonia.DotNetCoreRuntime.csproj delete mode 100644 src/Avalonia.DotNetFrameworkRuntime/Avalonia.DotNetFrameworkRuntime.csproj delete mode 100644 src/Avalonia.DotNetFrameworkRuntime/RuntimeInfo.cs diff --git a/.gitignore b/.gitignore index 5917c0f2ba..c5f28a6c1a 100644 --- a/.gitignore +++ b/.gitignore @@ -94,10 +94,6 @@ publish/ *.Publish.xml *.pubxml -# NuGet Packages Directory -## TODO: If you have NuGet Package Restore enabled, uncomment the next line -packages/ - # Windows Azure Build Output csx *.build.csdef diff --git a/build/Avalonia.csproj b/build/Avalonia.csproj deleted file mode 100644 index 94071f3fa3..0000000000 --- a/build/Avalonia.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - netstandard2.0;net461;netcoreapp2.0 - - - - - - - - - - diff --git a/build/CoreLibraries.props b/build/CoreLibraries.props index 154ae5db0b..4a69998784 100644 --- a/build/CoreLibraries.props +++ b/build/CoreLibraries.props @@ -14,7 +14,6 @@ - - + diff --git a/build/SampleApp.props b/build/SampleApp.props index 3b538e4029..2269cd5713 100644 --- a/build/SampleApp.props +++ b/build/SampleApp.props @@ -2,12 +2,7 @@ WinExe - - - - + - diff --git a/packages/Avalonia.Desktop/Avalonia.Desktop.csproj b/packages/Avalonia.Desktop/Avalonia.Desktop.csproj new file mode 100644 index 0000000000..615237b162 --- /dev/null +++ b/packages/Avalonia.Desktop/Avalonia.Desktop.csproj @@ -0,0 +1,13 @@ + + + netstandard2.0 + + + + + + + + + + diff --git a/packages/Avalonia/Avalonia.csproj b/packages/Avalonia/Avalonia.csproj new file mode 100644 index 0000000000..c075c317f3 --- /dev/null +++ b/packages/Avalonia/Avalonia.csproj @@ -0,0 +1,13 @@ + + + netstandard2.0;net461;netcoreapp2.0 + + + + + + + + + + diff --git a/samples/BindingDemo/App.config b/samples/BindingDemo/App.config deleted file mode 100644 index 538be69997..0000000000 --- a/samples/BindingDemo/App.config +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/ControlCatalog.Desktop/App.config b/samples/ControlCatalog.Desktop/App.config deleted file mode 100644 index cd4593817b..0000000000 --- a/samples/ControlCatalog.Desktop/App.config +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj b/samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj index ce061eabea..57619b8a67 100644 --- a/samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj +++ b/samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj @@ -8,7 +8,10 @@ + + + diff --git a/samples/ControlCatalog/App.config b/samples/ControlCatalog/App.config deleted file mode 100644 index 0c47592f2c..0000000000 --- a/samples/ControlCatalog/App.config +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/ControlCatalog/ControlCatalog.csproj b/samples/ControlCatalog/ControlCatalog.csproj index eb37c7856b..d0a746f87d 100644 --- a/samples/ControlCatalog/ControlCatalog.csproj +++ b/samples/ControlCatalog/ControlCatalog.csproj @@ -19,19 +19,7 @@ - - + diff --git a/samples/Previewer/Previewer.csproj b/samples/Previewer/Previewer.csproj index 0dbd87bf6d..2cdde0c945 100644 --- a/samples/Previewer/Previewer.csproj +++ b/samples/Previewer/Previewer.csproj @@ -10,5 +10,7 @@ + + diff --git a/samples/RemoteDemo/RemoteDemo.csproj b/samples/RemoteDemo/RemoteDemo.csproj index 653395f539..046999e06e 100644 --- a/samples/RemoteDemo/RemoteDemo.csproj +++ b/samples/RemoteDemo/RemoteDemo.csproj @@ -8,6 +8,7 @@ + diff --git a/samples/interop/WindowsInteropTest/App.config b/samples/interop/WindowsInteropTest/App.config deleted file mode 100644 index 4fe7131d2a..0000000000 --- a/samples/interop/WindowsInteropTest/App.config +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/interop/WindowsInteropTest/WindowsInteropTest.csproj b/samples/interop/WindowsInteropTest/WindowsInteropTest.csproj index 66a92bb9d6..1915ab276e 100644 --- a/samples/interop/WindowsInteropTest/WindowsInteropTest.csproj +++ b/samples/interop/WindowsInteropTest/WindowsInteropTest.csproj @@ -116,9 +116,9 @@ {7062ae20-5dcc-4442-9645-8195bdece63e} Avalonia.Diagnostics - + {4a1abb09-9047-4bd5-a4ad-a055e52c5ee0} - Avalonia.DotNetFrameworkRuntime + Avalonia.DesktopRuntime {62024b2d-53eb-4638-b26b-85eeaa54866e} @@ -186,4 +186,4 @@ - \ No newline at end of file + diff --git a/src/Avalonia.DotNetFrameworkRuntime/AppBuilder.cs b/src/Avalonia.DesktopRuntime/AppBuilder.cs similarity index 100% rename from src/Avalonia.DotNetFrameworkRuntime/AppBuilder.cs rename to src/Avalonia.DesktopRuntime/AppBuilder.cs diff --git a/src/Avalonia.DesktopRuntime/Avalonia.DesktopRuntime.csproj b/src/Avalonia.DesktopRuntime/Avalonia.DesktopRuntime.csproj new file mode 100644 index 0000000000..65c4bcb4a2 --- /dev/null +++ b/src/Avalonia.DesktopRuntime/Avalonia.DesktopRuntime.csproj @@ -0,0 +1,16 @@ + + + + net461;netcoreapp2.0 + false + + + + + + + + + + + diff --git a/src/Avalonia.DotNetCoreRuntime/RuntimeInfo.cs b/src/Avalonia.DesktopRuntime/RuntimeInfo.cs similarity index 97% rename from src/Avalonia.DotNetCoreRuntime/RuntimeInfo.cs rename to src/Avalonia.DesktopRuntime/RuntimeInfo.cs index 0e70f09296..82eaadb895 100644 --- a/src/Avalonia.DotNetCoreRuntime/RuntimeInfo.cs +++ b/src/Avalonia.DesktopRuntime/RuntimeInfo.cs @@ -21,9 +21,12 @@ namespace Avalonia.Shared.PlatformSupport return new RuntimePlatformInfo { +#if NETCOREAPP2_0 IsCoreClr = true, - IsDesktop = true, +#elif NET461 IsDotNetFramework = false, +#endif + IsDesktop = true, IsMono = false, IsMobile = false, IsUnix = os != OperatingSystemType.WinNT, diff --git a/src/Avalonia.DotNetCoreRuntime/AppBuilder.cs b/src/Avalonia.DotNetCoreRuntime/AppBuilder.cs deleted file mode 100644 index 87f8a8de8d..0000000000 --- a/src/Avalonia.DotNetCoreRuntime/AppBuilder.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Reflection; -using Avalonia.Controls; -using Avalonia.Platform; -using Avalonia.Shared.PlatformSupport; - -namespace Avalonia -{ - /// - /// Initializes platform-specific services for an . - /// - public sealed class AppBuilder : AppBuilderBase - { - /// - /// Initializes a new instance of the class. - /// - public AppBuilder() - : base(new StandardRuntimePlatform(), - builder => StandardRuntimePlatformServices.Register(builder.Instance?.GetType() - ?.GetTypeInfo().Assembly)) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The instance. - public AppBuilder(Application app) : this() - { - Instance = app; - } - - /// - /// Instructs the to use the best settings for the platform. - /// - /// An instance. - public AppBuilder UsePlatformDetect() - { - var os = RuntimePlatform.GetRuntimeInfo().OperatingSystem; - //We don't have the ability to load every assembly right now, so we are - //stuck with manual configuration here - //Helpers are extracted to separate methods to take the advantage of the fact - //that CLR doesn't try to load dependencies before referencing method is jitted - if (os == OperatingSystemType.WinNT) - LoadWin32(); - else if(os==OperatingSystemType.OSX) - LoadAvaloniaNative(); - else - LoadGtk3(); - this.UseSkia(); - - return this; - } - - void LoadAvaloniaNative() => this.UseAvaloniaNative(); - void LoadWin32() => this.UseWin32(); - void LoadGtk3() => this.UseGtk3(); - } -} diff --git a/src/Avalonia.DotNetCoreRuntime/Avalonia.DotNetCoreRuntime.csproj b/src/Avalonia.DotNetCoreRuntime/Avalonia.DotNetCoreRuntime.csproj deleted file mode 100644 index 4f775b7381..0000000000 --- a/src/Avalonia.DotNetCoreRuntime/Avalonia.DotNetCoreRuntime.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - netcoreapp2.0 - $(DefineConstants);DOTNETCORE - false - - - - - - - - - - - - - - diff --git a/src/Avalonia.DotNetFrameworkRuntime/Avalonia.DotNetFrameworkRuntime.csproj b/src/Avalonia.DotNetFrameworkRuntime/Avalonia.DotNetFrameworkRuntime.csproj deleted file mode 100644 index 8d9b36bea3..0000000000 --- a/src/Avalonia.DotNetFrameworkRuntime/Avalonia.DotNetFrameworkRuntime.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - netcoreapp2.0;net461 - bin\$(Configuration)\Avalonia.DotNetFrameworkRuntime.xml - $(DefineConstants);FULLDOTNET - true - false - - - - - - - - - - - diff --git a/src/Avalonia.DotNetFrameworkRuntime/RuntimeInfo.cs b/src/Avalonia.DotNetFrameworkRuntime/RuntimeInfo.cs deleted file mode 100644 index 41545a146f..0000000000 --- a/src/Avalonia.DotNetFrameworkRuntime/RuntimeInfo.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using Avalonia.Platform; - -namespace Avalonia.Shared.PlatformSupport -{ - internal partial class StandardRuntimePlatform - { - private static readonly Lazy Info = new Lazy(() => - { - var isMono = Type.GetType("Mono.Runtime") != null; - var isUnix = Environment.OSVersion.Platform == PlatformID.Unix || - Environment.OSVersion.Platform == PlatformID.MacOSX; - return new RuntimePlatformInfo - { - IsCoreClr = false, - IsDesktop = true, - IsDotNetFramework = !isMono, - IsMono = isMono, - IsMobile = false, - IsUnix = isUnix, - OperatingSystem = isUnix ? DetectUnix() : OperatingSystemType.WinNT, - }; - }); - - [DllImport("libc")] - static extern int uname(IntPtr buf); - - static OperatingSystemType DetectUnix() - { - var buffer = Marshal.AllocHGlobal(0x1000); - uname(buffer); - var unixName = Marshal.PtrToStringAnsi(buffer); - Marshal.FreeHGlobal(buffer); - if(unixName=="Darwin") - return OperatingSystemType.OSX; - if (unixName == "Linux") - return OperatingSystemType.Linux; - return OperatingSystemType.Unknown; - } - - public RuntimePlatformInfo GetRuntimeInfo() => Info.Value; - } -} diff --git a/src/Avalonia.ReactiveUI/Avalonia.ReactiveUI.csproj b/src/Avalonia.ReactiveUI/Avalonia.ReactiveUI.csproj index b9af486ce9..1851f9fb70 100644 --- a/src/Avalonia.ReactiveUI/Avalonia.ReactiveUI.csproj +++ b/src/Avalonia.ReactiveUI/Avalonia.ReactiveUI.csproj @@ -3,7 +3,7 @@ netstandard2.0 - + diff --git a/src/Gtk/Avalonia.Gtk3/Avalonia.Gtk3.csproj b/src/Gtk/Avalonia.Gtk3/Avalonia.Gtk3.csproj index 8f2ef1c0d7..c4be3d4b45 100644 --- a/src/Gtk/Avalonia.Gtk3/Avalonia.Gtk3.csproj +++ b/src/Gtk/Avalonia.Gtk3/Avalonia.Gtk3.csproj @@ -12,5 +12,6 @@ + diff --git a/src/Linux/Avalonia.LinuxFramebuffer/Avalonia.LinuxFramebuffer.csproj b/src/Linux/Avalonia.LinuxFramebuffer/Avalonia.LinuxFramebuffer.csproj index 542e050fcd..c622bbb8c5 100644 --- a/src/Linux/Avalonia.LinuxFramebuffer/Avalonia.LinuxFramebuffer.csproj +++ b/src/Linux/Avalonia.LinuxFramebuffer/Avalonia.LinuxFramebuffer.csproj @@ -4,6 +4,7 @@ true - + + diff --git a/src/Shared/PlatformSupport/StandardRuntimePlatform.cs b/src/Shared/PlatformSupport/StandardRuntimePlatform.cs index 613cf2baf6..186c55d9eb 100644 --- a/src/Shared/PlatformSupport/StandardRuntimePlatform.cs +++ b/src/Shared/PlatformSupport/StandardRuntimePlatform.cs @@ -113,7 +113,7 @@ namespace Avalonia.Shared.PlatformSupport -#if FULLDOTNET || DOTNETCORE +#if NET461 || NETCOREAPP2_0 [DllImport("libc", SetLastError = true)] private static extern IntPtr mmap(IntPtr addr, IntPtr length, int prot, int flags, int fd, IntPtr offset); [DllImport("libc", SetLastError = true)] diff --git a/src/Skia/Avalonia.Skia/Avalonia.Skia.csproj b/src/Skia/Avalonia.Skia/Avalonia.Skia.csproj index 836d45c8ae..e6f5b342ab 100644 --- a/src/Skia/Avalonia.Skia/Avalonia.Skia.csproj +++ b/src/Skia/Avalonia.Skia/Avalonia.Skia.csproj @@ -16,6 +16,7 @@ + diff --git a/src/Windows/Avalonia.Direct2D1/Avalonia.Direct2D1.csproj b/src/Windows/Avalonia.Direct2D1/Avalonia.Direct2D1.csproj index 62b61001dc..70b2703f5e 100644 --- a/src/Windows/Avalonia.Direct2D1/Avalonia.Direct2D1.csproj +++ b/src/Windows/Avalonia.Direct2D1/Avalonia.Direct2D1.csproj @@ -8,7 +8,7 @@ - + diff --git a/src/Windows/Avalonia.Win32.Interop/Avalonia.Win32.Interop.csproj b/src/Windows/Avalonia.Win32.Interop/Avalonia.Win32.Interop.csproj index 7c51f15db9..3405e5db49 100644 --- a/src/Windows/Avalonia.Win32.Interop/Avalonia.Win32.Interop.csproj +++ b/src/Windows/Avalonia.Win32.Interop/Avalonia.Win32.Interop.csproj @@ -7,7 +7,7 @@ true - + diff --git a/src/Windows/Avalonia.Win32/Avalonia.Win32.csproj b/src/Windows/Avalonia.Win32/Avalonia.Win32.csproj index 25b891119a..c0ee8f1373 100644 --- a/src/Windows/Avalonia.Win32/Avalonia.Win32.csproj +++ b/src/Windows/Avalonia.Win32/Avalonia.Win32.csproj @@ -14,6 +14,7 @@ + diff --git a/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj b/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj index da82a54f7a..683c256b7b 100644 --- a/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj +++ b/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj @@ -5,7 +5,7 @@ true - + diff --git a/tests/Avalonia.DesignerSupport.TestApp/Avalonia.DesignerSupport.TestApp.csproj b/tests/Avalonia.DesignerSupport.TestApp/Avalonia.DesignerSupport.TestApp.csproj index dd33ee831d..7736105529 100644 --- a/tests/Avalonia.DesignerSupport.TestApp/Avalonia.DesignerSupport.TestApp.csproj +++ b/tests/Avalonia.DesignerSupport.TestApp/Avalonia.DesignerSupport.TestApp.csproj @@ -14,7 +14,7 @@ - + @@ -28,10 +28,6 @@ - - - - - \ No newline at end of file + diff --git a/tests/Avalonia.Direct2D1.RenderTests/Avalonia.Direct2D1.RenderTests.csproj b/tests/Avalonia.Direct2D1.RenderTests/Avalonia.Direct2D1.RenderTests.csproj index 42d99cc19a..ecc928461e 100644 --- a/tests/Avalonia.Direct2D1.RenderTests/Avalonia.Direct2D1.RenderTests.csproj +++ b/tests/Avalonia.Direct2D1.RenderTests/Avalonia.Direct2D1.RenderTests.csproj @@ -6,7 +6,7 @@ - + @@ -24,4 +24,4 @@ - \ No newline at end of file + diff --git a/tests/Avalonia.Skia.RenderTests/Avalonia.Skia.RenderTests.csproj b/tests/Avalonia.Skia.RenderTests/Avalonia.Skia.RenderTests.csproj index 4a297a340d..a9452b4def 100644 --- a/tests/Avalonia.Skia.RenderTests/Avalonia.Skia.RenderTests.csproj +++ b/tests/Avalonia.Skia.RenderTests/Avalonia.Skia.RenderTests.csproj @@ -7,7 +7,7 @@ - + @@ -26,4 +26,4 @@ - \ No newline at end of file +