Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .devcontainer/get-nunit-apidocs.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# This script gets the the latest version of NUnit and extracts it. This is because docfx is capable of generating API docs, and this way the Codespace will be automatically enabled to do that.

# This is hard-coded for now.
NUNIT_VERSION_FOR_API_DOCS="4.3.2"
NUNIT_VERSION_FOR_API_DOCS="4.6.1"

first_workspace="$(cd /workspaces && ls | head -1)"

wget "https://github.com/nunit/nunit/releases/download/$NUNIT_VERSION_FOR_API_DOCS/NUnit.Framework-$NUNIT_VERSION_FOR_API_DOCS.zip" -O /apidocs.zip
wget "https://github.com/nunit/nunit/releases/download/v$NUNIT_VERSION_FOR_API_DOCS/NUnit.Framework-$NUNIT_VERSION_FOR_API_DOCS.zip" -O /apidocs.zip


mkdir -p /workspaces/$first_workspace/code-output
Expand Down
75 changes: 49 additions & 26 deletions docs/articles/nunit/writing-tests/attributes/platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ PlatformAttribute(string[] includes)
|----------|------|-------------|---------|
| `Include` | `string` | Comma-delimited list of included platforms. | `null` |
| `Exclude` | `string` | Comma-delimited list of excluded platforms. | `null` |
| `Includes` | `string[]` | Array of included platforms. | `null` |
| `Excludes` | `string[]` | Array of excluded platforms. | `null` |

## Applies To

Expand All @@ -53,7 +55,7 @@ PlatformAttribute(string[] includes)

## Platform Specifiers

The following values are recognized as platform specifiers. They may be expressed in upper, lower or mixed case.
The following values are recognized as platform specifiers. They may be expressed in upper, lower or mixed case. A list of supported identifiers can also be referenced from the named constants in the [`PlatformNames`](/api/NUnit.Framework.PlatformNames.html) class. _(NUnit 4.6+)_.

### Operating System

Expand Down Expand Up @@ -88,10 +90,6 @@ The following values are recognized as platform specifiers. They may be expresse
* MacOsX
* XBox

A list of supported platform identifiers can also be obtained from the constant string `PlatformHelper.OSPlatforms` of
the NUnit assembly you use. Note that this is for informational purposes only, because the `PlatformHelper` is
considered an internal type and shall not be used in production.

### Architecture

* 32-Bit
Expand All @@ -104,30 +102,55 @@ considered an internal type and shall not be used in production.
### Runtime

* Net
* Net-1.0
* Net-1.1
* Net-2.0
* Net-3.0 (1)
* Net-3.5 (2)
* Net-4.0
* Net-4.5 (3)
* NetCF
* NETCore
* DotNET
* DotNETCore
* NETFramework _(NUnit 5+)_
* DotNETFramework _(NUnit 5+)_

> [!IMPORTANT]
> **Breaking change in NUnit 5:** The meaning of `NET` and `DotNET` has changed to better align with
> Microsoft's terminology. These identifiers previously targeted .NET Framework and now
> target modern .NET (.NET 5+, .NET Core). For more information please see the [**Breaking Changes**](#breaking-changes-in-nunit-5) section below.

#### Other Runtimes

* SSCLI
* Rotor
* Mono
* Mono-1.0
* Mono-2.0
* Mono-3.0 (4)
* Mono-3.5 (5)
* Mono-4.0

## Notes

1. Includes Net-2.0
2. Includes Net-2.0 and Net-3.0
3. Includes Net-4.0
4. Includes Mono-2.0
5. Includes Mono-2.0 and Mono-3.0
* MonoTouch

#### Runtime Version Specifiers

> [!NOTE]
> Version specifiers (for example, `Net-5.0`) are **not** supported for modern .NET identifiers.

A runtime version number can be appended using a dash, for example `NETFramework-4.0`, `NETFramework-4.5`, or `Mono-3.0`. These relate to the underlying Common Language Runtime (CLR) version and are inclusive of lower runtime versions which target the same CLR.

For example:

`NETFramework-4.5` will include `NETFramework-4.0` as both run on version 4 of the CLR. Similarly, `Mono-3.5` will include `Mono-2.0` and `Mono-3.0` as all run on version 2 of the MonoCLR.

## Breaking Changes in NUnit 5

The meaning of `NET` and `DotNET` has changed to better align with Microsoft's current .NET terminology. These identifiers previously targeted .NET Framework and now
target modern .NET (.NET 5+, .NET Core).

| Identifier | NUnit 4 | NUnit 5 |
|------------|---------|---------|
| `NET` | .NET Framework | Modern .NET |
| `NETFramework` | Not supported | .NET Framework |
| `NETCore` | Modern .NET | Modern .NET _(unchanged)_ |
| `DotNET` | .NET Framework | Modern .NET |
| `DotNETCore` | Modern .NET | Modern .NET _(unchanged)_ |
| `DotNETFramework` | Not supported | .NET Framework |

If you were using `[Platform("NET")]` or `[Platform("DotNET")]` to target .NET Framework,
update those usages to `[Platform("NETFramework")]` or `[Platform("DotNETFramework")]`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we suggest to use the non-string versions using the enums instead?

@stevenaw stevenaw Jul 8, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do you mean the named constants? I think we opted away from actual enums during implementation of PlatformNames.

I was conflicted on whether to leave these string literals in place here or not. I like the idea of using the named constants where we can in the docs though this particular case gave me pause since it deals with a change in how the underlying strings are handled relative to previous releases. The PlatformNames constants were only introduced a few months ago as part of 4.6 and are new enough that I thought it likely most consumers may still use string literals (or even their own defined constants which could vary in naming from our own)


Additionally, version-specific .NET targeting using `Net-X.X` (for example, `Net-4.0`, `Net-4.5`)
is no longer supported. Use `NETFramework-X.X` instead (for example, `NETFramework-4.0`,
`NETFramework-4.5`).

## `[SupportedOSPlatformAttribute]` and `[UnsupportedOSPlatformAttribute]` support

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,23 @@ public class PlatformAttributeExamples
public class PortableTests
{
[Test]
[Platform(Exclude = "Win98,WinME")]
[Platform(Excludes = ["Win98", "WinME"])]
public void SomeTest()
{
Assert.Pass("Runs only on supported platforms.");
}
}

[TestFixture]
public class RuntimeSpecificTests
{
[Test]
[Platform([PlatformNames.NETFramework])]
public void SomeTest()
{
Assert.Pass("Runs only on .NET Framework");
}
}
#endregion
}
}
Loading