Description
Since v1.44 compilation fail when using mocking (MyType.Mock()).
CS9262 - Cannot use 'OverloadResolutionPriorityAttribute' on this member.
The issue happens in generated obj\Debug\net9.0\TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\ProjectName_MyType_MockMembers.g.cs file that unfortunately get automatically get cleaned up.
Expected Behavior
Generated mocked file should compile
Actual Behavior
Generated mocked file doesn't compile with error CS9262
Steps to Reproduce
public interface IDumb
{}
/// <summary>
/// Error CS9262 : Cannot use 'OverloadResolutionPriorityAttribute' on this member.
/// Starting from Tunit.Mocks 1.44.0 -> https://github.com/thomhurst/TUnit/commit/15f8062a70fd840ec62df159ebd1d6bc321e3635
/// </summary>
public class MyTests
{
[Test]
public async Task MOCK_TEST()
{
///Arrange
// raises the CS9262 error when building
var dumbMock = IDumb.Mock();
// Or : var dumbMock = Mock.Of<IDumb>();
///Act
///Assert
await Assert.That(true).IsTrue();
}
}
TUnit Version
from 1.44.0
.NET Version
.NET 9.0
Operating System
Windows
IDE / Test Runner
Visual Studio
Error Output / Stack Trace
CS9262 - Cannot use 'OverloadResolutionPriorityAttribute' on this member.
CS9262 - Cannot use 'OverloadResolutionPriorityAttribute' on this member.
CS9262 - Cannot use 'OverloadResolutionPriorityAttribute' on this member.
Additional Context
I am using Visual Studio 2022 Version 17.14.35 (June 2026)
My .csproj is
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>preview</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="TUnit" Version="1.58.0" />
<PackageReference Include="TUnit.Mocks" Version="1.58.0" />
<PackageReference Include="TUnit.Mocks.Assertions" Version="1.58.0" />
</ItemGroup>
</Project>
IDE-Specific Issue?
Description
Since v1.44 compilation fail when using mocking (
MyType.Mock()).The issue happens in generated
obj\Debug\net9.0\TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\ProjectName_MyType_MockMembers.g.csfile that unfortunately get automatically get cleaned up.Expected Behavior
Generated mocked file should compile
Actual Behavior
Generated mocked file doesn't compile with error CS9262
Steps to Reproduce
TUnit Version
from 1.44.0
.NET Version
.NET 9.0
Operating System
Windows
IDE / Test Runner
Visual Studio
Error Output / Stack Trace
Additional Context
I am using Visual Studio 2022 Version 17.14.35 (June 2026)
My .csproj is
IDE-Specific Issue?
dotnet testordotnet run, not just in my IDE