Skip to content

[Bug]: TUnitInfrastructure can't handle duplicate types #4663

@dosolkowski-work

Description

@dosolkowski-work

Description

After upgrading to TUnit 1.12.125, tests stopped building with an error that a type exists in multiple assemblies. This is pretty severe, as it's entirely normal to have a type with the same name in different assemblies, and many SDKs do this just on their own.

Expected Behavior

Tests that previously built normally should continue to compile.

Actual Behavior

Compilation failed (see below error).

Steps to Reproduce

Create a test project with references (directly or indirectly) to assemblies that define the same type, e.g. Amazon.Lambda.AspNetCoreServer.Hosting and AWSSDK.SecretsManager. Observe that the project fails to build.

TUnit Version

1.12.125

.NET Version

.NET 10.0

Operating System

Windows

IDE / Test Runner

dotnet CLI (dotnet test / dotnet run)

Error Output / Stack Trace

C:\Work\Source\MyProject\obj\Debug\net10.0\TUnit.Core.SourceGenerator\TUnit.Core.SourceGenerator.CodeGenerators.InfrastructureGenerator\TUnitInfrastructure.g.cs(34,82): error CS0433: The type 'ServiceCollectionExtensions' exists in both 'AWSSDK.Extensions.NETCore.Setup, Version=4.0.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604' and 'Amazon.Lambda.AspNetCoreServer.Hosting, Version=0.0.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604'

Additional Context

I am not using AOT or trimming and I don't believe I have any custom configuration.

IDE-Specific Issue?

  • I've confirmed this issue occurs when running via dotnet test or dotnet run, not just in my IDE

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions