Trim produced assemblies (#447)
This commit is contained in:
parent
db003aa6ca
commit
0c6e7eb1ac
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@ -50,7 +50,7 @@ jobs:
|
|||||||
- osx-arm64
|
- osx-arm64
|
||||||
- osx-x64
|
- osx-x64
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ${{ startsWith(matrix.rid, 'win-') && 'windows-latest' || startsWith(matrix.rid, 'osx-') && 'macos-latest' || 'ubuntu-latest' }}
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
|
@ -1,25 +1,33 @@
|
|||||||
using System;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Controls.Templates;
|
using Avalonia.Controls.Templates;
|
||||||
|
using YoutubeDownloader.ViewModels;
|
||||||
|
using YoutubeDownloader.ViewModels.Components;
|
||||||
|
using YoutubeDownloader.ViewModels.Dialogs;
|
||||||
|
using YoutubeDownloader.Views;
|
||||||
|
using YoutubeDownloader.Views.Components;
|
||||||
|
using YoutubeDownloader.Views.Dialogs;
|
||||||
|
|
||||||
namespace YoutubeDownloader.Framework;
|
namespace YoutubeDownloader.Framework;
|
||||||
|
|
||||||
public partial class ViewManager
|
public partial class ViewManager
|
||||||
{
|
{
|
||||||
|
private Control? TryCreateView(ViewModelBase viewModel) =>
|
||||||
|
viewModel switch
|
||||||
|
{
|
||||||
|
MainViewModel => new MainView(),
|
||||||
|
DashboardViewModel => new DashboardView(),
|
||||||
|
AuthSetupViewModel => new AuthSetupView(),
|
||||||
|
DownloadMultipleSetupViewModel => new DownloadMultipleSetupView(),
|
||||||
|
DownloadSingleSetupViewModel => new DownloadSingleSetupView(),
|
||||||
|
MessageBoxViewModel => new MessageBoxView(),
|
||||||
|
SettingsViewModel => new SettingsView(),
|
||||||
|
_ => null
|
||||||
|
};
|
||||||
|
|
||||||
public Control? TryBindView(ViewModelBase viewModel)
|
public Control? TryBindView(ViewModelBase viewModel)
|
||||||
{
|
{
|
||||||
var name = viewModel
|
var view = TryCreateView(viewModel);
|
||||||
.GetType()
|
if (view is null)
|
||||||
.FullName?.Replace("ViewModel", "View", StringComparison.Ordinal);
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(name))
|
|
||||||
return null;
|
|
||||||
|
|
||||||
var type = Type.GetType(name);
|
|
||||||
if (type is null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (Activator.CreateInstance(type) is not Control view)
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
view.DataContext ??= viewModel;
|
view.DataContext ??= viewModel;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
@ -48,6 +49,8 @@ public partial class SettingsService()
|
|||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
[property: JsonConverter(typeof(ContainerJsonConverter))]
|
[property: JsonConverter(typeof(ContainerJsonConverter))]
|
||||||
|
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(Container))]
|
||||||
|
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ContainerJsonConverter))]
|
||||||
private Container _lastContainer = Container.Mp4;
|
private Container _lastContainer = Container.Mp4;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
|
@ -8,11 +8,8 @@
|
|||||||
xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||||
xmlns:materialStyles="clr-namespace:Material.Styles.Controls;assembly=Material.Styles"
|
xmlns:materialStyles="clr-namespace:Material.Styles.Controls;assembly=Material.Styles"
|
||||||
x:Name="UserControl"
|
x:Name="UserControl"
|
||||||
|
x:DataType="components:DashboardViewModel"
|
||||||
Loaded="UserControl_OnLoaded">
|
Loaded="UserControl_OnLoaded">
|
||||||
<Design.DataContext>
|
|
||||||
<components:DashboardViewModel />
|
|
||||||
</Design.DataContext>
|
|
||||||
|
|
||||||
<DockPanel>
|
<DockPanel>
|
||||||
<!-- Header -->
|
<!-- Header -->
|
||||||
<StackPanel
|
<StackPanel
|
||||||
@ -315,7 +312,7 @@
|
|||||||
<Button
|
<Button
|
||||||
Padding="4"
|
Padding="4"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Command="{Binding $parent[UserControl].DataContext.RestartDownloadCommand}"
|
Command="{Binding $parent[UserControl].((components:DashboardViewModel)DataContext).RestartDownloadCommand}"
|
||||||
CommandParameter="{Binding}"
|
CommandParameter="{Binding}"
|
||||||
IsVisible="{Binding IsCanceledOrFailed}"
|
IsVisible="{Binding IsCanceledOrFailed}"
|
||||||
Theme="{DynamicResource MaterialFlatButton}"
|
Theme="{DynamicResource MaterialFlatButton}"
|
||||||
|
@ -5,11 +5,8 @@
|
|||||||
xmlns:dialogs="clr-namespace:YoutubeDownloader.ViewModels.Dialogs"
|
xmlns:dialogs="clr-namespace:YoutubeDownloader.ViewModels.Dialogs"
|
||||||
xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||||
Height="450"
|
Height="450"
|
||||||
MinWidth="450">
|
MinWidth="450"
|
||||||
<Design.DataContext>
|
x:DataType="dialogs:AuthSetupViewModel">
|
||||||
<dialogs:AuthSetupViewModel />
|
|
||||||
</Design.DataContext>
|
|
||||||
|
|
||||||
<Grid RowDefinitions="Auto,*,Auto">
|
<Grid RowDefinitions="Auto,*,Auto">
|
||||||
<!-- Title -->
|
<!-- Title -->
|
||||||
<TextBlock
|
<TextBlock
|
||||||
|
@ -9,11 +9,8 @@
|
|||||||
xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||||
x:Name="UserControl"
|
x:Name="UserControl"
|
||||||
Width="500"
|
Width="500"
|
||||||
|
x:DataType="dialogs:DownloadMultipleSetupViewModel"
|
||||||
Loaded="UserControl_OnLoaded">
|
Loaded="UserControl_OnLoaded">
|
||||||
<Design.DataContext>
|
|
||||||
<dialogs:DownloadMultipleSetupViewModel />
|
|
||||||
</Design.DataContext>
|
|
||||||
|
|
||||||
<Grid RowDefinitions="Auto,*,Auto,Auto">
|
<Grid RowDefinitions="Auto,*,Auto,Auto">
|
||||||
<!-- Title -->
|
<!-- Title -->
|
||||||
<TextBlock
|
<TextBlock
|
||||||
|
@ -9,11 +9,8 @@
|
|||||||
xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||||
x:Name="UserControl"
|
x:Name="UserControl"
|
||||||
Width="500"
|
Width="500"
|
||||||
|
x:DataType="dialogs:DownloadSingleSetupViewModel"
|
||||||
Loaded="UserControl_OnLoaded">
|
Loaded="UserControl_OnLoaded">
|
||||||
<Design.DataContext>
|
|
||||||
<dialogs:DownloadSingleSetupViewModel />
|
|
||||||
</Design.DataContext>
|
|
||||||
|
|
||||||
<Grid RowDefinitions="Auto,*,Auto,Auto">
|
<Grid RowDefinitions="Auto,*,Auto,Auto">
|
||||||
<!-- Info -->
|
<!-- Info -->
|
||||||
<StackPanel
|
<StackPanel
|
||||||
|
@ -4,11 +4,8 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:dialogs="clr-namespace:YoutubeDownloader.ViewModels.Dialogs"
|
xmlns:dialogs="clr-namespace:YoutubeDownloader.ViewModels.Dialogs"
|
||||||
xmlns:system="clr-namespace:System;assembly=System.Runtime"
|
xmlns:system="clr-namespace:System;assembly=System.Runtime"
|
||||||
Width="500">
|
Width="500"
|
||||||
<Design.DataContext>
|
x:DataType="dialogs:MessageBoxViewModel">
|
||||||
<dialogs:MessageBoxViewModel />
|
|
||||||
</Design.DataContext>
|
|
||||||
|
|
||||||
<Grid RowDefinitions="Auto,*,Auto">
|
<Grid RowDefinitions="Auto,*,Auto">
|
||||||
<!-- Title -->
|
<!-- Title -->
|
||||||
<TextBlock
|
<TextBlock
|
||||||
|
@ -3,11 +3,8 @@
|
|||||||
xmlns="https://github.com/avaloniaui"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:dialogs="clr-namespace:YoutubeDownloader.ViewModels.Dialogs"
|
xmlns:dialogs="clr-namespace:YoutubeDownloader.ViewModels.Dialogs"
|
||||||
Width="380">
|
Width="380"
|
||||||
<Design.DataContext>
|
x:DataType="dialogs:SettingsViewModel">
|
||||||
<dialogs:SettingsViewModel />
|
|
||||||
</Design.DataContext>
|
|
||||||
|
|
||||||
<Grid RowDefinitions="Auto,*,Auto">
|
<Grid RowDefinitions="Auto,*,Auto">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
|
@ -10,13 +10,10 @@
|
|||||||
Height="620"
|
Height="620"
|
||||||
MinWidth="600"
|
MinWidth="600"
|
||||||
MinHeight="400"
|
MinHeight="400"
|
||||||
|
x:DataType="viewModels:MainViewModel"
|
||||||
Icon="/favicon.ico"
|
Icon="/favicon.ico"
|
||||||
RenderOptions.BitmapInterpolationMode="HighQuality"
|
RenderOptions.BitmapInterpolationMode="HighQuality"
|
||||||
WindowStartupLocation="CenterScreen">
|
WindowStartupLocation="CenterScreen">
|
||||||
<Design.DataContext>
|
|
||||||
<viewModels:MainViewModel />
|
|
||||||
</Design.DataContext>
|
|
||||||
|
|
||||||
<!-- Hack: dialog host animations mess up webview positioning, so need to disable them -->
|
<!-- Hack: dialog host animations mess up webview positioning, so need to disable them -->
|
||||||
<dialogHostAvalonia:DialogHost
|
<dialogHostAvalonia:DialogHost
|
||||||
x:Name="DialogHost"
|
x:Name="DialogHost"
|
||||||
|
@ -4,11 +4,35 @@
|
|||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||||
<ApplicationIcon>..\favicon.ico</ApplicationIcon>
|
<ApplicationIcon>..\favicon.ico</ApplicationIcon>
|
||||||
|
|
||||||
<!-- App manifest is required to embed native windows, namely the WebBrowser control -->
|
|
||||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
|
<PublishTrimmed>true</PublishTrimmed>
|
||||||
|
<JsonSerializerIsReflectionEnabledByDefault>true</JsonSerializerIsReflectionEnabledByDefault>
|
||||||
|
<NoWarn>$(NoWarn);IL2104</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Avalonia-related settings -->
|
||||||
|
<PropertyGroup>
|
||||||
|
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
||||||
|
<!-- Warnings not valid when using compiled bindings -->
|
||||||
|
<NoWarn>$(NoWarn);IL2026</NoWarn>
|
||||||
|
<!-- Warnings about Material.Avalonia having peer dependencies -->
|
||||||
|
<NoWarn>$(NoWarn);IL2036</NoWarn>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Avalonia.WebView is completely incompatible with trimming -->
|
||||||
|
<ItemGroup>
|
||||||
|
<TrimmerRootAssembly Include="Avalonia.WebView" />
|
||||||
|
<TrimmerRootAssembly Include="Avalonia.WebView.Desktop" />
|
||||||
|
<TrimmerRootAssembly Include="Avalonia.WebView.Linux" />
|
||||||
|
<TrimmerRootAssembly Include="Avalonia.WebView.MacCatalyst" />
|
||||||
|
<TrimmerRootAssembly Include="Avalonia.WebView.Windows" />
|
||||||
|
<TrimmerRootAssembly Include="AvaloniaWebView.Shared" />
|
||||||
|
<TrimmerRootAssembly Include="Linux.WebView.Core" />
|
||||||
|
<TrimmerRootAssembly Include="Microsoft.Web.WebView2.Core" />
|
||||||
|
<TrimmerRootAssembly Include="WebView.Avalonia" />
|
||||||
|
<TrimmerRootAssembly Include="WebView.Core" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AvaloniaResource Include="..\favicon.ico" Link="favicon.ico" />
|
<AvaloniaResource Include="..\favicon.ico" Link="favicon.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user