Case studies
#powershell#debugging#windows#electron#docker#pterodactyl#python#csharp#wpf#bash#security#cpp#git#performance#ci#nodejs#pyside6#react-native
13 posts · #csharp
Clear filters·6 min read

TaskPad · Story
TaskPad's session restore could register a window it never showed
Restore created each window first and checked its tabs later, so a failure could leave a hidden window in the workspace. I rewrote it to validate before creating.
In short
- Session restore built each saved window up front and cleaned up empty ones afterwards, so a failure midway could leave a hidden window registered in the workspace.
- I split restore into parse, validate, create: a window is only made when at least one of its tabs can really be restored, and anything that fails is logged and rolled back.
- The save side and the single-instance handler now ignore invisible windows too, so a hidden one cannot be saved, or receive a file you double-clicked.
#wpf#csharp#session-restore#debugging
·6 min read

TaskPad · Story
Two TaskPad bugs that failed without a single error on screen
A restored window that existed but never appeared, and an edit button that did nothing. Both came from code that kept the app alive and so hid the failure. Here is how I found each one.
In short
- Session restore could register a window and never show it, then report success. Fixed in 48b16bf (v1.3.5).
- Editing a comment failed inside a click handler that a global exception handler swallowed. Fixed in 25a3d6f (v1.9.4).
- Both bugs were invisible because the app was designed to survive errors, not to surface them.
#wpf#csharp#error-handling#debugging
·6 min read

TaskPad · Story
Hiding the # in TaskPad headings, except where you edit them
A heading looks cleaner without its ## marks, but then you cannot see or change its level. One AvalonEdit generator and one caret event hid the marks everywhere except the line you are typing in.
In short
- Heading marks are hidden by an AvalonEdit element generator, but only on lines that do not hold the caret.
- Two places in the generator must skip the same token, and two lines must be redrawn when the caret moves.
- The fix shipped as v1.3.1: 26 lines added and 5 removed across four files.
#wpf#csharp#avalonedit#editor
·11 min read

TaskPad: a 1 MB WPF task editor that installs and updates itself
Notepad is too plain and VS Code is too heavy for a to-do list. I built TaskPad in C# as one 1 MB exe, and shipped 29 releases in about eleven hours. Here is what broke along the way.
In short
- The whole app is one exe: AvalonEdit is embedded as a resource and loaded through an AssemblyResolve handler, so there is no DLL next to it. The v1.9.4 build is 1,079,296 bytes.
- The same file is the portable app, the per-user installer (it detects "setup" in its own file name) and the updater, which swaps a running exe by renaming it to .old.
- Comments are stored as CriticMarkup inside the text file, so a note with a full discussion still opens in any editor.
#csharp#wpf#windows#desktop
·5 min read

TaskPad · Story
How TaskPad replaces its own running exe, and what the checksum covers
Windows will not let you overwrite a running exe, but it lets you rename it. That one fact is the whole TaskPad updater. I also show what the SHA-256 check does not protect against.
In short
- The updater downloads the new exe to Temp, checks a SHA-256, renames the running exe to .old, copies the new one in, and rolls back if the copy fails.
- The installer is the same file: it starts in setup mode when "setup" appears in its own file name.
- The checksum is only checked when the release notes contain a SHA-256: line, and it comes from the same release as the exe.
#csharp#wpf#updater#windows