https://learn.microsoft.com/en-us/dotnet/csharp/language-ref...
What's new in C# 12: overview
41–50 of 100 posts
Re: What's new in C# 12: overview
#42Code interception strikes me as just crude and poorly conceived? Given how hard it is to remove features from a language, why introduce things like this? 20 years from now people will have to deal with codebases that use InterceptsLocation decorators and for what? I get why InterceptsLocation can be useful, but why not make a more generic version that doesn't work with magic line and character offsets? Something as i…
So as it's intended for being used inside the compilation process, i don't think this is too valid of a concern.
Re: What's new in C# 12: overview
#43>finally, we can stop creating an interface for every class just to mock it in tests Is there more information available about this? Would be great to achieve this natively without requiring Fody and friends.
I've HATED it when people do this, but everyone is convinced it's best practice.
At work, I have better things to do than waste time on this for PR, so I create those interfaces, thankfully there are VS tools to create them automatically.
Re: What's new in C# 12: overview
#44Not sure if I like primary constructors. TBH, the following feature of Dart that I like: class Point { public Point(this x, this y); int x; int y } Everything else seems like small quality of life improvements. And still patiently waiting for the following to be legal: int result = some_variable switch { a => callAFunctionReturningVoid(); 1, b => 2, };
> int result = some_variable switch { a => callAFunctionReturningVoid(); 1, b => 2, }; What does it even mean? Multi-statement lambdas without return statement, I get it, but what is the return value? And returning a void to int? How is it all supposed to work? What the trailing comma means? Inconsistent way of dealing with things that may confuse developers just results in that proposal resisted.
Re: What's new in C# 12: overview
#45Just a reminder that in the C# world you don't really have to care about new language features. Visual Studio, ReSharper, and Rider (supports MacOS/Linux) will suggest useful new language features as a one-shortcut refactoring. A C# developers who went into coma in 2012 after learning about async/await and ASP.NET MVC can be awakened today and be instantly productive. Although he might go into coma again if he finds…
Re: What's new in C# 12: overview
#46>finally, we can stop creating an interface for every class just to mock it in tests Is there more information available about this? Would be great to achieve this natively without requiring Fody and friends.
Re: What's new in C# 12: overview
#47Code interception strikes me as just crude and poorly conceived? Given how hard it is to remove features from a language, why introduce things like this? 20 years from now people will have to deal with codebases that use InterceptsLocation decorators and for what? I get why InterceptsLocation can be useful, but why not make a more generic version that doesn't work with magic line and character offsets? Something as i…
Well, this features is designed to be used by source generators and not humans. So as it's intended for being used inside the compilation process, i don't think this is too valid of a concern.
Re: What's new in C# 12: overview
#48Code interception strikes me as just crude and poorly conceived? Given how hard it is to remove features from a language, why introduce things like this? 20 years from now people will have to deal with codebases that use InterceptsLocation decorators and for what? I get why InterceptsLocation can be useful, but why not make a more generic version that doesn't work with magic line and character offsets? Something as i…
Well, this features is designed to be used by source generators and not humans. So as it's intended for being used inside the compilation process, i don't think this is too valid of a concern.
Re: What's new in C# 12: overview
#49Re: What's new in C# 12: overview
#50>finally, we can stop creating an interface for every class just to mock it in tests Is there more information available about this? Would be great to achieve this natively without requiring Fody and friends.
It's more for DI than tests, really, right? Still, I have very rarely found it practical.
The reason this is so common is probably because code examples (including MS) often have it, so it gets followed the first time and repeated.