From 6144cef9b4516485d841dec7be86115712fd6083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20S=CC=8Colte=CC=81s?= Date: Mon, 23 Dec 2024 21:10:06 +0100 Subject: [PATCH] Use ReactiveGenerator --- azure-pipelines.yml | 2 +- build/Base.props | 2 +- build/build/_build.csproj | 3 +- global.json | 2 +- .../TypefaceUtilAvalonia.Base.csproj | 11 ++ .../ViewModels/GlyphViewModel.cs | 63 +++------- .../ViewModels/MainWindowViewModel.cs | 113 ++++++------------ .../ViewModels/TypefaceViewModel.cs | 33 ++--- .../ViewModels/ViewModelBase.cs | 9 +- .../TypefaceUtilAvalonia.Desktop.csproj | 2 +- .../TypefaceUtilAvalonia.Web.csproj | 2 +- .../UnicodeDataGenerator.csproj | 2 +- .../TypefaceUtil.OpenType.UnitTests.csproj | 2 +- 13 files changed, 85 insertions(+), 161 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index bf41e9a..f1a3e02 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -11,7 +11,7 @@ resources: variables: BuildConfiguration: 'Release' BuildPlatform: 'Any CPU' - PublishFramework: 'net8.0' + PublishFramework: 'net9.0' PublishProject: 'TypefaceUtilAvalonia.Desktop' PublishRuntime: '' Workloads: 'wasm-tools wasm-experimental' diff --git a/build/Base.props b/build/Base.props index c551fff..15526bd 100644 --- a/build/Base.props +++ b/build/Base.props @@ -10,6 +10,6 @@ latest - latest + preview diff --git a/build/build/_build.csproj b/build/build/_build.csproj index 5e6ba1f..bc8d448 100644 --- a/build/build/_build.csproj +++ b/build/build/_build.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net9.0 false False CS0649;CS0169 @@ -12,6 +12,7 @@ + diff --git a/global.json b/global.json index 7865629..6f4a523 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.100", + "version": "9.0.100", "rollForward": "latestMinor", "allowPrerelease": true } diff --git a/src/TypefaceUtilAvalonia.Base/TypefaceUtilAvalonia.Base.csproj b/src/TypefaceUtilAvalonia.Base/TypefaceUtilAvalonia.Base.csproj index 41f6e91..db214e9 100644 --- a/src/TypefaceUtilAvalonia.Base/TypefaceUtilAvalonia.Base.csproj +++ b/src/TypefaceUtilAvalonia.Base/TypefaceUtilAvalonia.Base.csproj @@ -6,6 +6,10 @@ enable TypefaceUtil.Avalonia + + + true + @@ -35,4 +39,11 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/TypefaceUtilAvalonia.Base/ViewModels/GlyphViewModel.cs b/src/TypefaceUtilAvalonia.Base/ViewModels/GlyphViewModel.cs index 2a900ad..44bff65 100644 --- a/src/TypefaceUtilAvalonia.Base/ViewModels/GlyphViewModel.cs +++ b/src/TypefaceUtilAvalonia.Base/ViewModels/GlyphViewModel.cs @@ -9,51 +9,26 @@ namespace TypefaceUtil.Avalonia.ViewModels; -public class GlyphViewModel : ViewModelBase +public partial class GlyphViewModel : ViewModelBase { - private int _charCode; - private ushort _glyphIndex; - private SKPath? _path; - private SKPaint? _paint; - private string? _color; - private string? _svgPathData; - - public int CharCode - { - get => _charCode; - set => this.RaiseAndSetIfChanged(ref _charCode, value); - } - - public ushort GlyphIndex - { - get => _glyphIndex; - set => this.RaiseAndSetIfChanged(ref _glyphIndex, value); - } - - public SKPath? Path - { - get => _path; - set => this.RaiseAndSetIfChanged(ref _path, value); - } - - public SKPaint? Paint - { - get => _paint; - set => this.RaiseAndSetIfChanged(ref _paint, value); - } - - public string? Color - { - get => _color; - set => this.RaiseAndSetIfChanged(ref _color, value); - } - - public string? SvgPathData - { - get => _svgPathData; - set => this.RaiseAndSetIfChanged(ref _svgPathData, value); - } - + [Reactive] + public partial int CharCode { get; set; } + + [Reactive] + public partial ushort GlyphIndex { get; set; } + + [Reactive] + public partial SKPath? Path { get; set; } + + [Reactive] + public partial SKPaint? Paint { get; set; } + + [Reactive] + public partial string? Color { get; set; } + + [Reactive] + public partial string? SvgPathData { get; set; } + public ICommand CopyAsCommand { get; } public ICommand OpenCommand { get; } diff --git a/src/TypefaceUtilAvalonia.Base/ViewModels/MainWindowViewModel.cs b/src/TypefaceUtilAvalonia.Base/ViewModels/MainWindowViewModel.cs index eff20f7..5017de2 100644 --- a/src/TypefaceUtilAvalonia.Base/ViewModels/MainWindowViewModel.cs +++ b/src/TypefaceUtilAvalonia.Base/ViewModels/MainWindowViewModel.cs @@ -16,86 +16,41 @@ namespace TypefaceUtil.Avalonia.ViewModels; -public class MainWindowViewModel : ViewModelBase +public partial class MainWindowViewModel : ViewModelBase { - private bool _isLoading; - private string? _inputFile; - private MemoryStream? _inputData; - private string? _familyName; - private ObservableCollection? _fontFamilies; - private float _fontSize; - private string? _color; - private double _itemWidth; - private double _itemHeight; - private TypefaceViewModel? _typeface; - private GlyphViewModel? _selectedGlyph; - - public bool IsLoading - { - get => _isLoading; - set => this.RaiseAndSetIfChanged(ref _isLoading, value); - } - - public string? InputFile - { - get => _inputFile; - set => this.RaiseAndSetIfChanged(ref _inputFile, value); - } - - public MemoryStream? InputData - { - get => _inputData; - set => this.RaiseAndSetIfChanged(ref _inputData, value); - } - - public string? FamilyName - { - get => _familyName; - set => this.RaiseAndSetIfChanged(ref _familyName, value); - } - - public ObservableCollection? FontFamilies - { - get => _fontFamilies; - set => this.RaiseAndSetIfChanged(ref _fontFamilies, value); - } - - public float FontSize - { - get => _fontSize; - set => this.RaiseAndSetIfChanged(ref _fontSize, value); - } - - public string? Color - { - get => _color; - set => this.RaiseAndSetIfChanged(ref _color, value); - } - - public double ItemWidth - { - get => _itemWidth; - set => this.RaiseAndSetIfChanged(ref _itemWidth, value); - } - - public double ItemHeight - { - get => _itemHeight; - set => this.RaiseAndSetIfChanged(ref _itemHeight, value); - } - - public TypefaceViewModel? Typeface - { - get => _typeface; - set => this.RaiseAndSetIfChanged(ref _typeface, value); - } - - public GlyphViewModel? SelectedGlyph - { - get => _selectedGlyph; - set => this.RaiseAndSetIfChanged(ref _selectedGlyph, value); - } - + [Reactive] + public partial bool IsLoading { get; set; } + + [Reactive] + public partial string? InputFile { get; set; } + + [Reactive] + public partial MemoryStream? InputData { get; set; } + + [Reactive] + public partial string? FamilyName { get; set; } + + [Reactive] + public partial ObservableCollection? FontFamilies { get; set; } + + [Reactive] + public partial float FontSize { get; set; } + + [Reactive] + public partial string? Color { get; set; } + + [Reactive] + public partial double ItemWidth { get; set; } + + [Reactive] + public partial double ItemHeight { get; set; } + + [Reactive] + public partial TypefaceViewModel? Typeface { get; set; } + + [Reactive] + public partial GlyphViewModel? SelectedGlyph { get; set; } + public ICommand InputFileCommand { get; } public ICommand LoadInputFileCommand { get; } diff --git a/src/TypefaceUtilAvalonia.Base/ViewModels/TypefaceViewModel.cs b/src/TypefaceUtilAvalonia.Base/ViewModels/TypefaceViewModel.cs index 40e5361..54d69a8 100644 --- a/src/TypefaceUtilAvalonia.Base/ViewModels/TypefaceViewModel.cs +++ b/src/TypefaceUtilAvalonia.Base/ViewModels/TypefaceViewModel.cs @@ -6,27 +6,14 @@ namespace TypefaceUtil.Avalonia.ViewModels; -public class TypefaceViewModel : ViewModelBase +public partial class TypefaceViewModel : ViewModelBase { - private SKTypeface? _typeface; - private List? _characterMaps; - private ObservableCollection? _glyphs; - - public SKTypeface? Typeface - { - get => _typeface; - set => this.RaiseAndSetIfChanged(ref _typeface, value); - } - - public List? CharacterMaps - { - get => _characterMaps; - set => this.RaiseAndSetIfChanged(ref _characterMaps, value); - } - - public ObservableCollection? Glyphs - { - get => _glyphs; - set => this.RaiseAndSetIfChanged(ref _glyphs, value); - } -} \ No newline at end of file + [Reactive] + public partial SKTypeface? Typeface { get; set; } + + [Reactive] + public partial List? CharacterMaps { get; set; } + + [Reactive] + public partial ObservableCollection? Glyphs { get; set; } +} diff --git a/src/TypefaceUtilAvalonia.Base/ViewModels/ViewModelBase.cs b/src/TypefaceUtilAvalonia.Base/ViewModels/ViewModelBase.cs index afaa89b..cecbebb 100644 --- a/src/TypefaceUtilAvalonia.Base/ViewModels/ViewModelBase.cs +++ b/src/TypefaceUtilAvalonia.Base/ViewModels/ViewModelBase.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Text; -using ReactiveUI; +using ReactiveUI; namespace TypefaceUtil.Avalonia.ViewModels; -public class ViewModelBase : ReactiveObject -{ -} \ No newline at end of file +public class ViewModelBase : ReactiveObject; diff --git a/src/TypefaceUtilAvalonia.Desktop/TypefaceUtilAvalonia.Desktop.csproj b/src/TypefaceUtilAvalonia.Desktop/TypefaceUtilAvalonia.Desktop.csproj index 2239543..dd1cd88 100644 --- a/src/TypefaceUtilAvalonia.Desktop/TypefaceUtilAvalonia.Desktop.csproj +++ b/src/TypefaceUtilAvalonia.Desktop/TypefaceUtilAvalonia.Desktop.csproj @@ -1,7 +1,7 @@  WinExe - net8.0 + net9.0 False enable ..\TypefaceUtilAvalonia.Base\Assets\Icon.ico diff --git a/src/TypefaceUtilAvalonia.Web/TypefaceUtilAvalonia.Web.csproj b/src/TypefaceUtilAvalonia.Web/TypefaceUtilAvalonia.Web.csproj index 5c22a23..9abf988 100644 --- a/src/TypefaceUtilAvalonia.Web/TypefaceUtilAvalonia.Web.csproj +++ b/src/TypefaceUtilAvalonia.Web/TypefaceUtilAvalonia.Web.csproj @@ -1,7 +1,7 @@  - net8.0-browser + net9.0-browser browser-wasm AppBundle\main.js Exe diff --git a/src/UnicodeDataGenerator/UnicodeDataGenerator.csproj b/src/UnicodeDataGenerator/UnicodeDataGenerator.csproj index 1006de0..6e91d1a 100644 --- a/src/UnicodeDataGenerator/UnicodeDataGenerator.csproj +++ b/src/UnicodeDataGenerator/UnicodeDataGenerator.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net9.0 False diff --git a/tests/TypefaceUtil.OpenType.UnitTests/TypefaceUtil.OpenType.UnitTests.csproj b/tests/TypefaceUtil.OpenType.UnitTests/TypefaceUtil.OpenType.UnitTests.csproj index bb208b6..27e71b8 100644 --- a/tests/TypefaceUtil.OpenType.UnitTests/TypefaceUtil.OpenType.UnitTests.csproj +++ b/tests/TypefaceUtil.OpenType.UnitTests/TypefaceUtil.OpenType.UnitTests.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 Library False enable