dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
34.84k stars 9.84k forks source link

Inconsistent namespaces #55824

Open PonchoPowers opened 1 month ago

PonchoPowers commented 1 month ago

Is there an existing issue for this?

Describe the bug

This happens in quite a few places, some namespaces have the word Abstractions in them, but then others don't.

Microsoft.Extensions.Caching.Abstractions Contains classes with the namespace: Microsoft.Extensions.Caching.X (no Abstractions in namespace)

Microsoft.Extensions.Configuration.Abstractions Contains classes with the namespace: Microsoft.Extensions.Configuration.X (no Abstractions in namespace)

Microsoft.Extensions.Logging.Abstractions Contains classes with the namespace: Microsoft.Extensions.Logging.Abstractions

Microsoft.Extensions.FileSystemGlobbing.Abstractions Contains classes with the namespace: Microsoft.Extensions.Logging.Abstractions

I think there are 8 namespaces that include the word Abstractions in them.

Is there a reason for this, and if not, is it correct to include the word Abstractions or not?

Also, if Abstractions should be included, where should the positioning of the word be, at the end of the namespace, or at the end of the project name, ie:

Microsoft.Extensions.Logging.AnotherProvider.Abstractions - or - Microsoft.Extensions.Logging.Abstractions.AnotherProvider

Can you provide some guidance on this please?

Expected Behavior

My personal view is that abstractions should have namespaces with either the word Abstractions in them or not.

I also think either an analyzer rule should be created to avoid this from happening or have some other way to protect against inconsistent namespace rules.

amcasey commented 1 month ago

@halter73 or @BrennanConroy may have some historical context.

PonchoPowers commented 1 month ago

Is it not caused by Visual Studio when you create a project, if you create a project with the name .Extensions in it then the namespaces will also have this in it, this would be my gut feeling, and if so then I guess it is incorrect and maybe somehow slipped into the production code. If this is the case then it would be good to have some sort of protection from this happening again, may an analyzer or something?