Skip to content

[Bug]: CS0111 and CS0411 in moq creation #5434

@dukedagmor

Description

@dukedagmor

Description

Azure.Data.Tables.TableClient and Azure.Storage.Blobs.BlobClient still encounter build errors

Expected Behavior

no build errors

Actual Behavior

PowerShell 7.6.0
PS My\Location> $path = Join-Path $env:TEMP 'tunit-blob-latest.cs'; Set-Content -Path $path -Value @'
>> #:property LangVersion=preview
>> #:property ManagePackageVersionsCentrally=false
>> #:package TUnit.Mocks@1.28.7-beta
>> #:package Azure.Data.Tables@12.11.0
>> #:package Azure.Storage.Blobs@12.27.0
>>
>> using Azure.Data.Tables;
>> using Azure.Storage.Blobs;
>>
>> var tableClientMock = Mock.Of<TableClient>(MockBehavior.Strict);
>> var blobClientMock = Mock.Of<BlobClient>(MockBehavior.Strict);
>>
>> Console.WriteLine($"Created: {tableClientMock.Object.GetType().Name}, {blobClientMock.Object.GetType().Name}");
>> '@; dotnet run $path
My\Location\AppData\Local\Temp\dotnet\runfile\tunit-blob-latest-6eefa9b3c27d469b423de24d470f8b5c2f42e48bbde4c39a538c66600f9bcc4c\obj\debug\TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\Azure_Storage_Blobs_BlobClient_MockMembers.g.cs(5433,83): error CS0111: Type 'Azure_Storage_Blobs_BlobClient_MockMemberExtensions' already defines a member called 'GenerateSasUri' with the same parameter types
My\Location\AppData\Local\Temp\dotnet\runfile\tunit-blob-latest-6eefa9b3c27d469b423de24d470f8b5c2f42e48bbde4c39a538c66600f9bcc4c\obj\debug\TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\Azure_Storage_Blobs_BlobClient_MockMembers.g.cs(5439,83): error CS0111: Type 'Azure_Storage_Blobs_BlobClient_MockMemberExtensions' already defines a member called 'GenerateSasUri' with the same parameter types
My\Location\AppData\Local\Temp\dotnet\runfile\tunit-blob-latest-6eefa9b3c27d469b423de24d470f8b5c2f42e48bbde4c39a538c66600f9bcc4c\obj\debug\TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\Azure_Storage_Blobs_BlobClient_MockMembers.g.cs(5446,83): error CS0111: Type 'Azure_Storage_Blobs_BlobClient_MockMemberExtensions' already defines a member called 'GenerateSasUri' with the same parameter types
My\Location\AppData\Local\Temp\dotnet\runfile\tunit-blob-latest-6eefa9b3c27d469b423de24d470f8b5c2f42e48bbde4c39a538c66600f9bcc4c\obj\debug\TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\Azure_Storage_Blobs_BlobClient_MockMembers.g.cs(5453,83): error CS0111: Type 'Azure_Storage_Blobs_BlobClient_MockMemberExtensions' already defines a member called 'GenerateSasUri' with the same parameter types
My\Location\AppData\Local\Temp\dotnet\runfile\tunit-blob-latest-6eefa9b3c27d469b423de24d470f8b5c2f42e48bbde4c39a538c66600f9bcc4c\obj\debug\TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\Azure_Storage_Blobs_BlobClient_MockMembers.g.cs(5474,83): error CS0111: Type 'Azure_Storage_Blobs_BlobClient_MockMemberExtensions' already defines a member called 'GenerateSasUri' with the same parameter types
My\Location\AppData\Local\Temp\dotnet\runfile\tunit-blob-latest-6eefa9b3c27d469b423de24d470f8b5c2f42e48bbde4c39a538c66600f9bcc4c\obj\debug\TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\Azure_Storage_Blobs_BlobClient_MockMembers.g.cs(5480,83): error CS0111: Type 'Azure_Storage_Blobs_BlobClient_MockMemberExtensions' already defines a member called 'GenerateSasUri' with the same parameter types
My\Location\AppData\Local\Temp\dotnet\runfile\tunit-blob-latest-6eefa9b3c27d469b423de24d470f8b5c2f42e48bbde4c39a538c66600f9bcc4c\obj\debug\TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\Azure_Storage_Blobs_BlobClient_MockMembers.g.cs(5547,97): error CS0111: Type 'Azure_Storage_Blobs_BlobClient_MockMemberExtensions' already defines a member called 'GenerateUserDelegationSasUri' with the same parameter types
My\Location\AppData\Local\Temp\dotnet\runfile\tunit-blob-latest-6eefa9b3c27d469b423de24d470f8b5c2f42e48bbde4c39a538c66600f9bcc4c\obj\debug\TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\Azure_Storage_Blobs_BlobClient_MockMembers.g.cs(5553,97): error CS0111: Type 'Azure_Storage_Blobs_BlobClient_MockMemberExtensions' already defines a member called 'GenerateUserDelegationSasUri' with the same parameter types
My\Location\AppData\Local\Temp\dotnet\runfile\tunit-blob-latest-6eefa9b3c27d469b423de24d470f8b5c2f42e48bbde4c39a538c66600f9bcc4c\obj\debug\TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\Azure_Storage_Blobs_BlobClient_MockMembers.g.cs(5560,97): error CS0111: Type 'Azure_Storage_Blobs_BlobClient_MockMemberExtensions' already defines a member called 'GenerateUserDelegationSasUri' with the same parameter types
My\Location\AppData\Local\Temp\dotnet\runfile\tunit-blob-latest-6eefa9b3c27d469b423de24d470f8b5c2f42e48bbde4c39a538c66600f9bcc4c\obj\debug\TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\Azure_Storage_Blobs_BlobClient_MockMembers.g.cs(5567,97): error CS0111: Type 'Azure_Storage_Blobs_BlobClient_MockMemberExtensions' already defines a member called 'GenerateUserDelegationSasUri' with the same parameter types
My\Location\AppData\Local\Temp\dotnet\runfile\tunit-blob-latest-6eefa9b3c27d469b423de24d470f8b5c2f42e48bbde4c39a538c66600f9bcc4c\obj\debug\TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\Azure_Storage_Blobs_BlobClient_MockMembers.g.cs(5575,97): error CS0111: Type 'Azure_Storage_Blobs_BlobClient_MockMemberExtensions' already defines a member called 'GenerateUserDelegationSasUri' with the same parameter types
My\Location\AppData\Local\Temp\dotnet\runfile\tunit-blob-latest-6eefa9b3c27d469b423de24d470f8b5c2f42e48bbde4c39a538c66600f9bcc4c\obj\debug\TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\Azure_Storage_Blobs_BlobClient_MockMembers.g.cs(5582,97): error CS0111: Type 'Azure_Storage_Blobs_BlobClient_MockMemberExtensions' already defines a member called 'GenerateUserDelegationSasUri' with the same parameter types
My\Location\AppData\Local\Temp\dotnet\runfile\tunit-blob-latest-6eefa9b3c27d469b423de24d470f8b5c2f42e48bbde4c39a538c66600f9bcc4c\obj\debug\TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\Azure_Storage_Blobs_BlobClient_MockMembers.g.cs(5590,97): error CS0111: Type 'Azure_Storage_Blobs_BlobClient_MockMemberExtensions' already defines a member called 'GenerateUserDelegationSasUri' with the same parameter types
My\Location\AppData\Local\Temp\dotnet\runfile\tunit-blob-latest-6eefa9b3c27d469b423de24d470f8b5c2f42e48bbde4c39a538c66600f9bcc4c\obj\debug\TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\Azure_Storage_Blobs_BlobClient_MockMembers.g.cs(5598,97): error CS0111: Type 'Azure_Storage_Blobs_BlobClient_MockMemberExtensions' already defines a member called 'GenerateUserDelegationSasUri' with the same parameter types
My\Location\AppData\Local\Temp\dotnet\runfile\tunit-blob-latest-6eefa9b3c27d469b423de24d470f8b5c2f42e48bbde4c39a538c66600f9bcc4c\obj\debug\TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\Azure_Storage_Blobs_BlobClient_MockMembers.g.cs(5635,97): error CS0111: Type 'Azure_Storage_Blobs_BlobClient_MockMemberExtensions' already defines a member called 'GenerateUserDelegationSasUri' with the same parameter types
My\Location\AppData\Local\Temp\dotnet\runfile\tunit-blob-latest-6eefa9b3c27d469b423de24d470f8b5c2f42e48bbde4c39a538c66600f9bcc4c\obj\debug\TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\Azure_Storage_Blobs_BlobClient_MockMembers.g.cs(5641,97): error CS0111: Type 'Azure_Storage_Blobs_BlobClient_MockMemberExtensions' already defines a member called 'GenerateUserDelegationSasUri' with the same parameter types
My\Location\AppData\Local\Temp\dotnet\runfile\tunit-blob-latest-6eefa9b3c27d469b423de24d470f8b5c2f42e48bbde4c39a538c66600f9bcc4c\obj\debug\TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\Azure_Storage_Blobs_BlobClient_MockMembers.g.cs(5648,97): error CS0111: Type 'Azure_Storage_Blobs_BlobClient_MockMemberExtensions' already defines a member called 'GenerateUserDelegationSasUri' with the same parameter types
My\Location\AppData\Local\Temp\dotnet\runfile\tunit-blob-latest-6eefa9b3c27d469b423de24d470f8b5c2f42e48bbde4c39a538c66600f9bcc4c\obj\debug\TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\Azure_Storage_Blobs_BlobClient_MockMembers.g.cs(5655,97): error CS0111: Type 'Azure_Storage_Blobs_BlobClient_MockMemberExtensions' already defines a member called 'GenerateUserDelegationSasUri' with the same parameter types

The build failed. Fix the build errors and run again.
PS My\Location> $path = Join-Path $env:TEMP 'tunit-blob-latest.cs'; Set-Content -Path $path -Value @'
>> #:property LangVersion=preview
>> #:property ManagePackageVersionsCentrally=false
>> #:package TUnit.Mocks@1.28.7-beta
>> #:package Azure.Data.Tables@12.11.0
>> #:package Azure.Storage.Blobs@12.27.0
>>
>> using Azure.Data.Tables;
>> using Azure.Storage.Blobs;
>>
>> var tableClientMock = Mock.Of<TableClient>(MockBehavior.Strict);//var blobClientMock = Mock.Of<BlobClient>(MockBehavior.Strict);
>>
>> Console.WriteLine($"Created: {tableClientMock.Object.GetType().Name}, /*{blobClientMock.Object.GetType().Name}*/");
>> '@; dotnet run $path
My\Location\AppData\Local\Temp\tunit-blob-latest.cs(12,74): error CS0103: The name 'blobClientMock' does not exist in the current context
My\Location\AppData\Local\Temp\dotnet\runfile\tunit-blob-latest-6eefa9b3c27d469b423de24d470f8b5c2f42e48bbde4c39a538c66600f9bcc4c\obj\debug\TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\Azure_Data_Tables_TableClient_MockImplFactory.g.cs(162,25): error CS0411: The type arguments for method 'TableClient.GetEntity<T>(string, string, IEnumerable<string>, CancellationToken)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
My\Location\AppData\Local\Temp\dotnet\runfile\tunit-blob-latest-6eefa9b3c27d469b423de24d470f8b5c2f42e48bbde4c39a538c66600f9bcc4c\obj\debug\TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\Azure_Data_Tables_TableClient_MockImplFactory.g.cs(176,25): error CS0411: The type arguments for method 'TableClient.GetEntityAsync<T>(string, string, IEnumerable<string>, CancellationToken)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
My\Location\AppData\Local\Temp\dotnet\runfile\tunit-blob-latest-6eefa9b3c27d469b423de24d470f8b5c2f42e48bbde4c39a538c66600f9bcc4c\obj\debug\TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\Azure_Data_Tables_TableClient_MockImplFactory.g.cs(185,25): error CS0411: The type arguments for method 'TableClient.GetEntityIfExists<T>(string, string, IEnumerable<string>, CancellationToken)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
My\Location\AppData\Local\Temp\dotnet\runfile\tunit-blob-latest-6eefa9b3c27d469b423de24d470f8b5c2f42e48bbde4c39a538c66600f9bcc4c\obj\debug\TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\Azure_Data_Tables_TableClient_MockImplFactory.g.cs(199,25): error CS0411: The type arguments for method 'TableClient.GetEntityIfExistsAsync<T>(string, string, IEnumerable<string>, CancellationToken)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
My\Location\AppData\Local\Temp\dotnet\runfile\tunit-blob-latest-6eefa9b3c27d469b423de24d470f8b5c2f42e48bbde4c39a538c66600f9bcc4c\obj\debug\TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\Azure_Data_Tables_TableClient_MockImplFactory.g.cs(272,25): error CS0411: The type arguments for method 'TableClient.QueryAsync<T>(Expression<Func<T, bool>>, int?, IEnumerable<string>, CancellationToken)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
My\Location\AppData\Local\Temp\dotnet\runfile\tunit-blob-latest-6eefa9b3c27d469b423de24d470f8b5c2f42e48bbde4c39a538c66600f9bcc4c\obj\debug\TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\Azure_Data_Tables_TableClient_MockImplFactory.g.cs(281,25): error CS0411: The type arguments for method 'TableClient.Query<T>(Expression<Func<T, bool>>, int?, IEnumerable<string>, CancellationToken)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

The build failed. Fix the build errors and run again.
PS My\Location>

Steps to Reproduce

#:property LangVersion=preview
#:property ManagePackageVersionsCentrally=false
#:package TUnit.Mocks@1.28.7-beta
#:package Azure.Data.Tables@12.11.0
#:package Azure.Storage.Blobs@12.27.0

using Azure.Data.Tables;
using Azure.Storage.Blobs;

var tableClientMock = Mock.Of<TableClient>(MockBehavior.Strict);
var blobClientMock = Mock.Of<BlobClient>(MockBehavior.Strict);

Console.WriteLine($"Created: {tableClientMock.Object.GetType().Name}, {blobClientMock.Object.GetType().Name}");

and

#:property LangVersion=preview
#:property ManagePackageVersionsCentrally=false
#:package TUnit.Mocks@1.28.7-beta
#:package Azure.Data.Tables@12.11.0
#:package Azure.Storage.Blobs@12.27.0

using Azure.Data.Tables;
using Azure.Storage.Blobs;

var tableClientMock = Mock.Of<TableClient>(MockBehavior.Strict);//var blobClientMock = Mock.Of<BlobClient>(MockBehavior.Strict);

Console.WriteLine($"Created: {tableClientMock.Object.GetType().Name}, /*{blobClientMock.Object.GetType().Name}*/");

TUnit Version

1.28.7-beta

.NET Version

.NET 10

Operating System

Windows

IDE / Test Runner

dotnet CLI (dotnet test / dotnet run)

Error Output / Stack Trace

Additional Context

No response

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