Skip to content

Code fixer creates merge conflict markers instead of clean transformations #4613

@thomhurst

Description

@thomhurst

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).

  1. Created a fresh clone of Castle.Core repository: https://github.com/castleproject/Core
  2. Installed TUnit package: dotnet add package TUnit
  3. Disabled implicit usings in .csproj:
    <TUnitImplicitUsings>false</TUnitImplicitUsings>
    <TUnitAssertionsImplicitUsings>false</TUnitAssertionsImplicitUsings>
  4. Rebuilt project: dotnet build
  5. 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()
>>>>>>> After

Affected Files:

  • src/Castle.Core.Tests/DynamicProxy.Tests/GenericInterfaceProxyTestCase.cs
  • src/Castle.Core.Tests/DynamicProxy.Tests/ModuleScopeTestCase.cs
  • src/Castle.Core.Tests/DynamicProxy.Tests/PersistentProxyBuilderTestCase.cs

Additional Observations

  1. The fixer appears to create multiple transformation attempts, leaving all versions in the file
  2. Some transformations appear incorrect (e.g., duplicate parameters in the intermediate version)
  3. This only affected 3 out of ~150 test files, so most transformations work correctly
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions