Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
351c30895e | ||
|
|
dcf5796bf2 |
No files matched your search
@@ -21,6 +21,16 @@ under a `## [x.y.z] - date` heading in the same commit that bumps `VERSION`, the
|
||||
|
||||
### Added
|
||||
|
||||
- **The bug report's last optional item: the last session's summary, when ticked (2026-09-15).** `10_LOGGING` §Bug
|
||||
report flow step 2 listed "last session metadata + aggregates JSON (never raw blobs by default)" beside the crash
|
||||
dump, and `legal/PRIVACY_POLICY.md` §3 promises both only when ticked. The Optional items dialog PR-9 added now shows
|
||||
a box for each item that exists: the crash dump, and the newest session in the ledger (`LastSessionSummary`) labelled
|
||||
with its game and start time. Ticked, the zip gains `session.json`, File ▸ Export's own JSON (metadata, aggregates,
|
||||
segments, hardware) without the user's notes and tags, passed through `LogRedactor` because it names the executable;
|
||||
no frame or sensor series. With neither item there is no question. `CrashDumpChoice` became `BugBundleOptions`, and
|
||||
`IBugReportPreview.AskCrashDumpAsync` became `AskOptionsAsync(BugBundleOffer)`. Two strings (en/vi/ja). Tests:
|
||||
`LastSessionSummaryTests`, `BugReportFlowTests`, `BugBundleOptionsViewModelTests`, `PagesLoadTests`. Docs:
|
||||
`10_LOGGING` §Bug report flow step 2.
|
||||
- **P4 PR-9 — the crash dialog, the minidump in both processes, and the crash dump as the bug report's opt-in
|
||||
(2026-09-15).** `10_LOGGING` §Crash handling specified Fatal → `MiniDumpWriteDump` → a dialog offering the bug report
|
||||
→ exit code 1; only the Fatal line existed, and `Crash_Title` / `Crash_Body` were translated for a dialog nothing
|
||||
@@ -241,6 +251,18 @@ under a `## [x.y.z] - date` heading in the same commit that bumps `VERSION`, the
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Bug bundles no longer carry the user's name in log paths, which the privacy policy already promised
|
||||
(2026-09-15).** `legal/PRIVACY_POLICY.md` §3 says "logs are redacted (user directory paths removed) before
|
||||
bundling" and `10_LOGGING` named a `RedactingEnricher`; neither existed, and `BugBundleBuilder` copied `ui-*.log`,
|
||||
`agent-*.log` and `overlay-*.log` verbatim on the stated ground that they carry no paths beyond the data directory,
|
||||
which is itself under the user's profile. On the dev box the profile path appeared 8 times in the UI log, 7 in the
|
||||
Agent's and in 175 overlay headers. `App/Services/LogRedactor` now rewrites every log copy in the zip: the name in
|
||||
each `X:\Users\<name>` path becomes `<user>`, and so does a profile directory's last segment elsewhere, in
|
||||
backslash, doubled-backslash (Serilog's JSON), forward-slash, any-case and ANSI-`?` spellings, byte for byte
|
||||
otherwise (Latin-1 round trip, so UTF-8 and ANSI logs both survive). The files on disk keep their paths; the policy's
|
||||
sentence is now true without a word of it changing. Tests: `LogRedactorTests`, `BugBundleBuilderTests`. Docs:
|
||||
`10_LOGGING` §Serilog configuration (the enricher claim struck, with where the rule is enforced) and §Bug report
|
||||
flow step 2.
|
||||
- **Test runs stop filling the real data folder with hook-harness logs (2026-09-15).** The injection tests inject the
|
||||
shipped Overlay, whose log goes to `%LOCALAPPDATA%\FrameLedger\logs` by design (§S21: not the environment, and no
|
||||
switch in the injected DLL), so the owner's folder held 2506 overlay logs, 2492 of them hook-harness's from test
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
- Minimum level `Information` (`Debug` toggle in Settings → applies live via `LoggingLevelSwitch`).
|
||||
- Enrichers: process name, version, `SessionGuid` and `GamePid` scoped properties during capture (`LogContext.PushProperty`).
|
||||
- Template: `[{Timestamp:HH:mm:ss.fff} {Level:u3}] {SourceContext} {Message:lj} {Properties:j}{NewLine}{Exception}`.
|
||||
- **Never log:** full user paths outside `%LOCALAPPDATA%\FrameLedger` (redact to `<user>`), machine name, any exe arguments of games. A `RedactingEnricher` enforces the path rule.
|
||||
- **Never log:** full user paths outside `%LOCALAPPDATA%\FrameLedger` (redact to `<user>`), machine name, any exe arguments of games. ~~A `RedactingEnricher` enforces the path rule.~~ *(No such enricher was ever written: found 2026-09-15, checking `legal/PRIVACY_POLICY.md` §3's "logs are redacted (user directory paths removed) before bundling" against the bundle, which copied the logs verbatim. An enricher could not have kept the rule anyway: exception text and the Overlay's native log never pass through one, and the data directory itself sits under the user's profile, so every run logs a user name. The rule is enforced where a log leaves the machine instead: `App/Services/LogRedactor` over every log copy in the bug bundle, §Bug report flow step 2. The files in `logs\` keep their full paths; they leave the PC only if the user copies them.)*
|
||||
- Capture hot path logs nothing per-frame; counters summarized at finalize.
|
||||
|
||||
## Crash handling (the app's own crashes)
|
||||
@@ -67,8 +67,9 @@ Tails the active files (shared read), level filter, text search, pause autoscrol
|
||||
> **Step 2 built 2026-09-14 (P3 PR-8a), narrower than this list; steps 1 (Help menu, crash dialog), 3, 4 and 5
|
||||
> are P4's.** `App/Services/BugBundleBuilder` writes the zip where the Logs page's save dialog says
|
||||
> (`FrameLedger-bugreport-YYYYMMDD-HHmm.zip`): `logs/` = every `ui-*.log` and `agent-*.log` modified in the last
|
||||
> seven days, **copied verbatim, not redacted** — the files carry no paths beyond the data directory and no
|
||||
> game data, and a redaction pass that nobody has specified would be a claim; `overlay/` = the five newest
|
||||
> seven days, ~~**copied verbatim, not redacted** — the files carry no paths beyond the data directory and no
|
||||
> game data, and a redaction pass that nobody has specified would be a claim~~ **redacted since 2026-09-15, note
|
||||
> below** (the data directory is under the user's profile, so the claim was false on every machine); `overlay/` = the five newest
|
||||
> `overlay-<pid>-*.log` (the ring's counters and the `FAULT`/`UNHOOK_*` lines are in those files, not
|
||||
> separately); `sysinfo.json` = app version, and from the Agent's `HelloAck` when connected its version, the
|
||||
> overlay build id, telemetry source, Vulkan layer state, elevation, CPU-temperature availability (the
|
||||
@@ -90,7 +91,20 @@ Tails the active files (shared read), level filter, text search, pause autoscrol
|
||||
> summary as Markdown** puts `sysinfo.json`'s twelve keys on the clipboard as a table. Both behind ports
|
||||
> (`IBugReportPreview`, `IUrlOpener`, `IClipboard`) so `BugReportFlowTests` pins the exact URL without a browser.
|
||||
> ~~Still open from this list: the **crash dialog and the minidump** (§Crash handling, step 1's third entry point)
|
||||
> and the optional session-metadata / dump checkboxes of step 2.~~ PR-9 below; the session-metadata checkbox is open.
|
||||
> and the optional session-metadata / dump checkboxes of step 2.~~ PR-9 below, and the session-metadata checkbox after it (2026-09-15).
|
||||
>
|
||||
> **The log copies are redacted since 2026-09-15.** `App/Services/LogRedactor` is what the list's "redacted copies"
|
||||
> and `legal/PRIVACY_POLICY.md` §3 promised: in every `logs/` and `overlay/` entry the name in each
|
||||
> `X:\Users\<name>` path becomes `<user>`, and so does the last segment of this user's profile directory when it
|
||||
> lives elsewhere (`D:\Profiles\<name>`). Every spelling a log carries is covered: backslashes, the doubled
|
||||
> backslashes of Serilog's JSON properties, forward slashes, any case, a name with spaces, and the `?` the Overlay's
|
||||
> ANSI image path writes for a letter its code page lacks. The file is read as bytes through Latin-1, so a UTF-8
|
||||
> log and an ANSI one both come out byte for byte except the names. Over-redaction is the chosen failure:
|
||||
> `C:\Users\Public` reads `<user>` too. The measured need on the dev box: the profile path appeared 8 times in
|
||||
> `ui-*.log`, 7 in `agent-*.log` and in 175 overlay headers; no machine name or bare user name did. A crash dump is
|
||||
> memory and cannot be redacted, which its checkbox says. Tests: `LogRedactorTests` (fifteen cases, both
|
||||
> directions, UTF-8 and ANSI bytes), `BugBundleBuilderTests` (the copies carry no user name, the file on disk is
|
||||
> untouched).
|
||||
>
|
||||
> **The crash dump's checkbox and step 1's third entry point built 2026-09-15 (P4 PR-9).** When
|
||||
> `BugBundleBuilder.LatestCrashDump` finds a `*.dmp` written in the last seven days under `crashdumps\` (either
|
||||
@@ -100,10 +114,21 @@ Tails the active files (shared read), level filter, text search, pause autoscrol
|
||||
> settings. Continue with the box clear writes the bundle without it; ticked, `crashdumps/<name>.dmp` goes in;
|
||||
> Cancel writes nothing. `WriteAsync` refuses a dump from anywhere but that directory, before the zip is created. It
|
||||
> is a dialog before the save rather than a box on step 3's preview because the preview lists a zip that is already
|
||||
> written. The crash dialog (§Crash handling) is step 1's third entry point. Still open: the session-metadata
|
||||
> checkbox. Tests: `BugBundleBuilderTests` (only when passed, only from the directory, the newest of the week),
|
||||
> `BugReportFlowTests` (no dump no question; left clear, ticked, cancelled), `BugBundleOptionsViewModelTests`,
|
||||
> `PagesLoadTests`.
|
||||
> written. The crash dialog (§Crash handling) is step 1's third entry point. ~~Still open: the session-metadata
|
||||
> checkbox.~~ Built the same day, below. Tests: `BugBundleBuilderTests` (only when passed, only from the directory,
|
||||
> the newest of the week), `BugReportFlowTests` (no dump no question; left clear, ticked, cancelled),
|
||||
> `BugBundleOptionsViewModelTests`, `PagesLoadTests`.
|
||||
>
|
||||
> **The last session's checkbox built 2026-09-15**, which completes this list's optional items. The same **Optional
|
||||
> items** dialog carries a second box when the ledger holds a session: the newest one (`App/Services/LastSessionSummary`),
|
||||
> labelled with its game and local start time, with a line saying what the file holds. Ticked, the bundle gains
|
||||
> `session.json`: File ▸ Export's own JSON (`SessionExporter.Document` — metadata, aggregates, segments, hardware)
|
||||
> **without the user's notes and tags**, and passed through `LogRedactor` like a log because it names the executable.
|
||||
> No frame or sensor series, which is the list's "never raw blobs". The dialog now appears when either item exists and
|
||||
> not at all when neither does; the port's answer is `BugBundleOptions` (closed, or which boxes were ticked) where
|
||||
> PR-9's was `CrashDumpChoice`. Tests: `LastSessionSummaryTests` (the newest session, no notes or tags, nothing for an
|
||||
> empty ledger), `BugReportFlowTests` (left clear, and ticked with a profile path redacted in the zip),
|
||||
> `BugBundleOptionsViewModelTests` (every box clear, an absent item cannot be included), `PagesLoadTests`.
|
||||
3. **Preview step:** the dialog lists every file included and lets the user open the zip before continuing. Nothing is ever sent automatically.
|
||||
4. "Open GitHub issue" → launches browser to
|
||||
`https://github.com/poli0981/frameledger/issues/new?template=bug_report.yml&title=[Bug]%20&labels=bug&app_version=…&os=…`
|
||||
|
||||
@@ -280,13 +280,14 @@ public partial class App : System.Windows.Application
|
||||
services.AddSingleton<IRunAtLogon, RunAtLogonRegistry>();
|
||||
services.AddSingleton<SafetyNotices>();
|
||||
services.AddSingleton(static _ => new LogTail(UiPaths.Logs));
|
||||
services.AddSingleton(static sp => new BugBundleBuilder(UiPaths.Logs, sp.GetRequiredService<RegisteredSettings>(), crashDumpDirectory: UiPaths.CrashDumps));
|
||||
services.AddSingleton(static sp => new BugBundleBuilder(UiPaths.Logs, sp.GetRequiredService<RegisteredSettings>(), crashDumpDirectory: UiPaths.CrashDumps, redactor: LogRedactor.ForCurrentUser()));
|
||||
|
||||
// The bug report's steps 3-4 and the shell's Export (P4 PR-3): the preview dialog, the browser, the clipboard,
|
||||
// the flow over them, the session the shell exports, and the CSV/JSON service the summary window's writers serve.
|
||||
services.AddSingleton<IUrlOpener, ShellUrlOpener>();
|
||||
services.AddSingleton<IClipboard, WpfClipboard>();
|
||||
services.AddSingleton<IBugReportPreview, BugReportPreviewPrompt>();
|
||||
services.AddSingleton<LastSessionSummary>();
|
||||
services.AddSingleton<BugReportFlow>();
|
||||
services.AddSingleton<SessionSelection>();
|
||||
services.AddSingleton<SessionExportService>();
|
||||
|
||||
@@ -9,13 +9,19 @@
|
||||
mc:Ignorable="d"
|
||||
MinWidth="480">
|
||||
<!--
|
||||
10_LOGGING §Bug report flow step 2's optional item (P4 PR-9): the crash dump goes in only when it is ticked
|
||||
(legal/PRIVACY_POLICY.md §3). The box starts clear, and its label and the line under it say how large the dump is
|
||||
and what it can hold before anyone ticks it.
|
||||
10_LOGGING §Bug report flow step 2's optional items: the crash dump (P4 PR-9) and the last session's summary each go
|
||||
in only when ticked (legal/PRIVACY_POLICY.md §3). Only the items there are get a box; every box starts clear, and
|
||||
the line under it says what the item holds before anyone ticks it.
|
||||
-->
|
||||
<StackPanel>
|
||||
<ui:TextBlock TextWrapping="Wrap" Text="{x:Static vm:BugBundleOptionsViewModel.Intro}" />
|
||||
<CheckBox Margin="0,12,0,0" IsChecked="{Binding IncludeCrashDump}" Content="{Binding DumpLabel}" />
|
||||
<ui:TextBlock Margin="28,4,0,0" Appearance="Secondary" TextWrapping="Wrap" Text="{x:Static vm:BugBundleOptionsViewModel.DumpDetail}" />
|
||||
<StackPanel Visibility="{Binding HasCrashDump, Converter={StaticResource BoolToVis}}">
|
||||
<CheckBox Margin="0,12,0,0" IsChecked="{Binding IncludeCrashDump}" Content="{Binding DumpLabel}" />
|
||||
<ui:TextBlock Margin="28,4,0,0" Appearance="Secondary" TextWrapping="Wrap" Text="{x:Static vm:BugBundleOptionsViewModel.DumpDetail}" />
|
||||
</StackPanel>
|
||||
<StackPanel Visibility="{Binding HasLastSession, Converter={StaticResource BoolToVis}}">
|
||||
<CheckBox Margin="0,12,0,0" IsChecked="{Binding IncludeLastSession}" Content="{Binding SessionLabel}" />
|
||||
<ui:TextBlock Margin="28,4,0,0" Appearance="Secondary" TextWrapping="Wrap" Text="{x:Static vm:BugBundleOptionsViewModel.SessionDetail}" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
@@ -11,7 +11,8 @@ namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// <c>10_LOGGING</c> §Bug report flow, step 2 — the bundle: <c>logs/</c> (this app's and the Agent's files of the
|
||||
/// last seven days), the last <c>overlay-*.log</c> files, <c>sysinfo.json</c> (app, agent, overlay build id, OS,
|
||||
/// last seven days) and the last <c>overlay-*.log</c> files, both as copies with every user name in a path replaced
|
||||
/// (<see cref="LogRedactor"/>), <c>sysinfo.json</c> (app, agent, overlay build id, OS,
|
||||
/// locale, telemetry source, Vulkan layer state, elevation), <c>settings.json</c> (the registry's keys and values —
|
||||
/// no paths), and <c>crashdumps/</c> with one minidump only when the user ticked it (P4 PR-9). We ship our files only,
|
||||
/// never a game's; nothing is sent anywhere (<see cref="BugReportFlow"/> is steps 3 and 4).
|
||||
@@ -24,18 +25,21 @@ public sealed class BugBundleBuilder
|
||||
private readonly RegisteredSettings _settings;
|
||||
private readonly TimeProvider _clock;
|
||||
private readonly string? _crashDumps;
|
||||
private readonly LogRedactor _redactor;
|
||||
|
||||
/// <summary>A builder over the logs directory, the settings registry and, when given, the crash dump directory.</summary>
|
||||
/// <param name="logsDirectory">The logs directory: ours and the Overlay's.</param>
|
||||
/// <param name="settings">The registry the bundle's <c>settings.json</c> reads.</param>
|
||||
/// <param name="clock">The seven-day cut's clock.</param>
|
||||
/// <param name="crashDumpDirectory">The minidumps' directory (P4 PR-9); null offers none.</param>
|
||||
public BugBundleBuilder(string logsDirectory, RegisteredSettings settings, TimeProvider? clock = null, string? crashDumpDirectory = null)
|
||||
/// <param name="redactor">What the log copies pass through; the current user's by default.</param>
|
||||
public BugBundleBuilder(string logsDirectory, RegisteredSettings settings, TimeProvider? clock = null, string? crashDumpDirectory = null, LogRedactor? redactor = null)
|
||||
{
|
||||
_logs = logsDirectory ?? throw new ArgumentNullException(nameof(logsDirectory));
|
||||
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
|
||||
_clock = clock ?? TimeProvider.System;
|
||||
_crashDumps = crashDumpDirectory;
|
||||
_redactor = redactor ?? LogRedactor.ForCurrentUser();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -59,9 +63,10 @@ public sealed class BugBundleBuilder
|
||||
|
||||
/// <summary>
|
||||
/// Writes the zip at <paramref name="path"/>; returns the entry names written. <paramref name="crashDump"/> goes in only
|
||||
/// when the caller passes one, which is the user's tick (P4 PR-9), and only from the crash dump directory.
|
||||
/// when the caller passes one, which is the user's tick (P4 PR-9), and only from the crash dump directory;
|
||||
/// <paramref name="lastSessionJson"/> likewise, as <c>session.json</c> with the user names in its paths replaced.
|
||||
/// </summary>
|
||||
public async Task<IReadOnlyList<string>> WriteAsync(string path, HelloAck? agent, CrashDumpInfo? crashDump = null, CancellationToken ct = default)
|
||||
public async Task<IReadOnlyList<string>> WriteAsync(string path, HelloAck? agent, CrashDumpInfo? crashDump = null, byte[]? lastSessionJson = null, CancellationToken ct = default)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(path);
|
||||
if (crashDump is not null && !IsOurDump(crashDump.Path))
|
||||
@@ -77,12 +82,12 @@ public sealed class BugBundleBuilder
|
||||
{
|
||||
foreach (string log in Directory.EnumerateFiles(_logs, "*.log").Where(f => IsOurs(f) && File.GetLastWriteTimeUtc(f) >= cutoff))
|
||||
{
|
||||
AddFile(zip, log, "logs/" + Path.GetFileName(log), written);
|
||||
AddRedactedFile(zip, log, "logs/" + Path.GetFileName(log), written);
|
||||
}
|
||||
|
||||
foreach (string overlay in Directory.EnumerateFiles(_logs, "overlay-*.log").OrderByDescending(File.GetLastWriteTimeUtc).Take(OverlayLogsKept))
|
||||
{
|
||||
AddFile(zip, overlay, "overlay/" + Path.GetFileName(overlay), written);
|
||||
AddRedactedFile(zip, overlay, "overlay/" + Path.GetFileName(overlay), written);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,6 +97,12 @@ public sealed class BugBundleBuilder
|
||||
AddFile(zip, crashDump.Path, "crashdumps/" + Path.GetFileName(crashDump.Path), written);
|
||||
}
|
||||
|
||||
// The other optional item: the last session's summary the user ticked, redacted like a log (it names the executable).
|
||||
if (lastSessionJson is not null)
|
||||
{
|
||||
AddBytes(zip, "session.json", _redactor.Redact(lastSessionJson), written);
|
||||
}
|
||||
|
||||
AddText(zip, "sysinfo.json", SysInfo(agent), written);
|
||||
AddText(zip, "settings.json", await SettingsJsonAsync(ct).ConfigureAwait(false), written);
|
||||
return written;
|
||||
@@ -121,6 +132,29 @@ public sealed class BugBundleBuilder
|
||||
written.Add(entryName);
|
||||
}
|
||||
|
||||
// legal/PRIVACY_POLICY.md §3: a log leaves this machine only as a copy with the user names in its paths replaced. A log is
|
||||
// at most 10 MB (Serilog's roll size), so it is read whole; a crash dump is memory and goes in as it is, behind its box.
|
||||
private void AddRedactedFile(ZipArchive zip, string source, string entryName, List<string> written)
|
||||
{
|
||||
byte[] bytes;
|
||||
using (var stream = new FileStream(source, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete))
|
||||
using (var buffer = new MemoryStream())
|
||||
{
|
||||
stream.CopyTo(buffer);
|
||||
bytes = buffer.ToArray();
|
||||
}
|
||||
|
||||
AddBytes(zip, entryName, _redactor.Redact(bytes), written);
|
||||
}
|
||||
|
||||
private static void AddBytes(ZipArchive zip, string entryName, byte[] bytes, List<string> written)
|
||||
{
|
||||
ZipArchiveEntry entry = zip.CreateEntry(entryName, CompressionLevel.Optimal);
|
||||
using Stream target = entry.Open();
|
||||
target.Write(bytes, 0, bytes.Length);
|
||||
written.Add(entryName);
|
||||
}
|
||||
|
||||
private static void AddText(ZipArchive zip, string entryName, string text, List<string> written)
|
||||
{
|
||||
ZipArchiveEntry entry = zip.CreateEntry(entryName, CompressionLevel.Optimal);
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// The optional items a bug report can offer (<c>10_LOGGING</c> §Bug report flow step 2), each null when there is none:
|
||||
/// the newest crash dump of the last seven days (P4 PR-9) and the last session's summary.
|
||||
/// </summary>
|
||||
public sealed record BugBundleOffer(CrashDumpInfo? CrashDump, LastSessionInfo? LastSession)
|
||||
{
|
||||
/// <summary>Nothing to offer, so no question is asked.</summary>
|
||||
public bool IsEmpty => CrashDump is null && LastSession is null;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// The answer to the optional items (<c>legal/PRIVACY_POLICY.md</c> §3: included only when ticked): the dialog closed, or
|
||||
/// which boxes were ticked. Every box starts clear.
|
||||
/// </summary>
|
||||
public sealed record BugBundleOptions(bool Cancelled, bool IncludeCrashDump, bool IncludeLastSession)
|
||||
{
|
||||
/// <summary>The dialog was closed: no bundle is written.</summary>
|
||||
public static BugBundleOptions Cancel { get; } = new(Cancelled: true, IncludeCrashDump: false, IncludeLastSession: false);
|
||||
|
||||
/// <summary>Continue with every box clear, and what an empty offer means.</summary>
|
||||
public static BugBundleOptions NothingTicked { get; } = new(Cancelled: false, IncludeCrashDump: false, IncludeLastSession: false);
|
||||
}
|
||||
@@ -7,7 +7,7 @@ namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// <c>10_LOGGING</c> §Bug report flow, steps 2–4 in one place (P4 PR-3), reached from Help ▸ Report a bug, the Logs
|
||||
/// page's button and the crash dialog (P4 PR-9): a recent crash dump offered as a checkbox that starts clear, the zip
|
||||
/// page's button and the crash dialog (P4 PR-9): a recent crash dump and the last session offered as checkboxes that start clear, the zip
|
||||
/// where the user says (step 2, <see cref="BugBundleBuilder"/>), the preview listing every entry (step 3), then either
|
||||
/// the GitHub issue form with the two short fields prefilled or the environment summary on the clipboard as Markdown
|
||||
/// (step 4). Nothing is ever sent automatically; the zip is dragged in by hand.
|
||||
@@ -23,8 +23,9 @@ public sealed class BugReportFlow
|
||||
private readonly IClipboard _clipboard;
|
||||
private readonly IMessageStrip _strip;
|
||||
private readonly TimeProvider _clock;
|
||||
private readonly LastSessionSummary? _lastSession;
|
||||
|
||||
public BugReportFlow(BugBundleBuilder bundles, IFileSaver saver, IAgentRequests agent, IBugReportPreview preview, IUrlOpener urls, IClipboard clipboard, IMessageStrip strip, TimeProvider? clock = null)
|
||||
public BugReportFlow(BugBundleBuilder bundles, IFileSaver saver, IAgentRequests agent, IBugReportPreview preview, IUrlOpener urls, IClipboard clipboard, IMessageStrip strip, TimeProvider? clock = null, LastSessionSummary? lastSession = null)
|
||||
{
|
||||
_bundles = bundles ?? throw new ArgumentNullException(nameof(bundles));
|
||||
_saver = saver ?? throw new ArgumentNullException(nameof(saver));
|
||||
@@ -34,13 +35,14 @@ public sealed class BugReportFlow
|
||||
_clipboard = clipboard ?? throw new ArgumentNullException(nameof(clipboard));
|
||||
_strip = strip ?? throw new ArgumentNullException(nameof(strip));
|
||||
_clock = clock ?? TimeProvider.System;
|
||||
_lastSession = lastSession;
|
||||
}
|
||||
|
||||
/// <summary>The whole flow; the outcome says how far it went, for the tests and the caller's log.</summary>
|
||||
public async Task<BugReportOutcome> RunAsync(CancellationToken ct = default)
|
||||
{
|
||||
DateTimeOffset now = _clock.GetUtcNow();
|
||||
(bool cancelled, CrashDumpInfo? dump) = await ChooseCrashDumpAsync(ct).ConfigureAwait(true);
|
||||
(bool cancelled, CrashDumpInfo? dump, byte[]? sessionJson) = await ChooseOptionalItemsAsync(ct).ConfigureAwait(true);
|
||||
if (cancelled)
|
||||
{
|
||||
return new BugReportOutcome(null, BugReportChoice.Close, Written: false);
|
||||
@@ -56,7 +58,7 @@ public sealed class BugReportFlow
|
||||
IReadOnlyList<string> entries;
|
||||
try
|
||||
{
|
||||
entries = await _bundles.WriteAsync(path, hello, dump, ct).ConfigureAwait(true);
|
||||
entries = await _bundles.WriteAsync(path, hello, dump, sessionJson, ct).ConfigureAwait(true);
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
@@ -91,18 +93,28 @@ public sealed class BugReportFlow
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Step 2's optional item (P4 PR-9): a crash dump of the last seven days is offered before the save dialog, in a
|
||||
/// checkbox that starts clear. No dump, no question; the dump comes back only when it was ticked.
|
||||
/// Step 2's optional items, offered before the save dialog, each in a checkbox that starts clear: a crash dump of the
|
||||
/// last seven days (P4 PR-9) and the last session's summary. Nothing to offer, no question; an item comes back only
|
||||
/// when it was ticked.
|
||||
/// </summary>
|
||||
private async Task<(bool Cancelled, CrashDumpInfo? Dump)> ChooseCrashDumpAsync(CancellationToken ct)
|
||||
private async Task<(bool Cancelled, CrashDumpInfo? Dump, byte[]? SessionJson)> ChooseOptionalItemsAsync(CancellationToken ct)
|
||||
{
|
||||
CrashDumpInfo? dump = _bundles.LatestCrashDump();
|
||||
if (dump is null)
|
||||
LastSessionInfo? session = _lastSession is null ? null : await _lastSession.FindAsync(ct).ConfigureAwait(true);
|
||||
var offer = new BugBundleOffer(_bundles.LatestCrashDump(), session);
|
||||
if (offer.IsEmpty)
|
||||
{
|
||||
return (false, null);
|
||||
return (false, null, null);
|
||||
}
|
||||
|
||||
CrashDumpChoice answer = await _preview.AskCrashDumpAsync(dump, ct).ConfigureAwait(true);
|
||||
return (answer == CrashDumpChoice.Cancel, answer == CrashDumpChoice.Include ? dump : null);
|
||||
BugBundleOptions options = await _preview.AskOptionsAsync(offer, ct).ConfigureAwait(true);
|
||||
if (options.Cancelled)
|
||||
{
|
||||
return (true, null, null);
|
||||
}
|
||||
|
||||
byte[]? json = options.IncludeLastSession && session is not null && _lastSession is not null
|
||||
? await _lastSession.JsonAsync(session.SessionId, ct).ConfigureAwait(true)
|
||||
: null;
|
||||
return (false, options.IncludeCrashDump ? offer.CrashDump : null, json);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// The bug report's dialogs in WPF UI: step 3's <c>ContentDialog</c> listing the zip's entries, whose primary button is
|
||||
/// step 4 and whose secondary is the clipboard fallback; and step 2's optional crash dump, a checkbox (P4 PR-9).
|
||||
/// step 4 and whose secondary is the clipboard fallback; and step 2's optional items, a checkbox each.
|
||||
/// </summary>
|
||||
public sealed class BugReportPreviewPrompt : IBugReportPreview
|
||||
{
|
||||
@@ -38,10 +38,10 @@ public sealed class BugReportPreviewPrompt : IBugReportPreview
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<CrashDumpChoice> AskCrashDumpAsync(CrashDumpInfo dump, CancellationToken ct = default)
|
||||
public async Task<BugBundleOptions> AskOptionsAsync(BugBundleOffer offer, CancellationToken ct = default)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(dump);
|
||||
var viewModel = new BugBundleOptionsViewModel(dump);
|
||||
ArgumentNullException.ThrowIfNull(offer);
|
||||
var viewModel = new BugBundleOptionsViewModel(offer);
|
||||
var dialog = new ContentDialog
|
||||
{
|
||||
Title = BugBundleOptionsViewModel.Title,
|
||||
@@ -53,6 +53,6 @@ public sealed class BugReportPreviewPrompt : IBugReportPreview
|
||||
};
|
||||
|
||||
ContentDialogResult result = await _dialogs.ShowAsync(dialog, ct).ConfigureAwait(true);
|
||||
return viewModel.Choice(result == ContentDialogResult.Primary);
|
||||
return viewModel.Options(result == ContentDialogResult.Primary);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>The answer to the bug report's optional crash dump (P4 PR-9, <c>10_LOGGING</c> §Bug report flow step 2).</summary>
|
||||
public enum CrashDumpChoice
|
||||
{
|
||||
/// <summary>The dialog was closed: no bundle is written.</summary>
|
||||
Cancel,
|
||||
|
||||
/// <summary>Continue without the dump: the checkbox was left clear, which is how it starts.</summary>
|
||||
LeaveOut,
|
||||
|
||||
/// <summary>Continue with the dump: the user ticked it.</summary>
|
||||
Include,
|
||||
}
|
||||
@@ -7,8 +7,8 @@ public interface IBugReportPreview
|
||||
Task<BugReportChoice> ShowAsync(BugReportPreviewModel model, CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// Step 2's optional item (P4 PR-9): the crash dump's checkbox, clear until the user ticks it
|
||||
/// (<c>legal/PRIVACY_POLICY.md</c> §3). Closing the dialog is <see cref="CrashDumpChoice.Cancel"/>.
|
||||
/// Step 2's optional items: a checkbox for each item <paramref name="offer"/> has, clear until the user ticks it
|
||||
/// (<c>legal/PRIVACY_POLICY.md</c> §3). Closing the dialog is <see cref="BugBundleOptions.Cancel"/>.
|
||||
/// </summary>
|
||||
Task<CrashDumpChoice> AskCrashDumpAsync(CrashDumpInfo dump, CancellationToken ct = default);
|
||||
Task<BugBundleOptions> AskOptionsAsync(BugBundleOffer offer, CancellationToken ct = default);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>The newest session in the ledger, as the bug report offers it: which one, of what, and when.</summary>
|
||||
public sealed record LastSessionInfo(long SessionId, string Game, DateTimeOffset StartedAt);
|
||||
@@ -0,0 +1,56 @@
|
||||
using System.IO;
|
||||
using FrameLedger.Application.Persistence;
|
||||
using FrameLedger.Domain.Sessions;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Step 2's other optional item, "last session metadata + aggregates JSON (never raw blobs by default)"
|
||||
/// (<c>10_LOGGING</c> §Bug report flow): the newest session in the ledger, written as the same <c>session.json</c> File ▸
|
||||
/// Export writes (<see cref="SessionExporter.Document"/>: metadata, aggregates, segments, hardware) but without the
|
||||
/// user's notes and tags, which are theirs and are not a diagnosis. No frame or sensor series.
|
||||
/// </summary>
|
||||
public sealed class LastSessionSummary
|
||||
{
|
||||
private readonly ISessionRepository _sessions;
|
||||
private readonly IGameRepository _games;
|
||||
private readonly IHardwareSnapshotRepository _hardware;
|
||||
|
||||
public LastSessionSummary(ISessionRepository sessions, IGameRepository games, IHardwareSnapshotRepository hardware)
|
||||
{
|
||||
_sessions = sessions ?? throw new ArgumentNullException(nameof(sessions));
|
||||
_games = games ?? throw new ArgumentNullException(nameof(games));
|
||||
_hardware = hardware ?? throw new ArgumentNullException(nameof(hardware));
|
||||
}
|
||||
|
||||
/// <summary>The newest session and its game, or null when the ledger has none.</summary>
|
||||
public async Task<LastSessionInfo?> FindAsync(CancellationToken ct = default)
|
||||
{
|
||||
IReadOnlyList<SessionRow> recent = await _sessions.ListRecentAsync(1, ct).ConfigureAwait(false);
|
||||
if (recent.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
SessionRow row = recent[0];
|
||||
GameRow? game = await _games.FindByIdAsync(row.GameId, ct).ConfigureAwait(false);
|
||||
return game is null ? null : new LastSessionInfo(row.Id, game.Name, row.StartedAt);
|
||||
}
|
||||
|
||||
/// <summary>The session's <c>session.json</c> bytes without notes or tags, or null when it is gone.</summary>
|
||||
public async Task<byte[]?> JsonAsync(long sessionId, CancellationToken ct = default)
|
||||
{
|
||||
SessionRow? row = await _sessions.FindByIdAsync(sessionId, ct).ConfigureAwait(false);
|
||||
GameRow? game = row is null ? null : await _games.FindByIdAsync(row.GameId, ct).ConfigureAwait(false);
|
||||
if (row is null || game is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
IReadOnlyList<SegmentRow> segments = await _sessions.FindSegmentsAsync(sessionId, ct).ConfigureAwait(false);
|
||||
HardwareSnapshot? snapshot = await _hardware.FindAsync(row.SnapshotId, ct).ConfigureAwait(false);
|
||||
using var buffer = new MemoryStream();
|
||||
SessionExporter.WriteJson(buffer, SessionExporter.Document(row, game, snapshot, segments, annotation: null));
|
||||
return buffer.ToArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// The "redacted copies" of <c>10_LOGGING</c> §Bug report flow step 2, and what makes <c>legal/PRIVACY_POLICY.md</c> §3's
|
||||
/// "logs are redacted (user directory paths removed) before bundling" true: the name in every <c>X:\Users\<name></c>
|
||||
/// path becomes <c><user></c>, and so does the last segment of this user's own profile directory when it lives
|
||||
/// somewhere else. Applied to the bundle's copies only; the files in <c>logs\</c> keep their paths.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Every spelling a log carries: backslashes, the doubled backslashes of Serilog's JSON properties, forward slashes, any
|
||||
/// case, a name with spaces, and a name the Overlay's ANSI header could only spell with <c>?</c>. Files are read as bytes
|
||||
/// through Latin-1, which maps each byte to one character and back, so a UTF-8 log (Serilog) and an ANSI one (the Overlay's
|
||||
/// image path) both come out byte for byte except the names. Over-redaction is the failure direction chosen: another
|
||||
/// account's folder, or <c>C:\Users\Public</c>, reads <c><user></c> too.
|
||||
/// </remarks>
|
||||
public sealed partial class LogRedactor
|
||||
{
|
||||
/// <summary>What a user name in a path becomes.</summary>
|
||||
public const string Placeholder = "<user>";
|
||||
|
||||
private const string _separator = @"(?:\\{1,2}|/)";
|
||||
private const string _end = @"(?=[\\/""'<>|\r\n\t]|\z)";
|
||||
|
||||
private readonly Regex? _profile;
|
||||
|
||||
/// <summary>A redactor for <paramref name="profileDirectory"/>'s owner; null or empty redacts <c>X:\Users\<name></c> paths only.</summary>
|
||||
public LogRedactor(string? profileDirectory)
|
||||
{
|
||||
_profile = ProfilePattern(profileDirectory);
|
||||
}
|
||||
|
||||
/// <summary>The redactor for the user running FrameLedger.</summary>
|
||||
public static LogRedactor ForCurrentUser() => new(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
|
||||
|
||||
/// <summary>The text with every user name in a path replaced by <see cref="Placeholder"/>.</summary>
|
||||
public string Redact(string text)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(text);
|
||||
string result = UsersPath().Replace(text, "${prefix}" + Placeholder);
|
||||
return _profile is null ? result : _profile.Replace(result, "${prefix}" + Placeholder);
|
||||
}
|
||||
|
||||
/// <summary>A log file's bytes, redacted, and otherwise byte for byte what was read.</summary>
|
||||
public byte[] Redact(byte[] bytes)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(bytes);
|
||||
return Encoding.Latin1.GetBytes(Redact(Encoding.Latin1.GetString(bytes)));
|
||||
}
|
||||
|
||||
[GeneratedRegex(@"(?<prefix>\b[A-Za-z]:" + _separator + "Users" + _separator + @")(?<name>[^\\/""'<>|\r\n\t]+?)" + _end, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture, matchTimeoutMilliseconds: 2000)]
|
||||
private static partial Regex UsersPath();
|
||||
|
||||
// A profile outside X:\Users (a redirected or a domain-managed one): its own parent, then its name. The name is matched
|
||||
// as its UTF-8 bytes read through Latin-1, which is how Redact(byte[]) sees a Serilog log.
|
||||
private static Regex? ProfilePattern(string? profileDirectory)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(profileDirectory))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
string[] segments = profileDirectory.Split(['\\', '/'], StringSplitOptions.RemoveEmptyEntries);
|
||||
if (segments.Length < 2 || segments[0].Length != 2 || segments[0][1] != ':'
|
||||
|| (segments.Length == 3 && string.Equals(segments[1], "Users", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
static string Escaped(string segment) => Regex.Escape(Encoding.Latin1.GetString(Encoding.UTF8.GetBytes(segment)));
|
||||
string parent = string.Join(_separator, segments[..^1].Select(Escaped));
|
||||
string pattern = @"(?<prefix>\b" + parent + _separator + ")" + Escaped(segments[^1]) + _end;
|
||||
return new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture, TimeSpan.FromSeconds(2));
|
||||
}
|
||||
}
|
||||
Generated
+6
@@ -56,6 +56,8 @@ public static class Strings
|
||||
nameof(BugReport_Options_Dump_Detail),
|
||||
nameof(BugReport_Options_Dump_Format),
|
||||
nameof(BugReport_Options_Intro),
|
||||
nameof(BugReport_Options_Session_Detail),
|
||||
nameof(BugReport_Options_Session_Format),
|
||||
nameof(BugReport_Options_Title),
|
||||
nameof(BugReport_Preview_Drag),
|
||||
nameof(BugReport_Preview_Intro_Format),
|
||||
@@ -642,6 +644,10 @@ public static class Strings
|
||||
|
||||
public static string BugReport_Options_Intro => ResourceManager.GetString(nameof(BugReport_Options_Intro), Culture) ?? nameof(BugReport_Options_Intro);
|
||||
|
||||
public static string BugReport_Options_Session_Detail => ResourceManager.GetString(nameof(BugReport_Options_Session_Detail), Culture) ?? nameof(BugReport_Options_Session_Detail);
|
||||
|
||||
public static string BugReport_Options_Session_Format => ResourceManager.GetString(nameof(BugReport_Options_Session_Format), Culture) ?? nameof(BugReport_Options_Session_Format);
|
||||
|
||||
public static string BugReport_Options_Title => ResourceManager.GetString(nameof(BugReport_Options_Title), Culture) ?? nameof(BugReport_Options_Title);
|
||||
|
||||
public static string BugReport_Preview_Drag => ResourceManager.GetString(nameof(BugReport_Preview_Drag), Culture) ?? nameof(BugReport_Preview_Drag);
|
||||
|
||||
@@ -2233,6 +2233,14 @@
|
||||
<value>クラッシュ時の FrameLedger 自身のメモリのスナップショットです。原因の特定に役立ちますが、この PC のファイルパス、ゲーム名、設定が含まれる場合があります。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="BugReport_Options_Session_Format" xml:space="preserve">
|
||||
<value>直近のセッション: {0}、{1}</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="BugReport_Options_Session_Detail" xml:space="preserve">
|
||||
<value>session.json: ゲームの名前と実行ファイルのパス、キャプチャ方法、設定と統計、この PC の CPU と GPU。フレームごとのデータ、メモやタグは含まれません。パス内のユーザー名は置き換えられます。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="BugReport_Options_Continue" xml:space="preserve">
|
||||
<value>続行</value>
|
||||
<comment>review</comment>
|
||||
|
||||
@@ -1682,6 +1682,12 @@ Open the bug report now? It shows you every file in the zip, sends nothing by it
|
||||
<data name="BugReport_Options_Dump_Detail" xml:space="preserve">
|
||||
<value>A snapshot of FrameLedger's own memory when it crashed. It helps find the cause, and it can contain file paths, game names and settings from this PC.</value>
|
||||
</data>
|
||||
<data name="BugReport_Options_Session_Format" xml:space="preserve">
|
||||
<value>The last session: {0}, {1}</value>
|
||||
</data>
|
||||
<data name="BugReport_Options_Session_Detail" xml:space="preserve">
|
||||
<value>session.json: the game's name and executable path, how it was captured, its settings and statistics, and this PC's CPU and GPU. No frame data, and not your notes or tags. User names in paths are replaced.</value>
|
||||
</data>
|
||||
<data name="BugReport_Options_Continue" xml:space="preserve">
|
||||
<value>Continue</value>
|
||||
</data>
|
||||
|
||||
@@ -1677,6 +1677,12 @@ Mở báo cáo lỗi ngay bây giờ? Báo cáo cho bạn xem mọi tệp trong
|
||||
<data name="BugReport_Options_Dump_Detail" xml:space="preserve">
|
||||
<value>Ảnh chụp bộ nhớ của chính FrameLedger lúc bị lỗi. Nó giúp tìm nguyên nhân, và có thể chứa đường dẫn tệp, tên game và cài đặt trên máy này.</value>
|
||||
</data>
|
||||
<data name="BugReport_Options_Session_Format" xml:space="preserve">
|
||||
<value>Phiên gần nhất: {0}, {1}</value>
|
||||
</data>
|
||||
<data name="BugReport_Options_Session_Detail" xml:space="preserve">
|
||||
<value>session.json: tên game và đường dẫn tệp chạy, cách ghi, các thiết lập và thống kê, cùng CPU và GPU của máy này. Không có dữ liệu từng khung hình, không có ghi chú hay thẻ của bạn. Tên người dùng trong đường dẫn được thay thế.</value>
|
||||
</data>
|
||||
<data name="BugReport_Options_Continue" xml:space="preserve">
|
||||
<value>Tiếp tục</value>
|
||||
</data>
|
||||
|
||||
@@ -6,24 +6,41 @@ using FrameLedger.App.Services;
|
||||
namespace FrameLedger.App.ViewModels;
|
||||
|
||||
/// <summary>
|
||||
/// The bug report's optional crash dump (P4 PR-9, <c>10_LOGGING</c> §Bug report flow step 2): one checkbox, clear until the
|
||||
/// user ticks it (<c>legal/PRIVACY_POLICY.md</c> §3), labelled with the dump's time and size, and a line saying what a
|
||||
/// dump can hold.
|
||||
/// The bug report's optional items (<c>10_LOGGING</c> §Bug report flow step 2): a checkbox for each item there is — the
|
||||
/// crash dump (P4 PR-9) and the last session's summary — each clear until the user ticks it
|
||||
/// (<c>legal/PRIVACY_POLICY.md</c> §3), each with a line saying what it holds.
|
||||
/// </summary>
|
||||
[SuppressMessage("Performance", "CA1863:Use 'CompositeFormat'", Justification = "the format string is a resource that follows the UI culture, which changes at runtime")]
|
||||
[SuppressMessage("Performance", "CA1863:Use 'CompositeFormat'", Justification = "the format strings are resources that follow the UI culture, which changes at runtime")]
|
||||
public sealed partial class BugBundleOptionsViewModel : ObservableObject
|
||||
{
|
||||
[ObservableProperty]
|
||||
private bool _includeCrashDump;
|
||||
|
||||
public BugBundleOptionsViewModel(CrashDumpInfo dump)
|
||||
[ObservableProperty]
|
||||
private bool _includeLastSession;
|
||||
|
||||
public BugBundleOptionsViewModel(BugBundleOffer offer)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(dump);
|
||||
DumpLabel = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
Strings.BugReport_Options_Dump_Format,
|
||||
dump.WrittenAt.ToLocalTime().ToString("g", CultureInfo.CurrentCulture),
|
||||
dump.Bytes / (1024.0 * 1024.0));
|
||||
ArgumentNullException.ThrowIfNull(offer);
|
||||
HasCrashDump = offer.CrashDump is not null;
|
||||
HasLastSession = offer.LastSession is not null;
|
||||
if (offer.CrashDump is { } dump)
|
||||
{
|
||||
DumpLabel = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
Strings.BugReport_Options_Dump_Format,
|
||||
dump.WrittenAt.ToLocalTime().ToString("g", CultureInfo.CurrentCulture),
|
||||
dump.Bytes / (1024.0 * 1024.0));
|
||||
}
|
||||
|
||||
if (offer.LastSession is { } session)
|
||||
{
|
||||
SessionLabel = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
Strings.BugReport_Options_Session_Format,
|
||||
session.Game,
|
||||
session.StartedAt.ToLocalTime().ToString("g", CultureInfo.CurrentCulture));
|
||||
}
|
||||
}
|
||||
|
||||
public static string Title => Strings.BugReport_Options_Title;
|
||||
@@ -32,17 +49,20 @@ public sealed partial class BugBundleOptionsViewModel : ObservableObject
|
||||
|
||||
public static string DumpDetail => Strings.BugReport_Options_Dump_Detail;
|
||||
|
||||
/// <summary>The checkbox's text: the dump's local time and its size in MB.</summary>
|
||||
public string DumpLabel { get; }
|
||||
public static string SessionDetail => Strings.BugReport_Options_Session_Detail;
|
||||
|
||||
public bool HasCrashDump { get; }
|
||||
|
||||
public bool HasLastSession { get; }
|
||||
|
||||
/// <summary>The crash dump's checkbox text: its local time and size in MB; empty when there is no dump.</summary>
|
||||
public string DumpLabel { get; } = string.Empty;
|
||||
|
||||
/// <summary>The last session's checkbox text: the game and the local start time; empty when there is no session.</summary>
|
||||
public string SessionLabel { get; } = string.Empty;
|
||||
|
||||
/// <summary>The answer, once the dialog closed: <paramref name="continued"/> is its primary button.</summary>
|
||||
public CrashDumpChoice Choice(bool continued)
|
||||
{
|
||||
if (!continued)
|
||||
{
|
||||
return CrashDumpChoice.Cancel;
|
||||
}
|
||||
|
||||
return IncludeCrashDump ? CrashDumpChoice.Include : CrashDumpChoice.LeaveOut;
|
||||
}
|
||||
public BugBundleOptions Options(bool continued) => continued
|
||||
? new BugBundleOptions(Cancelled: false, IncludeCrashDump: HasCrashDump && IncludeCrashDump, IncludeLastSession: HasLastSession && IncludeLastSession)
|
||||
: BugBundleOptions.Cancel;
|
||||
}
|
||||
@@ -80,6 +80,29 @@ public sealed class BugBundleBuilderTests : IDisposable
|
||||
sysinfo["telemetry_source"].Should().Be("l3");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TheLogCopiesCarryNoUserNameAndTheFilesOnDiskAreUntouched()
|
||||
{
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
var clock = new FixedClock(new DateTimeOffset(2026, 9, 15, 12, 0, 0, TimeSpan.Zero));
|
||||
DateTime now = clock.GetUtcNow().UtcDateTime;
|
||||
string ui = Path.Combine(_dir, "ui-20260915.log");
|
||||
await File.WriteAllTextAsync(ui, "[12:00:00.000 INF] ui: started (0.1.0), ledger C:\\Users\\tester\\AppData\\Local\\FrameLedger\\ledger.db {\"Path\":\"C:\\\\Users\\\\tester\\\\AppData\"}\r\n", Ct);
|
||||
File.SetLastWriteTimeUtc(ui, now);
|
||||
string overlay = Path.Combine(_dir, "overlay-4242-20260915-120000.log");
|
||||
await File.WriteAllTextAsync(overlay, "# FrameLedger.Overlay build x pid 4242 layout v9 image C:\\Users\\tester\\Games\\title.exe\nSTOP\n", Ct);
|
||||
File.SetLastWriteTimeUtc(overlay, now);
|
||||
string zip = Path.Combine(_dir, "bundle.zip");
|
||||
|
||||
await new BugBundleBuilder(_dir, new RegisteredSettings(new SqliteSettingsStore(s.Db)), clock, redactor: new LogRedactor(@"C:\Users\tester")).WriteAsync(zip, agent: null, ct: Ct);
|
||||
|
||||
string uiCopy = ReadEntry(zip, "logs/ui-20260915.log");
|
||||
string overlayCopy = ReadEntry(zip, "overlay/overlay-4242-20260915-120000.log");
|
||||
uiCopy.Should().NotContain("tester").And.Contain(@"C:\Users\<user>\AppData\Local\FrameLedger\ledger.db").And.Contain(@"C:\\Users\\<user>\\AppData");
|
||||
overlayCopy.Should().NotContain("tester").And.StartWith(@"# FrameLedger.Overlay build x pid 4242 layout v9 image C:\Users\<user>\Games\title.exe");
|
||||
(await File.ReadAllTextAsync(ui, Ct)).Should().Contain("tester", "the redaction is the bundle's copy, never the log on disk");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheSuggestedNameIsTheDocsFormat()
|
||||
{
|
||||
@@ -99,13 +122,13 @@ public sealed class BugBundleBuilderTests : IDisposable
|
||||
latest.Bytes.Should().Be(3000);
|
||||
|
||||
IReadOnlyList<string> without = await builder.WriteAsync(Path.Combine(_dir, "without.zip"), agent: null, ct: Ct);
|
||||
IReadOnlyList<string> with = await builder.WriteAsync(Path.Combine(_dir, "with.zip"), agent: null, latest, Ct);
|
||||
IReadOnlyList<string> with = await builder.WriteAsync(Path.Combine(_dir, "with.zip"), agent: null, latest, ct: Ct);
|
||||
|
||||
without.Should().NotContain(static e => e.StartsWith("crashdumps/", StringComparison.Ordinal), "a dump goes in only when the user ticked it");
|
||||
with.Should().Contain("crashdumps/ui-20260915-100000-42.dmp");
|
||||
string foreign = Path.Combine(_dir, "game.dmp");
|
||||
await File.WriteAllTextAsync(foreign, "MDMP", Ct);
|
||||
Func<Task> outside = () => builder.WriteAsync(Path.Combine(_dir, "foreign.zip"), agent: null, latest with { Path = foreign }, Ct);
|
||||
Func<Task> outside = () => builder.WriteAsync(Path.Combine(_dir, "foreign.zip"), agent: null, latest with { Path = foreign }, ct: Ct);
|
||||
await outside.Should().ThrowAsync<ArgumentException>("the bundle never carries a file from outside the dump directory");
|
||||
File.Exists(Path.Combine(_dir, "foreign.zip")).Should().BeFalse("refused before the zip is created");
|
||||
}
|
||||
@@ -143,6 +166,13 @@ public sealed class BugBundleBuilderTests : IDisposable
|
||||
return path;
|
||||
}
|
||||
|
||||
private static string ReadEntry(string zip, string entry)
|
||||
{
|
||||
using ZipArchive archive = ZipFile.OpenRead(zip);
|
||||
using var reader = new StreamReader(archive.GetEntry(entry)!.Open());
|
||||
return reader.ReadToEnd();
|
||||
}
|
||||
|
||||
private static Dictionary<string, string> ReadJson(string zip, string entry)
|
||||
{
|
||||
using ZipArchive archive = ZipFile.OpenRead(zip);
|
||||
|
||||
@@ -6,22 +6,42 @@ using FrameLedger.App.ViewModels;
|
||||
namespace FrameLedger.App.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// The bug report's optional crash dump (P4 PR-9): the box starts clear (<c>legal/PRIVACY_POLICY.md</c> §3, only when
|
||||
/// ticked), closing the dialog never includes it, and the label carries the dump's size.
|
||||
/// The bug report's optional items: every box starts clear (<c>legal/PRIVACY_POLICY.md</c> §3, only when ticked), only an
|
||||
/// item that exists can be included, closing the dialog includes nothing, and each label says what and how big.
|
||||
/// </summary>
|
||||
public sealed class BugBundleOptionsViewModelTests
|
||||
{
|
||||
private static readonly CrashDumpInfo _dump = new(@"C:\data\crashdumps\ui-1.dmp", new DateTimeOffset(2026, 9, 15, 1, 2, 3, TimeSpan.Zero), 1536 * 1024);
|
||||
private static readonly LastSessionInfo _session = new(42, "Title", new DateTimeOffset(2026, 9, 15, 3, 4, 5, TimeSpan.Zero));
|
||||
|
||||
[Fact]
|
||||
public void TheBoxStartsClearAndOnlyATickAndContinueIncludesTheDump()
|
||||
public void EveryBoxStartsClearAndOnlyATickAndContinueIncludesAnItem()
|
||||
{
|
||||
var vm = new BugBundleOptionsViewModel(new CrashDumpInfo(@"C:\data\crashdumps\ui-1.dmp", new DateTimeOffset(2026, 9, 15, 1, 2, 3, TimeSpan.Zero), 1536 * 1024));
|
||||
var vm = new BugBundleOptionsViewModel(new BugBundleOffer(_dump, _session));
|
||||
|
||||
vm.IncludeCrashDump.Should().BeFalse();
|
||||
vm.Choice(continued: true).Should().Be(CrashDumpChoice.LeaveOut);
|
||||
vm.Choice(continued: false).Should().Be(CrashDumpChoice.Cancel);
|
||||
vm.IncludeLastSession.Should().BeFalse();
|
||||
vm.Options(continued: true).Should().Be(BugBundleOptions.NothingTicked);
|
||||
vm.Options(continued: false).Should().Be(BugBundleOptions.Cancel);
|
||||
vm.IncludeCrashDump = true;
|
||||
vm.Choice(continued: true).Should().Be(CrashDumpChoice.Include);
|
||||
vm.Choice(continued: false).Should().Be(CrashDumpChoice.Cancel, "closing the dialog never includes the dump");
|
||||
vm.Options(continued: true).Should().Be(new BugBundleOptions(Cancelled: false, IncludeCrashDump: true, IncludeLastSession: false));
|
||||
vm.IncludeLastSession = true;
|
||||
vm.Options(continued: true).Should().Be(new BugBundleOptions(Cancelled: false, IncludeCrashDump: true, IncludeLastSession: true));
|
||||
vm.Options(continued: false).Should().Be(BugBundleOptions.Cancel, "closing the dialog never includes anything");
|
||||
vm.DumpLabel.Should().Contain(string.Format(CultureInfo.CurrentCulture, "{0:0.0}", 1.5), "the size is in the label, in MB");
|
||||
vm.SessionLabel.Should().Contain("Title");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AnItemThereIsNoneOfHasNoBoxAndCannotBeIncluded()
|
||||
{
|
||||
var vm = new BugBundleOptionsViewModel(new BugBundleOffer(CrashDump: null, _session));
|
||||
|
||||
vm.HasCrashDump.Should().BeFalse();
|
||||
vm.HasLastSession.Should().BeTrue();
|
||||
vm.DumpLabel.Should().BeEmpty();
|
||||
vm.IncludeCrashDump = true;
|
||||
vm.Options(continued: true).IncludeCrashDump.Should().BeFalse("there is no dump to include");
|
||||
new BugBundleOffer(null, null).IsEmpty.Should().BeTrue();
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ using System.IO;
|
||||
using System.IO.Compression;
|
||||
using FluentAssertions;
|
||||
using FrameLedger.App.Services;
|
||||
using FrameLedger.Application.Persistence;
|
||||
using FrameLedger.Application.Settings;
|
||||
using FrameLedger.Infrastructure.Persistence;
|
||||
using FrameLedger.Shared.Ipc;
|
||||
@@ -41,17 +42,18 @@ public sealed class BugReportFlowTests : IDisposable
|
||||
|
||||
private sealed record Harness(BugReportFlow Flow, ClosePreview Preview, NoUrlOpener Urls, NoClipboard Clipboard, RecordingStrip Strip, string Zip);
|
||||
|
||||
private async Task<Harness> BuildAsync(ScratchLedger s, BugReportChoice choice, bool cancel = false, CrashDumpChoice dumpChoice = CrashDumpChoice.LeaveOut)
|
||||
private async Task<Harness> BuildAsync(ScratchLedger s, BugReportChoice choice, bool cancel = false, BugBundleOptions? options = null)
|
||||
{
|
||||
await File.WriteAllTextAsync(Path.Combine(_dir, "ui-20260914.log"), "[12:00:00.000 INF] hello\n", Ct).ConfigureAwait(false);
|
||||
var builder = new BugBundleBuilder(_dir, new RegisteredSettings(new SqliteSettingsStore(s.Db)), crashDumpDirectory: Path.Combine(_dir, "crashdumps"));
|
||||
string zip = Path.Combine(_dir, "bundle.zip");
|
||||
var preview = new ClosePreview(choice, dumpChoice);
|
||||
var preview = new ClosePreview(choice, options);
|
||||
var urls = new NoUrlOpener();
|
||||
var clipboard = new NoClipboard();
|
||||
var strip = new RecordingStrip();
|
||||
var agent = new FakeAgentLink { Hello = new HelloAck("9.9.9", IpcProtocol.Version, 4, false, "build-z", false, "l1", false, "consent-dialog/1") };
|
||||
return new Harness(new BugReportFlow(builder, new PathSaver(cancel ? null : zip), agent, preview, urls, clipboard, strip), preview, urls, clipboard, strip, zip);
|
||||
var lastSession = new LastSessionSummary(s.Sessions, s.Games, new SqliteHardwareSnapshotRepository(s.Db));
|
||||
return new Harness(new BugReportFlow(builder, new PathSaver(cancel ? null : zip), agent, preview, urls, clipboard, strip, lastSession: lastSession), preview, urls, clipboard, strip, zip);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -77,22 +79,22 @@ public sealed class BugReportFlowTests : IDisposable
|
||||
.And.Contain("&os=Windows%20", "the form's field ids are app-version and os, hyphenated");
|
||||
h.Clipboard.Texts.Should().BeEmpty();
|
||||
h.Strip.Shown.Should().BeEmpty("the browser opened; there is nothing to say");
|
||||
h.Preview.DumpsOffered.Should().BeEmpty("no crash dump, no question");
|
||||
h.Preview.Offers.Should().BeEmpty("no crash dump and no session: no question");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(CrashDumpChoice.LeaveOut, false)]
|
||||
[InlineData(CrashDumpChoice.Include, true)]
|
||||
public async Task ARecentCrashDumpIsOfferedAndGoesInOnlyWhenTicked(CrashDumpChoice answer, bool included)
|
||||
[InlineData(false)]
|
||||
[InlineData(true)]
|
||||
public async Task ARecentCrashDumpIsOfferedAndGoesInOnlyWhenTicked(bool included)
|
||||
{
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
string dump = WriteDump();
|
||||
Harness h = await BuildAsync(s, BugReportChoice.Close, dumpChoice: answer);
|
||||
Harness h = await BuildAsync(s, BugReportChoice.Close, options: new BugBundleOptions(Cancelled: false, IncludeCrashDump: included, IncludeLastSession: false));
|
||||
|
||||
BugReportOutcome o = await h.Flow.RunAsync(Ct);
|
||||
|
||||
o.Written.Should().BeTrue();
|
||||
h.Preview.DumpsOffered.Should().ContainSingle().Which.Path.Should().Be(dump);
|
||||
h.Preview.Offers.Should().ContainSingle().Which.CrashDump!.Path.Should().Be(dump);
|
||||
IReadOnlyList<string> entries = h.Preview.Shown.Should().ContainSingle().Subject.Entries;
|
||||
string entry = "crashdumps/" + Path.GetFileName(dump);
|
||||
if (included)
|
||||
@@ -110,7 +112,7 @@ public sealed class BugReportFlowTests : IDisposable
|
||||
{
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
WriteDump();
|
||||
Harness h = await BuildAsync(s, BugReportChoice.OpenIssue, dumpChoice: CrashDumpChoice.Cancel);
|
||||
Harness h = await BuildAsync(s, BugReportChoice.OpenIssue, options: BugBundleOptions.Cancel);
|
||||
|
||||
BugReportOutcome o = await h.Flow.RunAsync(Ct);
|
||||
|
||||
@@ -121,6 +123,36 @@ public sealed class BugReportFlowTests : IDisposable
|
||||
h.Urls.Opened.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(false)]
|
||||
[InlineData(true)]
|
||||
public async Task TheLastSessionIsOfferedAndGoesInOnlyWhenTickedWithItsPathsRedacted(bool included)
|
||||
{
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
GameRow game = await s.GameAsync("Title", @"C:\Users\tester\Games\Title\title.exe");
|
||||
long id = await s.SessionAsync(game.Id, new DateTimeOffset(2026, 9, 14, 10, 0, 0, TimeSpan.Zero));
|
||||
Harness h = await BuildAsync(s, BugReportChoice.Close, options: new BugBundleOptions(Cancelled: false, IncludeCrashDump: false, IncludeLastSession: included));
|
||||
|
||||
BugReportOutcome o = await h.Flow.RunAsync(Ct);
|
||||
|
||||
o.Written.Should().BeTrue();
|
||||
BugBundleOffer offer = h.Preview.Offers.Should().ContainSingle().Subject;
|
||||
offer.CrashDump.Should().BeNull();
|
||||
offer.LastSession.Should().Be(new LastSessionInfo(id, "Title", new DateTimeOffset(2026, 9, 14, 10, 0, 0, TimeSpan.Zero)));
|
||||
IReadOnlyList<string> entries = h.Preview.Shown.Should().ContainSingle().Subject.Entries;
|
||||
if (!included)
|
||||
{
|
||||
entries.Should().NotContain("session.json", "the box starts clear and was left so");
|
||||
return;
|
||||
}
|
||||
|
||||
entries.Should().Contain("session.json");
|
||||
using ZipArchive archive = await ZipFile.OpenReadAsync(h.Zip, Ct);
|
||||
using var reader = new StreamReader(await archive.GetEntry("session.json")!.OpenAsync(Ct));
|
||||
string json = await reader.ReadToEndAsync(Ct);
|
||||
json.Should().Contain("Title").And.NotContain("tester", "a path in the summary is redacted like a log");
|
||||
}
|
||||
|
||||
private string WriteDump()
|
||||
{
|
||||
string dumps = Path.Combine(_dir, "crashdumps");
|
||||
|
||||
@@ -4,13 +4,14 @@ namespace FrameLedger.App.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// The bug report flow's three ports, scripted (P4 PR-3): a preview that answers what the test says, a browser and a
|
||||
/// clipboard that record. The crash dump question (P4 PR-9) answers <paramref name="dumpChoice"/> and records each offer.
|
||||
/// clipboard that record. The optional items' question answers <paramref name="options"/> (nothing ticked by default) and
|
||||
/// records each offer.
|
||||
/// </summary>
|
||||
internal sealed class ClosePreview(BugReportChoice choice = BugReportChoice.Close, CrashDumpChoice dumpChoice = CrashDumpChoice.LeaveOut) : IBugReportPreview
|
||||
internal sealed class ClosePreview(BugReportChoice choice = BugReportChoice.Close, BugBundleOptions? options = null) : IBugReportPreview
|
||||
{
|
||||
public List<BugReportPreviewModel> Shown { get; } = [];
|
||||
|
||||
public List<CrashDumpInfo> DumpsOffered { get; } = [];
|
||||
public List<BugBundleOffer> Offers { get; } = [];
|
||||
|
||||
public Task<BugReportChoice> ShowAsync(BugReportPreviewModel model, CancellationToken ct = default)
|
||||
{
|
||||
@@ -18,9 +19,9 @@ internal sealed class ClosePreview(BugReportChoice choice = BugReportChoice.Clos
|
||||
return Task.FromResult(choice);
|
||||
}
|
||||
|
||||
public Task<CrashDumpChoice> AskCrashDumpAsync(CrashDumpInfo dump, CancellationToken ct = default)
|
||||
public Task<BugBundleOptions> AskOptionsAsync(BugBundleOffer offer, CancellationToken ct = default)
|
||||
{
|
||||
DumpsOffered.Add(dump);
|
||||
return Task.FromResult(dumpChoice);
|
||||
Offers.Add(offer);
|
||||
return Task.FromResult(options ?? BugBundleOptions.NothingTicked);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using System.Text.Json;
|
||||
using FluentAssertions;
|
||||
using FrameLedger.App.Services;
|
||||
using FrameLedger.Application.Persistence;
|
||||
using FrameLedger.Infrastructure.Persistence;
|
||||
|
||||
namespace FrameLedger.App.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// The last session's summary (<c>10_LOGGING</c> §Bug report flow step 2): the newest session, as File ▸ Export's
|
||||
/// <c>session.json</c> without the user's notes and tags; nothing when the ledger has no session.
|
||||
/// </summary>
|
||||
public sealed class LastSessionSummaryTests
|
||||
{
|
||||
private static CancellationToken Ct => TestContext.Current.CancellationToken;
|
||||
|
||||
[Fact]
|
||||
public async Task TheNewestSessionIsOfferedAndWrittenWithoutNotesOrTags()
|
||||
{
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
var summary = new LastSessionSummary(s.Sessions, s.Games, new SqliteHardwareSnapshotRepository(s.Db));
|
||||
(await summary.FindAsync(Ct)).Should().BeNull("an empty ledger offers nothing");
|
||||
|
||||
GameRow older = await s.GameAsync("Older");
|
||||
GameRow newer = await s.GameAsync("Newer");
|
||||
await s.SessionAsync(older.Id, new DateTimeOffset(2026, 9, 1, 10, 0, 0, TimeSpan.Zero));
|
||||
long id = await s.SessionAsync(newer.Id, new DateTimeOffset(2026, 9, 14, 10, 0, 0, TimeSpan.Zero));
|
||||
await s.Annotations.UpsertAsync(new SessionAnnotation { SessionId = id, Notes = "private note", Tags = ["mine"] }, Ct);
|
||||
|
||||
LastSessionInfo? info = await summary.FindAsync(Ct);
|
||||
byte[]? json = await summary.JsonAsync(id, Ct);
|
||||
|
||||
info.Should().Be(new LastSessionInfo(id, "Newer", new DateTimeOffset(2026, 9, 14, 10, 0, 0, TimeSpan.Zero)));
|
||||
json.Should().NotBeNull();
|
||||
using JsonDocument doc = JsonDocument.Parse(json!);
|
||||
doc.RootElement.GetProperty("game").GetString().Should().Be("Newer");
|
||||
System.Text.Encoding.UTF8.GetString(json!).Should().NotContain("private note").And.NotContain("mine");
|
||||
(await summary.JsonAsync(id + 1000, Ct)).Should().BeNull("a session that is gone writes nothing");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
using System.Text;
|
||||
using FluentAssertions;
|
||||
using FrameLedger.App.Services;
|
||||
|
||||
namespace FrameLedger.App.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// <c>legal/PRIVACY_POLICY.md</c> §3 (P4 follow-up, 2026-09-15): a user name in a path never leaves the machine in a log
|
||||
/// copy, in any spelling a log carries, and nothing else in the file changes.
|
||||
/// </summary>
|
||||
public sealed class LogRedactorTests
|
||||
{
|
||||
private static readonly LogRedactor _redactor = new(@"C:\Users\kuujo");
|
||||
|
||||
[Theory]
|
||||
[InlineData(@"ledger C:\Users\kuujo\AppData\Local\FrameLedger\ledger.db", @"ledger C:\Users\<user>\AppData\Local\FrameLedger\ledger.db")]
|
||||
[InlineData(@"{""Path"":""C:\\Users\\kuujo\\AppData\\Local""}", @"{""Path"":""C:\\Users\\<user>\\AppData\\Local""}")]
|
||||
[InlineData("file:///c:/users/KUUJO/Documents/x.txt", "file:///c:/users/<user>/Documents/x.txt")]
|
||||
[InlineData(@"C:\Users\John Smith\Documents", @"C:\Users\<user>\Documents")]
|
||||
[InlineData(@"'C:\Users\kuujo'", @"'C:\Users\<user>'")]
|
||||
[InlineData("profile C:\\Users\\kuujo\r\nnext", "profile C:\\Users\\<user>\r\nnext")]
|
||||
[InlineData(@"image C:\Users\Nguy?n\Games\title.exe", @"image C:\Users\<user>\Games\title.exe")]
|
||||
[InlineData(@"two C:\Users\a\x and D:\Users\b\y", @"two C:\Users\<user>\x and D:\Users\<user>\y")]
|
||||
public void TheNameInAUsersPathBecomesThePlaceholderInEverySpelling(string log, string expected)
|
||||
{
|
||||
_redactor.Redact(log).Should().Be(expected);
|
||||
_redactor.Redact(_redactor.Redact(log)).Should().Be(expected, "redacting a copy twice changes nothing more");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(@"C:\Program Files\FrameLedger\FrameLedger.exe")]
|
||||
[InlineData(@"D:\Games\Users\title.exe")]
|
||||
[InlineData(@"C:\Userspace\x")]
|
||||
[InlineData("Users: 3, sessions: 12")]
|
||||
[InlineData(@"C:\Users\")]
|
||||
public void TextThatNamesNoUserIsUnchanged(string log) => _redactor.Redact(log).Should().Be(log);
|
||||
|
||||
[Fact]
|
||||
public void AProfileOutsideTheUsersFolderIsRedactedByItsOwnPath()
|
||||
{
|
||||
var redirected = new LogRedactor(@"D:\Profiles\kuujo");
|
||||
|
||||
redirected.Redact(@"ledger D:\Profiles\kuujo\AppData\Local\FrameLedger\ledger.db").Should().Be(@"ledger D:\Profiles\<user>\AppData\Local\FrameLedger\ledger.db");
|
||||
redirected.Redact(@"{""P"":""d:\\profiles\\KUUJO\\x""}").Should().Be(@"{""P"":""d:\\profiles\\<user>\\x""}");
|
||||
redirected.Redact(@"D:\Profiles\kuujo2\x").Should().Be(@"D:\Profiles\kuujo2\x", "another folder that merely starts with the name");
|
||||
new LogRedactor(null).Redact(@"D:\Profiles\kuujo\x").Should().Be(@"D:\Profiles\kuujo\x", "without a profile only X:\\Users paths are known");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BytesOutsideTheNamesAreKeptExactlyInUtf8AndInAnsi()
|
||||
{
|
||||
byte[] utf8 = Encoding.UTF8.GetBytes("[12:00:00.000 INF] Thiết lập đã lưu C:\\Users\\Nguyễn\\AppData\r\n");
|
||||
byte[] expectedUtf8 = Encoding.UTF8.GetBytes("[12:00:00.000 INF] Thiết lập đã lưu C:\\Users\\<user>\\AppData\r\n");
|
||||
byte[] ansi = [.. Encoding.ASCII.GetBytes("# image C:\\Users\\Jos"), 0xE9, .. Encoding.ASCII.GetBytes("\\Games\\t.exe\n")];
|
||||
byte[] expectedAnsi = Encoding.ASCII.GetBytes("# image C:\\Users\\<user>\\Games\\t.exe\n");
|
||||
|
||||
_redactor.Redact(utf8).Should().Equal(expectedUtf8);
|
||||
_redactor.Redact(ansi).Should().Equal(expectedAnsi);
|
||||
}
|
||||
}
|
||||
@@ -267,11 +267,11 @@ public sealed class PagesLoadTests
|
||||
public Task<bool> ConfirmSweepAsync(int keep, CancellationToken ct = default) => Task.FromResult(false);
|
||||
}
|
||||
|
||||
/// <summary>The bug report's optional crash dump (P4 PR-9) under the real dictionaries: the checkbox and both texts bind.</summary>
|
||||
/// <summary>The bug report's optional items under the real dictionaries: both checkboxes, their texts, the visibility converter.</summary>
|
||||
[Fact]
|
||||
public async Task TheBundleOptionsDialogLoads()
|
||||
{
|
||||
var vm = new BugBundleOptionsViewModel(new CrashDumpInfo(@"C:\data\crashdumps\ui-20260915-010203-42.dmp", DateTimeOffset.UtcNow, 2 * 1024 * 1024));
|
||||
var vm = new BugBundleOptionsViewModel(new BugBundleOffer(new CrashDumpInfo(@"C:\data\crashdumps\ui-20260915-010203-42.dmp", DateTimeOffset.UtcNow, 2 * 1024 * 1024), new LastSessionInfo(1, "Title", DateTimeOffset.UtcNow)));
|
||||
|
||||
double width = await OnStaAsync(() =>
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user