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

TaskPad · Story
TaskPad icons would not line up: one shared frame, then the checkbox column
AvalonEdit puts inline elements at the top of the line, so badges and checkboxes drifted. Two commits fixed it: a shared vertical frame, then a horizontal column.
In short
- AvalonEdit places inline elements at the top of the text line, and a line's top depends on its tallest element, so icons of different heights drifted vertically.
- Commit 525a0a8 added Align.Host, one shared frame for every inline icon, centred on the middle of the capital letters; commit 270faef then made tag icons share the checkbox's three-cell column.
- To do that the parser's tag token now swallows one trailing space, so the text starts at the fifth cell, like [ ] text.
#wpf#avalonedit#csharp#ui-alignment
·4 min read

TaskPad · Story
TaskPad comment editing threw because WPF panels do not allow Children[i] = x
The edit button swapped a TextBlock for a TextBox by assigning into a panel's Children by index. WPF throws on that. RemoveAt then Insert fixed it, and copy plus a right-click menu came along.
In short
- Comment editing replaced a TextBlock with a TextBox by assigning into the panel's Children collection by index, which WPF does not allow.
- The fix removes the old element at its index and inserts the box at the same index, which keeps the position.
- While in there I moved delete into a local function so a toolbar button and a new right-click menu share one code path, and added copy with a short check mark as feedback.
#wpf#csharp#desktop#bugfix#ui
·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
·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