Files
StarterNG/StarterNG/Program.cs
maj00r a3137a27c4 Introduce layers, ports and a composition root
Ports in Application/Abstractions, adapters in Infrastructure, hand-wired
AppServices (no reflection, as PublishAot requires). Adds a test project.
2026-09-04 20:46:51 +02:00

59 lines
1.4 KiB
C#

using Avalonia;
using System;
using System.Threading.Tasks;
using StarterNG.Application;
using StarterNG.Infrastructure;
namespace StarterNG;
static class Program
{
[STAThread]
public static void Main(string[] args)
{
// Composition root first: everything below, including the crash handlers,
// resolves its collaborators from this graph.
AppServices.Initialize();
AppDomain.CurrentDomain.UnhandledException += (_, e) =>
{
if (e.ExceptionObject is Exception ex)
Diagnostics.Log("Unhandled exception", ex);
Diagnostics.Flush();
};
TaskScheduler.UnobservedTaskException += (_, e) =>
{
Diagnostics.Log("Unobserved task exception", e.Exception);
e.SetObserved();
};
try
{
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
}
catch (Exception ex)
{
Diagnostics.Log("Fatal", ex);
throw;
}
finally
{
Diagnostics.Flush();
}
}
private static AppBuilder WithDiagnosticsLogging(this AppBuilder builder)
{
DiagnosticsLogSink.Install();
return builder;
}
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.WithInterFont()
.WithDiagnosticsLogging();
}