Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable (C# 10) Implicit usings on a specific class

Tags:

c#

using

c#-10.0

C# 10 brought implicit usings.

I globaly like them, but they're causing me a conflict on a particular class called Region as there's a conflict with the Microsoft.Identity.Client.Region class.

There's a nice thread here explaining how to disable implicit usings everywhere: C# 10: Disable Global Using

I don't want to do it globally, I want to do it just on specific classes. Alternatively, a solution that would allow me to disable a particular implicit using (Microsoft.Identity.Client.Region) would also serve my needs.

like image 259
Luis Gouveia Avatar asked Oct 19 '25 12:10

Luis Gouveia


1 Answers

To remove implicit namespace for project completely you can use Using xml element (see also) with Remove attribute:

<ItemGroup>
    <Using Remove="Microsoft.Identity.Client" />
</ItemGroup>

It also provides option to specify Condition attribute but I have not found docs on it for this specific use case.

like image 188
Guru Stron Avatar answered Oct 21 '25 02:10

Guru Stron