-
-
Notifications
You must be signed in to change notification settings - Fork 111
Description
Description
The TUnit automated code fixer (dotnet format analyzers --severity info --diagnostics TUNU0001) is creating merge conflict markers in the source code instead of cleanly applying transformations. This causes compilation errors (CS8300: Merge conflict marker encountered) that prevent the migrated project from building.
Steps to Reproduce
I followed the migration guide at https://tunit.dev/docs/migration/nunit using Castle.Core's test suite (a large, multi-targeting NUnit test project).
- Created a fresh clone of Castle.Core repository: https://github.com/castleproject/Core
- Installed TUnit package:
dotnet add package TUnit - Disabled implicit usings in .csproj:
<TUnitImplicitUsings>false</TUnitImplicitUsings> <TUnitAssertionsImplicitUsings>false</TUnitAssertionsImplicitUsings>
- Rebuilt project:
dotnet build - Ran code fixer:
dotnet format analyzers --severity info --diagnostics TUNU0001 --framework net10.0
Project details:
- Multi-targeting: net8.0, net9.0, net10.0, net462
- ~150 test files
- Large NUnit test suite (Castle.Core.Tests)
Expected Behavior
The code fixer should cleanly replace NUnit syntax with TUnit syntax without leaving merge conflict markers.
Actual Behavior
The code fixer created merge conflict markers showing "Before" and "After" versions, which prevents compilation:
ProxyWithGenInterfaceWithBase();
<<<<<<< TODO: Unmerged change from project 'Castle.Core.Tests(net462)', Before:
Assert.AreEqual(4, typeof(IGenInterfaceHierarchyBase<int>).GetMethods().Length);
=======
Assert.AreEqual(typeof(IGenInterfaceHierarchyBase<int>).GetMethods().Length).IsEqualTo(4);
>>>>>>> After
await Assert.That(typeof(IGenInterfaceHierarchyBase<int>).GetMethods().Length).IsEqualTo(4);
}Another example from the same file:
<<<<<<< TODO: Unmerged change from project 'Castle.Core.Tests(net462)', Before:
[Test(Description =
"There is a strange CLR bug resulting from our loading the tokens of methods in generic types. " +
"This test ensures we correctly work around it.")]
public void GetAllInstanceMethodsIsStable()
=======
[Test]
[Property("Description", "There is a strange CLR bug resulting from our loading the tokens of methods in generic types. " +
"This test ensures we correctly work around it.")]
public async Task GetAllInstanceMethodsIsStable()
>>>>>>> AfterAffected Files:
src/Castle.Core.Tests/DynamicProxy.Tests/GenericInterfaceProxyTestCase.cssrc/Castle.Core.Tests/DynamicProxy.Tests/ModuleScopeTestCase.cssrc/Castle.Core.Tests/DynamicProxy.Tests/PersistentProxyBuilderTestCase.cs
Additional Observations
- The fixer appears to create multiple transformation attempts, leaving all versions in the file
- Some transformations appear incorrect (e.g., duplicate parameters in the intermediate version)
- This only affected 3 out of ~150 test files, so most transformations work correctly
- All build errors stem from these merge conflict markers (CS8300, CS1002, CS1513, CS1027)
Environment
- TUnit Version: 1.12.90
- .NET SDK: 10.0.100
- OS: Linux 6.17.0-8-generic
- Command:
dotnet format analyzers --severity info --diagnostics TUNU0001 --framework net10.0
Workaround
Manually resolve the conflict markers by keeping only the final transformation (the line after ">>>>>>> After").
Impact
This bug prevents automated migration of NUnit test suites to TUnit, requiring manual intervention to fix the merge conflict markers before the project can build.