Global Usings in C# 10 allow us to declare a namespace as being available to all files in a project so we don’t need a using statement for it in each file which needs it. Ideally we’d put these global usings in a separate file. This will reduce so called ‘vertical waste’ which is nice.
BUT… fewer lines of code doesn’t necessarily mean the code is easier to understand, so I’m not sure I’d recommend making all your usings global. Doing this will remove some per file contextual info.
I like Romans example from twitter below 👇🏻 …
We can see above that he removes common namespaces such as System and System.Linq to a separate file but keeps System.Net.WebSockets. This means a developer who has not originally worked on this file can see straight away there is some web socket stuff going on. This is a good balance I think.
What do you do think? Do you like Global Usings? Will you use them in your apps?