Skip to content

New Attributes documentation#1162

Merged
OsirisTerje merged 11 commits intomasterfrom
attributedocs
Mar 31, 2026
Merged

New Attributes documentation#1162
OsirisTerje merged 11 commits intomasterfrom
attributedocs

Conversation

@OsirisTerje
Copy link
Copy Markdown
Member

@OsirisTerje OsirisTerje commented Mar 29, 2026

Fixes #1161

Copilot AI review requested due to automatic review settings March 29, 2026 09:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds documentation and runnable snippets for several NUnit 4.6-era attributes and updates the attributes TOC so the new pages appear in the docs.

Changes:

  • Add new attribute docs pages: [UnhandledExceptionHandling], [NoTests], [NetPlatform], [TestAssemblyDirectoryResolve]
  • Add corresponding C# snippet/example files used by DocFX [!code-csharp] inclusions
  • Extend [TestCase] docs with a new section for generic TestCase attributes and update the attributes TOC

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
docs/snippets/Snippets.NUnit/Snippets.NUnit.csproj Updates NUnit package reference version for the snippets test project
docs/snippets/Snippets.NUnit/Attributes/UnhandledExceptionHandlingAttributeExamples.cs Adds snippet examples for [UnhandledExceptionHandling]
docs/snippets/Snippets.NUnit/Attributes/TestCaseGenericExamples.cs Adds snippet examples for generic TestCase attributes
docs/snippets/Snippets.NUnit/Attributes/TestAssemblyDirectoryResolveAttributeExamples.cs Adds snippet examples for [TestAssemblyDirectoryResolve]
docs/snippets/Snippets.NUnit/Attributes/NoTestsAttributeExamples.cs Adds snippet examples for [NoTests]
docs/snippets/Snippets.NUnit/Attributes/NetPlatformAttributeExamples.cs Adds snippet examples for [NetPlatform]
docs/articles/nunit/writing-tests/attributes/unhandledexceptionhandling.md New docs page for [UnhandledExceptionHandling]
docs/articles/nunit/writing-tests/attributes/testassemblydirectoryresolve.md New docs page for [TestAssemblyDirectoryResolve]
docs/articles/nunit/writing-tests/attributes/notests.md New docs page for [NoTests]
docs/articles/nunit/writing-tests/attributes/netplatform.md New docs page for [NetPlatform]
docs/articles/nunit/writing-tests/attributes/toc.yml Adds new attribute pages to the attributes TOC
docs/articles/nunit/writing-tests/attributes/testcase.md Adds “Generic TestCase Attributes” section and snippet references

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +13 to +21
// Any unhandled exception on background threads will cause this test to fail
// This is the default behavior
var task = Task.Run(() =>
{
// Work that completes successfully
Thread.Sleep(10);
});
task.Wait();
Assert.Pass();
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example is framed as handling unhandled background-thread exceptions, but Task.Run(...); task.Wait(); observes any exception on the main test thread. That means this pattern won’t illustrate (and may contradict) what [UnhandledExceptionHandling] affects per the warning in the docs. Consider adjusting the snippet/comment to use a truly unhandled background exception scenario (e.g., a fire-and-forget thread) or rewording to avoid implying Wait() is relevant here.

Copilot uses AI. Check for mistakes.
Comment on lines +44 to +50
// Returns empty when certain conditions aren't met
if (Environment.GetEnvironmentVariable("RUN_CONDITIONAL_TESTS") == "true")
{
yield return "test1";
yield return "test2";
}
// Otherwise yields nothing - test will be Inconclusive
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example’s behavior depends on the RUN_CONDITIONAL_TESTS environment variable, which can make snippet test results vary between environments/CI runs. Prefer keeping snippet fixtures deterministic (e.g., base the condition on a local constant or provide two explicit sources) so the documented outcome is consistent.

Copilot uses AI. Check for mistakes.
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
<PackageReference Include="NUnit" Version="4.5.1" />
<PackageReference Include="NUnit" Version="4.6.0-*" />
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a floating prerelease version (4.6.0-*) makes restores non-deterministic and will fail if no matching prerelease exists on the configured NuGet feeds. Prefer pinning a specific NUnit version (e.g., 4.6.0) or using a stable floating patch range (e.g., 4.6.*) if you intentionally want updates.

Suggested change
<PackageReference Include="NUnit" Version="4.6.0-*" />
<PackageReference Include="NUnit" Version="4.6.0" />

Copilot uses AI. Check for mistakes.
OsirisTerje and others added 9 commits March 29, 2026 11:36
…esolveAttributeExamples.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…lingAttributeExamples.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…nhandling.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…s.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…s.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@OsirisTerje OsirisTerje requested a review from SeanKilleen March 29, 2026 17:49
@OsirisTerje OsirisTerje merged commit b7ef520 into master Mar 31, 2026
7 checks passed
@OsirisTerje OsirisTerje deleted the attributedocs branch March 31, 2026 10:28
github-actions bot pushed a commit that referenced this pull request Mar 31, 2026
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.

Undocumented attributes

3 participants