Repository navigation
Fix session file loading crash, deploy the native DLL, and add a README - #16
Merged
Merged
Conversation
Describes what the application records and analyses, how to build and run it, the session file format and the recovery behaviour, the layout of the three projects, and how to run the tests. Points at the coding guidelines already in the repository. Notes that the licensing of the third-party header in TruRNGpro has not been established, which is worth settling before the code is distributed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0153VVkWg7DQmdaNLcvtY37w
Starting a session threw DllNotFoundException for TruRNGpro.dll. The native DLL was copied to the solution bin directory and into the test output, but nothing put it next to the application in its own output directory, which is where the application runs from and so where it looks for it. The test project already copies the DLL into its output, which is why the tests exercised the device interface without trouble while the application could not load it at all. The application project now does the same. Verified by loading the built assembly with neither the PATH nor the working directory pointing at the DLL, calling InitializeDevice in simulate mode and reading from the simulator. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0153VVkWg7DQmdaNLcvtY37w
Opening a session file took the application down with a stack overflow. Loading a session sets the simulate toggle to match the file it came from. The handler for that toggle worked out the new state by inverting what was recorded rather than by reading the toggle, and then set the toggle from that result. Setting it from code with a value the recording disagreed with left the two of them setting each other without end. The handler now takes the state from the toggle and no longer writes to it, so setting it from code settles. This is reached by opening any session recorded in a different mode to the one currently selected, which includes the ordinary case of opening a simulated session in a freshly started application. The file itself has nothing to do with it; a properly closed file and one left unfinished both brought the application down in the same way. Found by driving the interface rather than the classes behind it. The unit tests do not build the form's event wiring, and a session had to be started before opening a file for the toggle to already agree and the fault to be missed. A test covers the invariant now, reaching the toggle by reflection as it is not exposed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0153VVkWg7DQmdaNLcvtY37w
Replaces the committed binary with the build supplied for this work. There is no source for it in this repository, so it is carried as a binary the same way DeviceInterfaces.dll is. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0153VVkWg7DQmdaNLcvtY37w
There was a problem hiding this comment.
🟢 Approval recommended
The changes directly address the reported crash and deployment issue with low-risk, well-scoped edits and include a regression test for the crash scenario.
Pull request overview
Fixes a WinForms crash when loading session files by preventing recursive toggling of the Simulate checkbox, ensures the native TruRNGpro.dll is deployed alongside the application output so the app can actually P/Invoke it at runtime, and documents build/run/test and session-file details in a new README.
Changes:
- Prevent infinite recursion/stack overflow by updating the simulate-toggle handler to read from the control state (and not write back into it).
- Add a component test that exercises setting the simulate toggle from code (regression coverage for the crash path).
- Copy
TruRNGpro.dllinto the application output directory during the app project’s post-build step, and add a repository README with build/run/test guidance and file format notes.
File summaries
| File | Description |
|---|---|
| README.md | Adds documentation for purpose, build/run steps, tests, and session XML format/recovery behavior. |
| RandomNumberGenerator.Test/GeneratorForm.Test.cs | Adds a regression test covering programmatic simulate-toggle setting without re-entrant toggling. |
| RandomNumberGenerator.csproj | Updates post-build to deploy TruRNGpro.dll into the app output folder. |
| GeneratorForm.cs | Fixes simulate-toggle event handling to avoid recursive CheckedChanged behavior. |
Review details
- Files reviewed: 4/5 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Four changes found by running the application rather than only its tests.
Opening a session file crashed the application
STATUS_STACK_OVERFLOW, confirmed in the Windows event log, faulting inntdll.dll. The application died about two seconds after a file was opened.Loading a session sets the simulate toggle to match the file it came from. The handler for that toggle worked out its new state by inverting what was recorded rather than by reading the toggle, then wrote the result back to the toggle from inside its own event:
This is reached by opening any session recorded in a different mode to the one currently selected, which includes the ordinary case of opening a simulated session in a freshly started application. The file itself has nothing to do with it: a properly closed file and one left unfinished both brought the application down in the same way.
The handler now takes its state from the toggle and no longer writes to it, so setting it from code settles. A test covers the invariant, reaching the toggle by reflection as it is not exposed.
This blocked the recovery of unfinished session files entirely. That work went through five rounds of review on the previous pull request and could not be reached through the interface at all.
The native DLL was never deployed next to the application
Starting a session threw
DllNotFoundExceptionforTruRNGpro.dll. The build placed it in the solutionbindirectory and in the test output, but nothing put it beside the application in its own output directory, which is where the application runs from and so where it looks for it. The test project had been copying it into its own output all along, which is why the tests exercised the device interface while the application could not load it.README
Describes what the application records and analyses, how to build and run it, the session file format and the recovery behaviour, the layout of the three projects, and how to run the tests. It also notes that the licensing of the third-party header in
TruRNGprohas not been established, which is worth settling before the code is distributed.CommonControls.dll
Updated to the build supplied for this work. There is no source for it here, so it is carried as a binary the same way
DeviceInterfaces.dllis.Verification
Driven through the interface with the controls operated directly, rather than against the classes behind them:
Covering recording (average 0.499973, standard deviation 3.94e-3), pause and resume halting and continuing at the exact point counts, loading and appending 81 to 113 points, the baseline against result comparison, and recovery end to end: the application killed while recording, reopened, 50 points recovered, the recovery reported to the user, the session continued to 82 points and the file left valid.
🤖 Generated with Claude Code
https://claude.ai/code/session_0153VVkWg7DQmdaNLcvtY37w