chore: clean up template, add test project and lock dependencies
This commit is contained in:
1 parent
93ea102d89
commit
c1ea39f5da
14 files changed
+93
-93
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>
|
||||
<Project Path="YKanBan.Tests/YKanBan.Tests.csproj" />
|
||||
<Project Path="YKanBan/YKanBan.csproj" />
|
||||
</Solution>
|
||||
+1
-6
@@ -1,13 +1,8 @@
|
||||
<Application xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="YKanBan.App"
|
||||
xmlns:local="using:YKanBan"
|
||||
RequestedThemeVariant="Default">
|
||||
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
|
||||
|
||||
<Application.DataTemplates>
|
||||
<local:ViewLocator/>
|
||||
</Application.DataTemplates>
|
||||
<!-- "Default" theme variant follows the system theme; "Dark" and "Light" are the explicit options. -->
|
||||
|
||||
<Application.Styles>
|
||||
<FluentTheme />
|
||||
|
||||
+15
-17
@@ -1,30 +1,30 @@
|
||||
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;
|
||||
|
||||
namespace YKanBan;
|
||||
|
||||
public partial class App : Application
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
/// <summary>
|
||||
/// Application class controlling the desktop lifetime and the root window composition.
|
||||
/// </summary>
|
||||
public partial class App : Application {
|
||||
public override void Initialize() {
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public override void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
public override void OnFrameworkInitializationCompleted() {
|
||||
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
|
||||
{
|
||||
desktop.MainWindow = new MainWindow {
|
||||
DataContext = new MainWindowViewModel(),
|
||||
};
|
||||
}
|
||||
@@ -32,15 +32,13 @@ public partial class App : Application
|
||||
base.OnFrameworkInitializationCompleted();
|
||||
}
|
||||
|
||||
private void DisableAvaloniaDataAnnotationValidation()
|
||||
{
|
||||
// Get an array of plugins to remove
|
||||
private void DisableAvaloniaDataAnnotationValidation() {
|
||||
// Collect the Avalonia data-validation plugins that clash with the CommunityToolkit.
|
||||
var dataValidationPluginsToRemove =
|
||||
BindingPlugins.DataValidators.OfType<DataAnnotationsValidationPlugin>().ToArray();
|
||||
|
||||
// remove each entry found
|
||||
foreach (var plugin in dataValidationPluginsToRemove)
|
||||
{
|
||||
// Remove every plugin found so validation runs only once.
|
||||
foreach (var plugin in dataValidationPluginsToRemove) {
|
||||
BindingPlugins.DataValidators.Remove(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 172 KiB |
+17
-13
@@ -1,21 +1,25 @@
|
||||
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.
|
||||
/// <summary>
|
||||
/// Application entry point that bootstraps and launches the Avalonia desktop application.
|
||||
/// </summary>
|
||||
sealed class Program {
|
||||
/// <summary>
|
||||
/// Starts the application with the classic desktop lifetime.
|
||||
/// </summary>
|
||||
[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<App>()
|
||||
.UsePlatformDetect()
|
||||
.WithInterFont()
|
||||
.LogToTrace();
|
||||
/// <summary>
|
||||
/// Builds the Avalonia application configuration; also used by the visual designer.
|
||||
/// </summary>
|
||||
public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure<App>()
|
||||
.UsePlatformDetect()
|
||||
.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;
|
||||
|
||||
public partial class MainWindowViewModel : ViewModelBase
|
||||
{
|
||||
public string Greeting { get; } = "Welcome to Avalonia!";
|
||||
/// <summary>
|
||||
/// View model for the main application window.
|
||||
/// </summary>
|
||||
public partial class MainWindowViewModel : ViewModelBase {
|
||||
}
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
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"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:YKanBan.ViewModels"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
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">
|
||||
|
||||
<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>
|
||||
@@ -2,10 +2,11 @@ using Avalonia.Controls;
|
||||
|
||||
namespace YKanBan.Views;
|
||||
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
/// <summary>
|
||||
/// Main application window hosting the kanban user interface.
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window {
|
||||
public MainWindow() {
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,6 @@
|
||||
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Models\" />
|
||||
<AvaloniaResource Include="Assets\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="11.3.6" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.3.6" />
|
||||
@@ -23,6 +18,11 @@
|
||||
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
|
||||
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
|
||||
</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" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in new issue
Block a user