From e934eb9629c97b8c96f5076ffa779f3cc4a1321c Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Thu, 1 Oct 2026 16:57:12 +0800 Subject: [PATCH] refactor(m0): restructure project and install dependencies - Clean Avalonia template content (ViewLocator, greeting, empty Models folder) - Add YKanBan.Tests (MSTest 4.4.1) to solution - Install packages per plan version table (Semi.Avalonia, Lucide icons, Microsoft.Data.Sqlite, Pidgin, Newtonsoft.Json 13.0.4 fallback) --- YKanBan.Tests/SmokeTests.cs | 13 ++++++++++ YKanBan.Tests/YKanBan.Tests.csproj | 16 ++++++++++++ YKanBan.slnx | 1 + YKanBan/App.axaml | 8 +----- YKanBan/App.axaml.cs | 8 ++---- YKanBan/Program.cs | 8 ++---- YKanBan/ViewLocator.cs | 31 ----------------------- YKanBan/ViewModels/MainWindowViewModel.cs | 1 - YKanBan/Views/MainWindow.axaml | 5 ---- YKanBan/YKanBan.csproj | 8 ++++-- 10 files changed, 41 insertions(+), 58 deletions(-) create mode 100644 YKanBan.Tests/SmokeTests.cs create mode 100644 YKanBan.Tests/YKanBan.Tests.csproj delete mode 100644 YKanBan/ViewLocator.cs diff --git a/YKanBan.Tests/SmokeTests.cs b/YKanBan.Tests/SmokeTests.cs new file mode 100644 index 0000000..19af919 --- /dev/null +++ b/YKanBan.Tests/SmokeTests.cs @@ -0,0 +1,13 @@ +namespace YKanBan.Tests; + +[TestClass] +public class SmokeTests +{ + [TestMethod] + public void ThirdPartyPackagesResolve() + { + Assert.IsNotNull(typeof(Pidgin.Parser).Assembly); + Assert.IsNotNull(typeof(Newtonsoft.Json.JsonConvert).Assembly); + Assert.IsNotNull(typeof(Microsoft.Data.Sqlite.SqliteConnection).Assembly); + } +} diff --git a/YKanBan.Tests/YKanBan.Tests.csproj b/YKanBan.Tests/YKanBan.Tests.csproj new file mode 100644 index 0000000..34fae19 --- /dev/null +++ b/YKanBan.Tests/YKanBan.Tests.csproj @@ -0,0 +1,16 @@ + + + net9.0 + enable + enable + false + + + + + + + + + + diff --git a/YKanBan.slnx b/YKanBan.slnx index c37ab03..abbc2a8 100644 --- a/YKanBan.slnx +++ b/YKanBan.slnx @@ -1,3 +1,4 @@ + diff --git a/YKanBan/App.axaml b/YKanBan/App.axaml index 2ba681d..9fe79d9 100644 --- a/YKanBan/App.axaml +++ b/YKanBan/App.axaml @@ -1,15 +1,9 @@ - - - - - - \ No newline at end of file + diff --git a/YKanBan/App.axaml.cs b/YKanBan/App.axaml.cs index 0c02113..49fba9c 100644 --- a/YKanBan/App.axaml.cs +++ b/YKanBan/App.axaml.cs @@ -1,8 +1,8 @@ +using System.Linq; using Avalonia; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Data.Core; using Avalonia.Data.Core.Plugins; -using System.Linq; using Avalonia.Markup.Xaml; using YKanBan.ViewModels; using YKanBan.Views; @@ -20,8 +20,6 @@ public partial class App : Application { if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { - // Avoid duplicate validations from both Avalonia and the CommunityToolkit. - // More info: https://docs.avaloniaui.net/docs/guides/development-guides/data-validation#manage-validationplugins DisableAvaloniaDataAnnotationValidation(); desktop.MainWindow = new MainWindow { @@ -34,14 +32,12 @@ public partial class App : Application private void DisableAvaloniaDataAnnotationValidation() { - // Get an array of plugins to remove var dataValidationPluginsToRemove = BindingPlugins.DataValidators.OfType().ToArray(); - // remove each entry found foreach (var plugin in dataValidationPluginsToRemove) { BindingPlugins.DataValidators.Remove(plugin); } } -} \ No newline at end of file +} diff --git a/YKanBan/Program.cs b/YKanBan/Program.cs index bbc7334..b63de49 100644 --- a/YKanBan/Program.cs +++ b/YKanBan/Program.cs @@ -1,18 +1,14 @@ -using Avalonia; -using System; +using System; +using Avalonia; namespace YKanBan; sealed class Program { - // Initialization code. Don't use any Avalonia, third-party APIs or any - // SynchronizationContext-reliant code before AppMain is called: things aren't initialized - // yet and stuff might break. [STAThread] public static void Main(string[] args) => BuildAvaloniaApp() .StartWithClassicDesktopLifetime(args); - // Avalonia configuration, don't remove; also used by visual designer. public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure() .UsePlatformDetect() diff --git a/YKanBan/ViewLocator.cs b/YKanBan/ViewLocator.cs deleted file mode 100644 index 651f07e..0000000 --- a/YKanBan/ViewLocator.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using Avalonia.Controls; -using Avalonia.Controls.Templates; -using YKanBan.ViewModels; - -namespace YKanBan; - -public class ViewLocator : IDataTemplate -{ - - public Control? Build(object? param) - { - if (param is null) - return null; - - var name = param.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal); - var type = Type.GetType(name); - - if (type != null) - { - return (Control)Activator.CreateInstance(type)!; - } - - return new TextBlock { Text = "Not Found: " + name }; - } - - public bool Match(object? data) - { - return data is ViewModelBase; - } -} diff --git a/YKanBan/ViewModels/MainWindowViewModel.cs b/YKanBan/ViewModels/MainWindowViewModel.cs index 68fb1ed..dd8a2fd 100644 --- a/YKanBan/ViewModels/MainWindowViewModel.cs +++ b/YKanBan/ViewModels/MainWindowViewModel.cs @@ -2,5 +2,4 @@ public partial class MainWindowViewModel : ViewModelBase { - public string Greeting { get; } = "Welcome to Avalonia!"; } diff --git a/YKanBan/Views/MainWindow.axaml b/YKanBan/Views/MainWindow.axaml index 2233ddf..3f92fd5 100644 --- a/YKanBan/Views/MainWindow.axaml +++ b/YKanBan/Views/MainWindow.axaml @@ -6,15 +6,10 @@ mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="YKanBan.Views.MainWindow" x:DataType="vm:MainWindowViewModel" - Icon="/Assets/avalonia-logo.ico" Title="YKanBan"> - - - diff --git a/YKanBan/YKanBan.csproj b/YKanBan/YKanBan.csproj index bd99f8a..36a8404 100644 --- a/YKanBan/YKanBan.csproj +++ b/YKanBan/YKanBan.csproj @@ -9,7 +9,6 @@ - @@ -18,11 +17,16 @@ - + None All + + + + +