Earlier quoted context omitted.
It's more for DI than tests, really, right? Still, I have very rarely found it practical.
They're not required for MS's dependency injection, not sure about other libraries. 95% of the interfaces I've ever seen used for DI only have one implementation, and that 5% is generous. This makes maintaining the class and the interface tedious. 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.
What's new in C# 12: overview
51–60 of 100 posts
Re: What's new in C# 12: overview
#52Re: What's new in C# 12: overview
#53Not 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, };
Re: What's new in C# 12: overview
#54I love that Java and C# (not sure about VB.NET and F# in the .NET ecosystem) are continuing to get handy language features instead of collecting dust. The array syntax stuff is a nice win. Having other languages be the guinea pigs for language features is a good way to go.
The only feature I've been hoping for is abstract data types. I'm not sure how they could make them work in .Net though. Presumably F# has crossed that hurdle.
Re: What's new in C# 12: overview
#55Why would we need to make a struct with an attribute and a weird member?
Re: What's new in C# 12: overview
#56Earlier quoted context omitted.
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.
Source code generators are used because the language itself is not expressive enough. Maybe fix that instead.
Re: What's new in C# 12: overview
#57Earlier quoted context omitted.
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.
Source code generators are used because the language itself is not expressive enough. Maybe fix that instead.
Re: What's new in C# 12: overview
#58Earlier quoted context omitted.
Source code generators are used because the language itself is not expressive enough. Maybe fix that instead.
So how would you solve the AOT (ahead of time compiling) problem without code generation? An entire ecosystem (Unity) that uses C# requires that code must be AOT for supporting IL2CPP (a low level translation of IL to c++). Dynamics and Reflection of non-AOT types are unavailable at runtime. IL2CPP came from Apples requirement that no JIT be run in apps and to get more performance; especially, for features like burst…
System.Xml.Serialization, for example, relies on generating assemblies at runtime to work. That's "code generation", but of a kind that directly conflicts with the AOT meaning of "code generation".
Re: What's new in C# 12: overview
#59Earlier quoted context omitted.
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.
Source code generators are used because the language itself is not expressive enough. Maybe fix that instead.
Source generation is used at some level to implement expressivity at minimal runtime cost. It's just operating at a different level of abstraction to make different tradeoffs.
Whether you do Foo.Serialize() and it uses reflection to enumerate the properties, carries around tags permanently or it uses some compiletime generated function has nothing much to do with expressiveness.
If you design around a Foo does it matter if behind the scenes it generates a FooOfBar?
Should a language inherently care specifically about protobufs, flatbuffers, capnproto, etc because expressiveness or should it just have capable source generators for building strongly typed interfaces without the legwork? Are you sure an alternative implementation which is more expressive would be better or would it just be different?