-
-
Notifications
You must be signed in to change notification settings - Fork 110
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Description
The NUnit migration code fixer (TUNU0001) converts NUnit's [Platform] attribute to [ExcludeOn(OS.X)], but neither the ExcludeOn attribute nor the OS enum exist in TUnit. This results in compilation errors.
Reproduction Steps
- Create a file with NUnit Platform attributes:
using NUnit.Framework;
public class TestClass
{
[Test]
[Platform(Exclude = "Mono")]
public void Test_ExcludeMono() { }
[Test]
[Platform(Exclude = "Net")]
public void Test_ExcludeNet() { }
[Test]
[Platform(Exclude = "Net,NetCore")]
public void Test_ExcludeNetAndNetCore() { }
}-
Run the code fixer:
dotnet format analyzers --severity info --diagnostics TUNU0001 -
The code is converted to:
using System.Threading.Tasks;
public class TestClass
{
[Test]
[ExcludeOn(OS.Mono)]
public async Task Test_ExcludeMono() { }
[Test]
[ExcludeOn(OS.Net)]
public async Task Test_ExcludeNet() { }
[Test]
[ExcludeOn(OS.Net | OS.NetCore)]
public async Task Test_ExcludeNetAndNetCore() { }
}- Building produces errors:
error CS0246: The type or namespace name 'ExcludeOn' could not be found
error CS0103: The name 'OS' does not exist in the current context
Expected Behavior
The code fixer should either:
- Convert Platform attributes to TUnit's equivalent skip mechanism (custom SkipAttribute)
- Leave a TODO comment indicating manual migration is required
- Not convert the attribute at all if no direct equivalent exists
Environment
- TUnit Version: 1.11.64
- .NET SDK: 10.0.100-preview.1.25103.12
- OS: Windows 11
Additional Context
TUnit's recommended approach for platform-specific test skipping is to create custom skip attributes by extending SkipAttribute. The code fixer is generating references to types that don't exist in TUnit.
Note: Please add tests when fixing this issue to prevent regression.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working