Browse Source
* Remove netstandard2.0 from almost all projects * Fix duplicated target frameworks in unit tests * Fix DesignerSupport tests * Fix Designer.HostApp packaging * Build ControlCatalog.Desktop on CI * Fix another bad auto merge * Fix LeakTests duplicated target frameworks * Don't hardcode target framework in DesignerSupportTestspull/18913/head
committed by
GitHub
62 changed files with 260 additions and 320 deletions
@ -1,22 +1,41 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<OutputType>Exe</OutputType> |
|||
<TargetFramework>net461</TargetFramework> |
|||
<PlatformTarget>x64</PlatformTarget> |
|||
<OutputType>WinExe</OutputType> |
|||
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework> |
|||
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> |
|||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> |
|||
<ApplicationManifest>../ControlCatalog.NetCore/app.manifest</ApplicationManifest> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\ControlCatalog\ControlCatalog.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj" /> |
|||
<Compile Include="..\..\src\Avalonia.X11\NativeDialogs\Gtk.cs" Link="NativeControls\Gtk\Gtk.cs" /> |
|||
<Compile Include="..\..\src\Avalonia.X11\Interop\Glib.cs" Link="NativeControls\Gtk\Glib.cs" /> |
|||
<Compile Include="..\..\src\Avalonia.Base\Platform\Interop\Utf8Buffer.cs" Link="NativeControls\Utf8Buffer.cs" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<Content Include="NativeControls\Gtk\nodes.mp4"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<Compile Include="..\ControlCatalog.NetCore\NativeControls\Win\*.cs" Link="NativeControls\*" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj" /> |
|||
<ProjectReference Include="..\..\src\Headless\Avalonia.Headless.Vnc\Avalonia.Headless.Vnc.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Dialogs\Avalonia.Dialogs.csproj" /> |
|||
<ProjectReference Include="..\..\src\Linux\Avalonia.LinuxFramebuffer\Avalonia.LinuxFramebuffer.csproj" /> |
|||
<ProjectReference Include="..\ControlCatalog\ControlCatalog.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.X11\Avalonia.X11.csproj" /> |
|||
<!-- For native controls test --> |
|||
<PackageReference Include="MonoMac.NetStandard" Version="0.0.4" /> |
|||
</ItemGroup> |
|||
|
|||
<PropertyGroup> |
|||
<!-- For Microsoft.CodeAnalysis --> |
|||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages> |
|||
<ApplicationManifest>app.manifest</ApplicationManifest> |
|||
</PropertyGroup> |
|||
|
|||
<Import Project="..\..\build\SampleApp.props" /> |
|||
<Import Project="..\..\build\NetFX.props" /> |
|||
<Import Project="..\..\build\ReferenceCoreLibraries.props" /> |
|||
</Project> |
|||
|
|||
@ -1,7 +1,7 @@ |
|||
using System; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
namespace ControlCatalog.NetCore; |
|||
namespace ControlCatalog.Desktop; |
|||
|
|||
internal unsafe class WinApi |
|||
{ |
|||
@ -1,38 +1,180 @@ |
|||
using System; |
|||
using System.Diagnostics; |
|||
using System.Globalization; |
|||
using System.Linq; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Avalonia; |
|||
using Avalonia.Platform; |
|||
using ControlCatalog.NetCore; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Controls.ApplicationLifetimes; |
|||
using Avalonia.Fonts.Inter; |
|||
using Avalonia.Headless; |
|||
using Avalonia.LinuxFramebuffer.Output; |
|||
using Avalonia.LogicalTree; |
|||
using Avalonia.Rendering.Composition; |
|||
using Avalonia.Threading; |
|||
using Avalonia.Vulkan; |
|||
using ControlCatalog.Pages; |
|||
|
|||
namespace ControlCatalog |
|||
namespace ControlCatalog.Desktop |
|||
{ |
|||
internal class Program |
|||
static class Program |
|||
{ |
|||
private static bool s_useFramebuffer; |
|||
|
|||
[STAThread] |
|||
public static int Main(string[] args) |
|||
=> BuildAvaloniaApp().StartWithClassicDesktopLifetime(args); |
|||
static int Main(string[] args) |
|||
{ |
|||
if (args.Contains("--fbdev")) |
|||
{ |
|||
s_useFramebuffer = true; |
|||
} |
|||
|
|||
if (args.Contains("--wait-for-attach")) |
|||
{ |
|||
Console.WriteLine("Attach debugger and use 'Set next statement'"); |
|||
while (true) |
|||
{ |
|||
Thread.Sleep(100); |
|||
if (Debugger.IsAttached) |
|||
break; |
|||
} |
|||
} |
|||
|
|||
var builder = BuildAvaloniaApp(); |
|||
|
|||
double GetScaling() |
|||
{ |
|||
var idx = Array.IndexOf(args, "--scaling"); |
|||
if (idx != 0 && args.Length > idx + 1 && |
|||
double.TryParse(args[idx + 1], NumberStyles.Any, CultureInfo.InvariantCulture, out var scaling)) |
|||
return scaling; |
|||
return 1; |
|||
} |
|||
if (s_useFramebuffer) |
|||
{ |
|||
SilenceConsole(); |
|||
return builder.StartLinuxFbDev(args, new FbDevOutputOptions() |
|||
{ |
|||
Scaling = GetScaling() |
|||
}); |
|||
} |
|||
else if (args.Contains("--vnc")) |
|||
{ |
|||
return builder.StartWithHeadlessVncPlatform(null, 5901, args, ShutdownMode.OnMainWindowClose); |
|||
} |
|||
else if (args.Contains("--full-headless")) |
|||
{ |
|||
return builder |
|||
.UseHeadless(new AvaloniaHeadlessPlatformOptions |
|||
{ |
|||
UseHeadlessDrawing = true |
|||
}) |
|||
.AfterSetup(_ => |
|||
{ |
|||
DispatcherTimer.RunOnce(async () => |
|||
{ |
|||
var window = ((IClassicDesktopStyleApplicationLifetime)Application.Current.ApplicationLifetime) |
|||
.MainWindow; |
|||
var tc = window.GetLogicalDescendants().OfType<TabControl>().First(); |
|||
foreach (var page in tc.Items.Cast<TabItem>().ToList()) |
|||
{ |
|||
if (page.Header.ToString() == "DatePicker" || page.Header.ToString() == "TreeView") |
|||
continue; |
|||
Console.WriteLine("Selecting " + page.Header); |
|||
tc.SelectedItem = page; |
|||
await Task.Delay(50); |
|||
} |
|||
Console.WriteLine("Selecting the first page"); |
|||
tc.SelectedItem = tc.Items.OfType<object>().First(); |
|||
await Task.Delay(500); |
|||
Console.WriteLine("Clicked through all pages, triggering GC"); |
|||
for (var c = 0; c < 3; c++) |
|||
{ |
|||
GC.Collect(2, GCCollectionMode.Forced); |
|||
await Task.Delay(50); |
|||
} |
|||
|
|||
void FormatMem(string metric, long bytes) |
|||
{ |
|||
Console.WriteLine(metric + ": " + bytes / 1024 / 1024 + "MB"); |
|||
} |
|||
|
|||
FormatMem("GC allocated bytes", GC.GetTotalMemory(true)); |
|||
FormatMem("WorkingSet64", Process.GetCurrentProcess().WorkingSet64); |
|||
}, TimeSpan.FromSeconds(1)); |
|||
}) |
|||
.StartWithClassicDesktopLifetime(args); |
|||
} |
|||
else if (args.Contains("--drm")) |
|||
{ |
|||
SilenceConsole(); |
|||
return builder.StartLinuxDrm(args, scaling: GetScaling()); |
|||
} |
|||
else if (args.Contains("--dxgi")) |
|||
{ |
|||
builder.With(new Win32PlatformOptions() |
|||
{ |
|||
CompositionMode = new [] { Win32CompositionMode.LowLatencyDxgiSwapChain } |
|||
}); |
|||
return builder.StartWithClassicDesktopLifetime(args); |
|||
} |
|||
else |
|||
return builder.StartWithClassicDesktopLifetime(args); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// This method is needed for IDE previewer infrastructure
|
|||
/// </summary>
|
|||
public static AppBuilder BuildAvaloniaApp() |
|||
=> AppBuilder.Configure<App>() |
|||
.LogToTrace() |
|||
.UsePlatformDetect() |
|||
.With(new X11PlatformOptions |
|||
{ |
|||
EnableMultiTouch = true, |
|||
UseDBusMenu = true, |
|||
EnableIme = true, |
|||
}) |
|||
|
|||
.With(new VulkanOptions |
|||
{ |
|||
VulkanInstanceCreationOptions = new () |
|||
{ |
|||
UseDebug = true |
|||
} |
|||
}) |
|||
.With(new CompositionOptions() |
|||
{ |
|||
UseRegionDirtyRectClipping = true |
|||
}) |
|||
.UseSkia() |
|||
.WithInterFont() |
|||
.AfterSetup(builder => |
|||
{ |
|||
builder.Instance!.AttachDevTools(new Avalonia.Diagnostics.DevToolsOptions() |
|||
if (!s_useFramebuffer) |
|||
{ |
|||
StartupScreenIndex = 1, |
|||
}); |
|||
builder.Instance!.AttachDevTools(new Avalonia.Diagnostics.DevToolsOptions() |
|||
{ |
|||
StartupScreenIndex = 1, |
|||
}); |
|||
} |
|||
|
|||
EmbedSample.Implementation = new EmbedSampleWin(); |
|||
EmbedSample.Implementation = OperatingSystem.IsWindows() ? (INativeDemoControl)new EmbedSampleWin() |
|||
: OperatingSystem.IsMacOS() ? new EmbedSampleMac() |
|||
: OperatingSystem.IsLinux() ? new EmbedSampleGtk() |
|||
: null; |
|||
}) |
|||
.UseWin32() |
|||
.UseSkia(); |
|||
.LogToTrace(); |
|||
|
|||
private static void ConfigureAssetAssembly(AppBuilder builder) |
|||
static void SilenceConsole() |
|||
{ |
|||
AssetLoader.SetDefaultAssembly(typeof(App).Assembly); |
|||
new Thread(() => |
|||
{ |
|||
Console.CursorVisible = false; |
|||
while (true) |
|||
Console.ReadKey(true); |
|||
}) |
|||
{ IsBackground = true }.Start(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -1,6 +1,6 @@ |
|||
{ |
|||
"profiles": { |
|||
"ControlCatalog.NetCore": { |
|||
"ControlCatalog.Desktop": { |
|||
"commandName": "Project" |
|||
}, |
|||
"Dxgi": { |
|||
@ -1,41 +0,0 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<OutputType>WinExe</OutputType> |
|||
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework> |
|||
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> |
|||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<Compile Include="..\..\src\Avalonia.X11\NativeDialogs\Gtk.cs" Link="NativeControls\Gtk\Gtk.cs" /> |
|||
<Compile Include="..\..\src\Avalonia.X11\Interop\Glib.cs" Link="NativeControls\Gtk\Glib.cs" /> |
|||
<Compile Include="..\..\src\Avalonia.Base\Platform\Interop\Utf8Buffer.cs" Link="NativeControls\Utf8Buffer.cs" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<Content Include="NativeControls\Gtk\nodes.mp4"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj" /> |
|||
<ProjectReference Include="..\..\src\Headless\Avalonia.Headless.Vnc\Avalonia.Headless.Vnc.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Dialogs\Avalonia.Dialogs.csproj" /> |
|||
<ProjectReference Include="..\..\src\Linux\Avalonia.LinuxFramebuffer\Avalonia.LinuxFramebuffer.csproj" /> |
|||
<ProjectReference Include="..\ControlCatalog\ControlCatalog.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.X11\Avalonia.X11.csproj" /> |
|||
<!-- For native controls test --> |
|||
<PackageReference Include="MonoMac.NetStandard" Version="0.0.4" /> |
|||
</ItemGroup> |
|||
|
|||
<PropertyGroup> |
|||
<!-- For Microsoft.CodeAnalysis --> |
|||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages> |
|||
<ApplicationManifest>app.manifest</ApplicationManifest> |
|||
</PropertyGroup> |
|||
|
|||
<Import Project="..\..\build\SampleApp.props" /> |
|||
<Import Project="..\..\build\ReferenceCoreLibraries.props" /> |
|||
</Project> |
|||
@ -1,180 +0,0 @@ |
|||
using System; |
|||
using System.Diagnostics; |
|||
using System.Globalization; |
|||
using System.Linq; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Avalonia; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Controls.ApplicationLifetimes; |
|||
using Avalonia.Fonts.Inter; |
|||
using Avalonia.Headless; |
|||
using Avalonia.LinuxFramebuffer.Output; |
|||
using Avalonia.LogicalTree; |
|||
using Avalonia.Rendering.Composition; |
|||
using Avalonia.Threading; |
|||
using Avalonia.Vulkan; |
|||
using ControlCatalog.Pages; |
|||
|
|||
namespace ControlCatalog.NetCore |
|||
{ |
|||
static class Program |
|||
{ |
|||
private static bool s_useFramebuffer; |
|||
|
|||
[STAThread] |
|||
static int Main(string[] args) |
|||
{ |
|||
if (args.Contains("--fbdev")) |
|||
{ |
|||
s_useFramebuffer = true; |
|||
} |
|||
|
|||
if (args.Contains("--wait-for-attach")) |
|||
{ |
|||
Console.WriteLine("Attach debugger and use 'Set next statement'"); |
|||
while (true) |
|||
{ |
|||
Thread.Sleep(100); |
|||
if (Debugger.IsAttached) |
|||
break; |
|||
} |
|||
} |
|||
|
|||
var builder = BuildAvaloniaApp(); |
|||
|
|||
double GetScaling() |
|||
{ |
|||
var idx = Array.IndexOf(args, "--scaling"); |
|||
if (idx != 0 && args.Length > idx + 1 && |
|||
double.TryParse(args[idx + 1], NumberStyles.Any, CultureInfo.InvariantCulture, out var scaling)) |
|||
return scaling; |
|||
return 1; |
|||
} |
|||
if (s_useFramebuffer) |
|||
{ |
|||
SilenceConsole(); |
|||
return builder.StartLinuxFbDev(args, new FbDevOutputOptions() |
|||
{ |
|||
Scaling = GetScaling() |
|||
}); |
|||
} |
|||
else if (args.Contains("--vnc")) |
|||
{ |
|||
return builder.StartWithHeadlessVncPlatform(null, 5901, args, ShutdownMode.OnMainWindowClose); |
|||
} |
|||
else if (args.Contains("--full-headless")) |
|||
{ |
|||
return builder |
|||
.UseHeadless(new AvaloniaHeadlessPlatformOptions |
|||
{ |
|||
UseHeadlessDrawing = true |
|||
}) |
|||
.AfterSetup(_ => |
|||
{ |
|||
DispatcherTimer.RunOnce(async () => |
|||
{ |
|||
var window = ((IClassicDesktopStyleApplicationLifetime)Application.Current.ApplicationLifetime) |
|||
.MainWindow; |
|||
var tc = window.GetLogicalDescendants().OfType<TabControl>().First(); |
|||
foreach (var page in tc.Items.Cast<TabItem>().ToList()) |
|||
{ |
|||
if (page.Header.ToString() == "DatePicker" || page.Header.ToString() == "TreeView") |
|||
continue; |
|||
Console.WriteLine("Selecting " + page.Header); |
|||
tc.SelectedItem = page; |
|||
await Task.Delay(50); |
|||
} |
|||
Console.WriteLine("Selecting the first page"); |
|||
tc.SelectedItem = tc.Items.OfType<object>().First(); |
|||
await Task.Delay(500); |
|||
Console.WriteLine("Clicked through all pages, triggering GC"); |
|||
for (var c = 0; c < 3; c++) |
|||
{ |
|||
GC.Collect(2, GCCollectionMode.Forced); |
|||
await Task.Delay(50); |
|||
} |
|||
|
|||
void FormatMem(string metric, long bytes) |
|||
{ |
|||
Console.WriteLine(metric + ": " + bytes / 1024 / 1024 + "MB"); |
|||
} |
|||
|
|||
FormatMem("GC allocated bytes", GC.GetTotalMemory(true)); |
|||
FormatMem("WorkingSet64", Process.GetCurrentProcess().WorkingSet64); |
|||
}, TimeSpan.FromSeconds(1)); |
|||
}) |
|||
.StartWithClassicDesktopLifetime(args); |
|||
} |
|||
else if (args.Contains("--drm")) |
|||
{ |
|||
SilenceConsole(); |
|||
return builder.StartLinuxDrm(args, scaling: GetScaling()); |
|||
} |
|||
else if (args.Contains("--dxgi")) |
|||
{ |
|||
builder.With(new Win32PlatformOptions() |
|||
{ |
|||
CompositionMode = new [] { Win32CompositionMode.LowLatencyDxgiSwapChain } |
|||
}); |
|||
return builder.StartWithClassicDesktopLifetime(args); |
|||
} |
|||
else |
|||
return builder.StartWithClassicDesktopLifetime(args); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// This method is needed for IDE previewer infrastructure
|
|||
/// </summary>
|
|||
public static AppBuilder BuildAvaloniaApp() |
|||
=> AppBuilder.Configure<App>() |
|||
.UsePlatformDetect() |
|||
.With(new X11PlatformOptions |
|||
{ |
|||
EnableMultiTouch = true, |
|||
UseDBusMenu = true, |
|||
EnableIme = true, |
|||
}) |
|||
|
|||
.With(new VulkanOptions |
|||
{ |
|||
VulkanInstanceCreationOptions = new () |
|||
{ |
|||
UseDebug = true |
|||
} |
|||
}) |
|||
.With(new CompositionOptions() |
|||
{ |
|||
UseRegionDirtyRectClipping = true |
|||
}) |
|||
.UseSkia() |
|||
.WithInterFont() |
|||
.AfterSetup(builder => |
|||
{ |
|||
if (!s_useFramebuffer) |
|||
{ |
|||
builder.Instance!.AttachDevTools(new Avalonia.Diagnostics.DevToolsOptions() |
|||
{ |
|||
StartupScreenIndex = 1, |
|||
}); |
|||
} |
|||
|
|||
EmbedSample.Implementation = OperatingSystem.IsWindows() ? (INativeDemoControl)new EmbedSampleWin() |
|||
: OperatingSystem.IsMacOS() ? new EmbedSampleMac() |
|||
: OperatingSystem.IsLinux() ? new EmbedSampleGtk() |
|||
: null; |
|||
}) |
|||
.LogToTrace(); |
|||
|
|||
static void SilenceConsole() |
|||
{ |
|||
new Thread(() => |
|||
{ |
|||
Console.CursorVisible = false; |
|||
while (true) |
|||
Console.ReadKey(true); |
|||
}) |
|||
{ IsBackground = true }.Start(); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue