-
-
Notifications
You must be signed in to change notification settings - Fork 114
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description
When running the xUnit migration code fixer on a project with multiple test files, some files are converted while others are not. This leaves the project in a broken state where:
- Some files have TUnit syntax (
[Test],await Assert.That()) - Other files still have xUnit syntax (
[Fact],Assert.Equal()) - Both xUnit and TUnit packages are referenced
- Enabling TUnit implicit usings causes ambiguous reference errors in unconverted files
- Disabling implicit usings causes missing type errors in converted files
Steps to Reproduce
- Create a test project with 50+ xUnit test files
- Add TUnit package reference
- Run
dotnet format analyzers --severity info --diagnostics TUXU0001 - Observe partial conversion
Observed Behavior
In my test case with ~85 test files:
- ~54 files (~63%) were converted to TUnit syntax
- ~31 files (~37%) were NOT converted at all
The unconverted files still have:
using Xunit;[Fact]attributesAssert.Equal(),Assert.True(), etc.
The Broken State
With TUnit Implicit Usings Enabled
<TUnitImplicitUsings>true</TUnitImplicitUsings>Result:
- Converted files work but unconverted files fail:
error CS0104: 'Assert' is an ambiguous reference between 'TUnit.Assertions.Assert' and 'Xunit.Assert'
With TUnit Implicit Usings Disabled
<TUnitImplicitUsings>false</TUnitImplicitUsings>Result:
- Unconverted files might work but converted files fail:
error CS0246: The type or namespace name 'Test' could not be found
Expected Behavior
The code fixer should either:
- Convert ALL files in a project when run in project/solution scope (Fix All)
- Clearly report which files couldn't be converted and why
- Not leave the project in a broken, inconsistent state
Impact
This partial conversion issue makes the migration process extremely difficult because:
- Users cannot simply run the code fixer and have a working project
- Manual intervention is required to fix hundreds/thousands of compilation errors
- It's unclear which files need manual attention
- The error messages don't indicate whether the issue is with xUnit remnants or TUnit migration
Suggested Fix
- Priority: Fix the "Fix All" action (see issue TUXU0001: XUnitMigrationCodeFixProvider Fix All action not working #4416) so all files are converted
- Add diagnostic output listing files that couldn't be converted
- Add a validation pass after conversion that ensures no mixed state exists
- Consider atomic conversion - either convert all files or roll back changes
Workaround (for users)
Until this is fixed, users must:
- Run the code fixer
- Manually identify unconverted files:
grep -l "\[Fact\]" **/*.cs - Manually convert or run the code fixer file-by-file on remaining files
- Or remove xUnit package and fix all errors manually
Environment
- TUnit Version: 1.11.*
- .NET SDK: 10.0.102
- OS: Windows
Related Issues
- TUXU0001: XUnitMigrationCodeFixProvider Fix All action not working #4416 - Fix All action not working
- TUXU0001: Code fixer does not remove 'using Xunit;' directive after conversion #4417 - using Xunit not removed after conversion
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working