-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
81 lines (70 loc) · 3.01 KB
/
Copy pathProgram.cs
File metadata and controls
81 lines (70 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using Avalonia;
using ClaudeLog.Core;
namespace ClaudeLog;
internal static 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 int Main(string[] args)
{
// Before Cli.Run, because this one needs Avalonia and Core deliberately doesn't reference it.
if (args.Contains("--startup")) return Startup();
if (Cli.IsHeadless(args)) return Cli.Run(args);
AppDomain.CurrentDomain.UnhandledException += (_, e) =>
Log.Error("unhandled exception", e.ExceptionObject as Exception ?? new Exception("unknown"));
try
{
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
}
catch (Exception ex)
{
Log.Error("fatal", ex);
return 1;
}
return 0;
}
/// <summary>
/// Boots the UI as far as it can go without showing a window, then exits.
///
/// This is what CI runs against the packaged binary. `--selftest` proves the logic but never
/// touches Avalonia, so a single-file bundle that failed to unpack its native libraries, or a
/// window whose XAML no longer loads, would sail through every other check and only break on
/// the machine that downloaded it. Setup initializes the platform; constructing MainWindow
/// loads the whole window's XAML, styles and templates.
/// </summary>
private static int Startup()
{
Cli.AttachToParentConsole();
try
{
BuildAvaloniaApp().SetupWithoutStarting();
var window = new Views.MainWindow();
var dialog = new Views.TextPrompt();
// The settings dialog binds to Settings with compiled bindings, so constructing it
// with a real one loads its XAML and exercises every one of those bindings' targets.
var settings = new Views.SettingsDialog { DataContext = Settings.Load() };
// The leading "ok" is what CI matches on — reaching this line at all means every
// window constructed. The rest of the sentence is for a human reading the log and can
// be reworded; the sentinel and the type names cannot.
Console.WriteLine($"ok platform started, {window.GetType().Name} " +
$"({window.Width:0}x{window.Height:0}), {dialog.GetType().Name} " +
$"and {settings.GetType().Name} loaded");
return 0;
}
catch (Exception ex)
{
Console.Error.WriteLine($"startup failed: {ex}");
return 1;
}
}
// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
#if DEBUG
.WithDeveloperTools()
#endif
.WithInterFont()
.LogToTrace();
}