using System.IO;
using System.Reflection;
using System.Text.Json;
using System.Windows;
using XFEToolBox.Client.Utilities;
using XFEToolBox.QuickTools;
namespace QuickTools.RuntimeFixture;
public partial class SmokeWindow : Window
{
public SmokeWindow()
{
InitializeComponent();
Loaded += async (_, _) =>
{
string marker = Environment.GetEnvironmentVariable("XFE_QUICKTOOLS_SMOKE_RESULT")!;
try
{
if (string.IsNullOrEmpty(marker)) throw new InvalidOperationException("Only run through the validation harness.");
typeof(QuickToolPaths).GetField("ValidationDataRoot", BindingFlags.Static | BindingFlags.NonPublic)!.SetValue(null, Path.Combine(Path.GetDirectoryName(marker)!, "runtime-isolated-data"));
await Task.Delay(3000);
int pages = 0;
foreach (var kind in Enum.GetValues<QuickToolKind>())
{
var page = QuickToolsBridge.Create(kind.ToString());
FixtureRoot.Children.Clear(); FixtureRoot.Children.Add(page);
await Dispatcher.InvokeAsync(() => { }, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
UpdateLayout();
if (page.ActualWidth <= 0) throw new InvalidOperationException("Missing layout for " + kind);
pages++;
}
if (QrService.Decode(QrService.Encode("runtime 中文")) != "runtime 中文") throw new InvalidOperationException("ZXing runtime failed");
var languages = ScreenTools.OcrLanguages();
var audio = SystemActions.OutputDevices();
var ports = PortInspector.Query();
File.WriteAllText(marker, JsonSerializer.Serialize(new { success = true, pages, languages = languages.Length, audio = audio.Length, endpoints = ports.Count, clr = typeof(object).Assembly.Location, wpf = typeof(Window).Assembly.Location }));
}
catch (Exception e)
{
if (!string.IsNullOrEmpty(marker)) File.WriteAllText(marker, JsonSerializer.Serialize(new { success = false, error = e.ToString() }));
Environment.ExitCode = 1;
}
finally { Close(); }
};
}
}
using System.IO;
using System.Reflection;
using System.Text.Json;
using System.Windows;
using XFEToolBox.Client.Utilities;
using XFEToolBox.QuickTools;
namespace QuickTools.RuntimeFixture;
public partial class SmokeWindow : Window
{
public SmokeWindow()
{
InitializeComponent();
Loaded += async (_, _) =>
{
string marker = Environment.GetEnvironmentVariable("XFE_QUICKTOOLS_SMOKE_RESULT")!;
try
{
if (string.IsNullOrEmpty(marker)) throw new InvalidOperationException("Only run through the validation harness.");
typeof(QuickToolPaths).GetField("ValidationDataRoot", BindingFlags.Static | BindingFlags.NonPublic)!.SetValue(null, Path.Combine(Path.GetDirectoryName(marker)!, "runtime-isolated-data"));
await Task.Delay(3000);
int pages = 0;
foreach (var kind in Enum.GetValues<QuickToolKind>())
{
var page = QuickToolsBridge.Create(kind.ToString());
FixtureRoot.Children.Clear(); FixtureRoot.Children.Add(page);
await Dispatcher.InvokeAsync(() => { }, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
UpdateLayout();
if (page.ActualWidth <= 0) throw new InvalidOperationException("Missing layout for " + kind);
pages++;
}
if (QrService.Decode(QrService.Encode("runtime 中文")) != "runtime 中文") throw new InvalidOperationException("ZXing runtime failed");
var languages = ScreenTools.OcrLanguages();
var audio = SystemActions.OutputDevices();
var ports = PortInspector.Query();
File.WriteAllText(marker, JsonSerializer.Serialize(new { success = true, pages, languages = languages.Length, audio = audio.Length, endpoints = ports.Count, clr = typeof(object).Assembly.Location, wpf = typeof(Window).Assembly.Location }));
}
catch (Exception e)
{
if (!string.IsNullOrEmpty(marker)) File.WriteAllText(marker, JsonSerializer.Serialize(new { success = false, error = e.ToString() }));
Environment.ExitCode = 1;
}
finally { Close(); }
};
}
}