-
-
Notifications
You must be signed in to change notification settings - Fork 111
Closed
Labels
bugSomething isn't workingSomething isn't workingduplicateThis issue or pull request already existsThis issue or pull request already exists
Description
Description
The TUNU0001 NUnit migration code fixer crashes when running dotnet format analyzers --severity info --diagnostics TUNU0001 on projects that target multiple frameworks.
Reproduction Steps
- Create a test project with multiple target frameworks:
<PropertyGroup>
<TargetFrameworks>net8.0;net9.0;net10.0;net462</TargetFrameworks>
</PropertyGroup>- Add TUnit and NUnit packages:
<PackageReference Include="TUnit" Version="1.11.*" />
<PackageReference Include="NUnit" Version="3.14.0" />- Run the code fixer:
dotnet format analyzers --severity info --diagnostics TUNU0001Expected Behavior
The code fixer should process all files and apply migrations.
Actual Behavior
The code fixer crashes with the following exception:
Unhandled exception: System.AggregateException: One or more errors occurred. (Changes must be within bounds of SourceText (Parameter 'changes'))
---> System.ArgumentException: Changes must be within bounds of SourceText (Parameter 'changes')
at Microsoft.CodeAnalysis.Text.SourceText.WithChanges(IEnumerable`1 changes)
at Microsoft.CodeAnalysis.LinkedFileMergeConflictCommentAdditionService.GetCommentChangesForDocument(...)
...
Workaround
Temporarily change the project to use a single target framework:
<TargetFramework>net10.0</TargetFramework>Then run the code fixer, and restore multi-targeting afterward.
Environment
- TUnit version: 1.11.64
- .NET SDK: 10.0.102
- OS: Windows
Suggested Fix
The code fixer should handle multi-targeting projects by processing files for a single TFM at a time, or by properly merging changes across linked file instances.
Tests should be added to verify the code fixer works correctly with multi-targeting projects.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingduplicateThis issue or pull request already existsThis issue or pull request already exists