chore: clean up template, add test project and lock dependencies
This commit is contained in:
1 parent
93ea102d89
commit
c1ea39f5da
14 files changed
+98
-98
No files matched your search
@@ -0,0 +1 @@
|
|||||||
|
[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)]
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using YKanBan.ViewModels;
|
||||||
|
|
||||||
|
namespace YKanBan.Tests;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Smoke tests verifying the wiring between the test project and the main application project.
|
||||||
|
/// </summary>
|
||||||
|
[TestClass]
|
||||||
|
public sealed class SmokeTests {
|
||||||
|
/// <summary>
|
||||||
|
/// Verifies that the main application assembly is referenced and can be resolved at runtime.
|
||||||
|
/// </summary>
|
||||||
|
[TestMethod]
|
||||||
|
public void MainAssemblyIsReferenced() {
|
||||||
|
Assert.AreEqual("YKanBan", typeof(ViewModelBase).Assembly.GetName().Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
|
<LangVersion>latest</LangVersion>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="MSTest" Version="4.4.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\YKanBan\YKanBan.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
<Solution>
|
<Solution>
|
||||||
|
<Project Path="YKanBan.Tests/YKanBan.Tests.csproj" />
|
||||||
<Project Path="YKanBan/YKanBan.csproj" />
|
<Project Path="YKanBan/YKanBan.csproj" />
|
||||||
</Solution>
|
</Solution>
|
||||||
+2
-7
@@ -1,15 +1,10 @@
|
|||||||
<Application xmlns="https://github.com/avaloniaui"
|
<Application xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
x:Class="YKanBan.App"
|
x:Class="YKanBan.App"
|
||||||
xmlns:local="using:YKanBan"
|
|
||||||
RequestedThemeVariant="Default">
|
RequestedThemeVariant="Default">
|
||||||
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
|
<!-- "Default" theme variant follows the system theme; "Dark" and "Light" are the explicit options. -->
|
||||||
|
|
||||||
<Application.DataTemplates>
|
|
||||||
<local:ViewLocator/>
|
|
||||||
</Application.DataTemplates>
|
|
||||||
|
|
||||||
<Application.Styles>
|
<Application.Styles>
|
||||||
<FluentTheme />
|
<FluentTheme />
|
||||||
</Application.Styles>
|
</Application.Styles>
|
||||||
</Application>
|
</Application>
|
||||||
+16
-18
@@ -1,30 +1,30 @@
|
|||||||
|
using System.Linq;
|
||||||
|
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
using Avalonia.Data.Core;
|
using Avalonia.Data.Core;
|
||||||
using Avalonia.Data.Core.Plugins;
|
using Avalonia.Data.Core.Plugins;
|
||||||
using System.Linq;
|
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
using YKanBan.ViewModels;
|
using YKanBan.ViewModels;
|
||||||
using YKanBan.Views;
|
using YKanBan.Views;
|
||||||
|
|
||||||
namespace YKanBan;
|
namespace YKanBan;
|
||||||
|
|
||||||
public partial class App : Application
|
/// <summary>
|
||||||
{
|
/// Application class controlling the desktop lifetime and the root window composition.
|
||||||
public override void Initialize()
|
/// </summary>
|
||||||
{
|
public partial class App : Application {
|
||||||
|
public override void Initialize() {
|
||||||
AvaloniaXamlLoader.Load(this);
|
AvaloniaXamlLoader.Load(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnFrameworkInitializationCompleted()
|
public override void OnFrameworkInitializationCompleted() {
|
||||||
{
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) {
|
||||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
// Avoid duplicate validations from both Avalonia and the CommunityToolkit.
|
||||||
{
|
|
||||||
// Avoid duplicate validations from both Avalonia and the CommunityToolkit.
|
|
||||||
// More info: https://docs.avaloniaui.net/docs/guides/development-guides/data-validation#manage-validationplugins
|
// More info: https://docs.avaloniaui.net/docs/guides/development-guides/data-validation#manage-validationplugins
|
||||||
DisableAvaloniaDataAnnotationValidation();
|
DisableAvaloniaDataAnnotationValidation();
|
||||||
desktop.MainWindow = new MainWindow
|
desktop.MainWindow = new MainWindow {
|
||||||
{
|
|
||||||
DataContext = new MainWindowViewModel(),
|
DataContext = new MainWindowViewModel(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -32,15 +32,13 @@ public partial class App : Application
|
|||||||
base.OnFrameworkInitializationCompleted();
|
base.OnFrameworkInitializationCompleted();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DisableAvaloniaDataAnnotationValidation()
|
private void DisableAvaloniaDataAnnotationValidation() {
|
||||||
{
|
// Collect the Avalonia data-validation plugins that clash with the CommunityToolkit.
|
||||||
// Get an array of plugins to remove
|
|
||||||
var dataValidationPluginsToRemove =
|
var dataValidationPluginsToRemove =
|
||||||
BindingPlugins.DataValidators.OfType<DataAnnotationsValidationPlugin>().ToArray();
|
BindingPlugins.DataValidators.OfType<DataAnnotationsValidationPlugin>().ToArray();
|
||||||
|
|
||||||
// remove each entry found
|
// Remove every plugin found so validation runs only once.
|
||||||
foreach (var plugin in dataValidationPluginsToRemove)
|
foreach (var plugin in dataValidationPluginsToRemove) {
|
||||||
{
|
|
||||||
BindingPlugins.DataValidators.Remove(plugin);
|
BindingPlugins.DataValidators.Remove(plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 172 KiB |
+18
-14
@@ -1,21 +1,25 @@
|
|||||||
using Avalonia;
|
using System;
|
||||||
using System;
|
|
||||||
|
using Avalonia;
|
||||||
|
|
||||||
namespace YKanBan;
|
namespace YKanBan;
|
||||||
|
|
||||||
sealed class Program
|
/// <summary>
|
||||||
{
|
/// Application entry point that bootstraps and launches the Avalonia desktop application.
|
||||||
// Initialization code. Don't use any Avalonia, third-party APIs or any
|
/// </summary>
|
||||||
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
|
sealed class Program {
|
||||||
// yet and stuff might break.
|
/// <summary>
|
||||||
|
/// Starts the application with the classic desktop lifetime.
|
||||||
|
/// </summary>
|
||||||
[STAThread]
|
[STAThread]
|
||||||
public static void Main(string[] args) => BuildAvaloniaApp()
|
public static void Main(string[] args) => BuildAvaloniaApp()
|
||||||
.StartWithClassicDesktopLifetime(args);
|
.StartWithClassicDesktopLifetime(args);
|
||||||
|
|
||||||
// Avalonia configuration, don't remove; also used by visual designer.
|
/// <summary>
|
||||||
public static AppBuilder BuildAvaloniaApp()
|
/// Builds the Avalonia application configuration; also used by the visual designer.
|
||||||
=> AppBuilder.Configure<App>()
|
/// </summary>
|
||||||
.UsePlatformDetect()
|
public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure<App>()
|
||||||
.WithInterFont()
|
.UsePlatformDetect()
|
||||||
.LogToTrace();
|
.WithInterFont()
|
||||||
}
|
.LogToTrace();
|
||||||
|
}
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
namespace YKanBan.ViewModels;
|
namespace YKanBan.ViewModels;
|
||||||
|
|
||||||
public partial class MainWindowViewModel : ViewModelBase
|
/// <summary>
|
||||||
{
|
/// View model for the main application window.
|
||||||
public string Greeting { get; } = "Welcome to Avalonia!";
|
/// </summary>
|
||||||
}
|
public partial class MainWindowViewModel : ViewModelBase {
|
||||||
|
}
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace YKanBan.ViewModels;
|
namespace YKanBan.ViewModels;
|
||||||
|
|
||||||
public class ViewModelBase : ObservableObject
|
/// <summary>
|
||||||
{
|
/// Base class for all view models, providing property change notification.
|
||||||
}
|
/// </summary>
|
||||||
|
public class ViewModelBase : ObservableObject {
|
||||||
|
}
|
||||||
@@ -1,20 +1,8 @@
|
|||||||
<Window xmlns="https://github.com/avaloniaui"
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:vm="using:YKanBan.ViewModels"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="YKanBan.Views.MainWindow"
|
x:Class="YKanBan.Views.MainWindow"
|
||||||
x:DataType="vm:MainWindowViewModel"
|
|
||||||
Icon="/Assets/avalonia-logo.ico"
|
|
||||||
Title="YKanBan">
|
Title="YKanBan">
|
||||||
|
|
||||||
<Design.DataContext>
|
|
||||||
<!-- This only sets the DataContext for the previewer in an IDE,
|
|
||||||
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
|
|
||||||
<vm:MainWindowViewModel/>
|
|
||||||
</Design.DataContext>
|
|
||||||
|
|
||||||
<TextBlock Text="{Binding Greeting}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
|
||||||
|
|
||||||
</Window>
|
</Window>
|
||||||
@@ -2,10 +2,11 @@ using Avalonia.Controls;
|
|||||||
|
|
||||||
namespace YKanBan.Views;
|
namespace YKanBan.Views;
|
||||||
|
|
||||||
public partial class MainWindow : Window
|
/// <summary>
|
||||||
{
|
/// Main application window hosting the kanban user interface.
|
||||||
public MainWindow()
|
/// </summary>
|
||||||
{
|
public partial class MainWindow : Window {
|
||||||
|
public MainWindow() {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,11 +8,6 @@
|
|||||||
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Models\" />
|
|
||||||
<AvaloniaResource Include="Assets\**" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia" Version="11.3.6" />
|
<PackageReference Include="Avalonia" Version="11.3.6" />
|
||||||
<PackageReference Include="Avalonia.Desktop" Version="11.3.6" />
|
<PackageReference Include="Avalonia.Desktop" Version="11.3.6" />
|
||||||
@@ -23,6 +18,11 @@
|
|||||||
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
|
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
|
||||||
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
|
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="Semi.Avalonia" Version="11.2.1.10" />
|
||||||
|
<PackageReference Include="IconPacks.Avalonia.Lucide" Version="2.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.20" />
|
||||||
|
<PackageReference Include="Pidgin" Version="3.5.1" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
|
||||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
|
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
Reference in new issue
Block a user