News for hackers. Stuff that matters.
Re:Welcome to C# 10 by Someone1234 on Monday November 08, 2021 @03:27PM (#29153819)
Looks like they added global usings to support their implicit usings functionality. Essentially they want to save people having to put using System, System.Linq, System.Collections.Generic, and others[0] at the top of nearly every C# file.

I'm of two minds:

- I think they're an anti-pattern, because it creates a global scope that can get messy/annoying.

- It makes a ton of sense for the implicit usings functionality, and I'm tired of needing to add the basic SDK usings to every source file.

So the ideal is to enable .Net's implicit usings, then to use an analyzer to "ban" adding more global usings directly from your solution/project. Best of both worlds that way. Alternatively just make them a no-pass item for code reviews.

[0] https://docs.microsoft.com/en-us/dotnet/core/compatibility/s...

Re:Welcome to C# 10 by metaltyphoon on Monday November 08, 2021 @04:06PM (#29154282)
It's literally the same as Rust's prelude system and I don't see anyone complaining so much about this.
Re:Welcome to C# 10 by t-writescode on Monday November 08, 2021 @09:40PM (#29157078)
Rust doesn't have anywhere near the following of C#, so there probably aren't enough opinionated people in the community to mention it on an HN post
Re:Welcome to C# 10 by AlfeG on Monday November 08, 2021 @04:09PM (#29154318)
> Essentially they want to save people having to put using System, System.Linq, System.Collections.Generic, and others[0] at the top of nearly every C# file.

Interesting that this doesn't bother me at starting from .net 1.0. All tools (including raw VS without addins) can add those using automatically and they do.

But for me it's still a nice to have feature if VS will be able to show where this using is defined.

Re:Welcome to C# 10 by sbelskie on Monday November 08, 2021 @03:44PM (#29153979)
This is what I’ve settled on. Implicit usings for the SDK are great but otherwise I don’t want this in any code base I work on.