Skip to content

Correct and complete the UnhandledExceptionHandling attribute documentation - #1283

Open
SeanKilleen wants to merge 2 commits into
masterfrom
1151_unhandled-exception-handling-attribute
Open

SeanKilleen wants to merge 2 commits into
masterfrom
1151_unhandled-exception-handling-attribute

Conversation

@SeanKilleen

Copy link
Copy Markdown
Member

The UnhandledExceptionHandling page existed but had two inaccuracies and a gap, checked against NUnitTestAssemblyRunner, UnhandledExceptionHandlingAttribute and the framework's own tests:

  • Precedence was wrong. The page said settings at different levels are "combined - each level's configuration is additive". GetUnhandledExceptionHandlingFor actually walks method → fixture → assembly and uses the first level with a match; within a level, an entry naming the exception type beats an all-exceptions entry. Replaced with a "Precedence When Applied at Several Levels" section and an example of ignoring everything except one type at the same level.
  • Platform behaviour was missing. On .NET Core / .NET 5+, an unhandled exception on another thread terminates the process regardless of the attribute (the framework tests are limited to NETFRAMEWORK for this reason), and unobserved Task exceptions are raised on the finalizer thread where NUnit cannot attribute them to a test. Added a "Platform Support" section and rewrote the "Common Scenarios" that used Task.Run as if the attribute would catch them.
  • Added the constructor table, a "When to Use It" section (the issue asked when it is appropriate), fixed the See Also links, and added the missing row on the attributes index page.
  • Updated the two snippet examples that spawned tasks to use threads that do not throw, with comments explaining why they cannot throw on modern .NET. Snippet tests pass (6 passed, 1 skipped on .NET as before).

Fixes #1151

🤖 Generated with Claude Code

…tation

The `UnhandledExceptionHandling` page existed but had two inaccuracies and a gap, checked against `NUnitTestAssemblyRunner`, `UnhandledExceptionHandlingAttribute` and the framework's own tests:

* **Precedence was wrong.** The page said settings at different levels are "combined - each level's configuration is additive". `GetUnhandledExceptionHandlingFor` actually walks method → fixture → assembly and uses the first level with a match; within a level, an entry naming the exception type beats an all-exceptions entry. Replaced with a "Precedence When Applied at Several Levels" section and an example of ignoring everything except one type at the same level.
* **Platform behaviour was missing.** On .NET Core / .NET 5+, an unhandled exception on another thread terminates the process regardless of the attribute (the framework tests are limited to `NETFRAMEWORK` for this reason), and unobserved `Task` exceptions are raised on the finalizer thread where NUnit cannot attribute them to a test. Added a "Platform Support" section and rewrote the "Common Scenarios" that used `Task.Run` as if the attribute would catch them.
* Added the constructor table, a "When to Use It" section (the issue asked when it is appropriate), fixed the See Also links, and added the missing row on the attributes index page.
* Updated the two snippet examples that spawned tasks to use threads that do not throw, with comments explaining why they cannot throw on modern .NET. Snippet tests pass (6 passed, 1 skipped on .NET as before).

Fixes #1151

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

📖 Docs preview: https://pr-1283.nunit-docs.pages.dev

Built from bfde25a. This link always shows the latest build for this PR; the build for this exact commit is at https://3abcb464.nunit-docs.pages.dev.

Previews are hosted on Cloudflare Pages, are not indexed by search engines, and are removed when the PR is closed. They omit the archived NUnit 2.x documentation (the /2.x/ pages), which never changes; use the live site for those.

Resolve conflicts from the table-alignment sweep in #1284 by keeping the
aligned column formatting and re-applying this branch's content changes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document the UnhandledException behaviour

1 participant