Open LPeter1997 opened 2 years ago
Switch expression: After the dreadful switch statement, the switch expression is a breath of fresh air.
The switch expression. It's horrible. I usually avoid it at all cost.
🦆
Switch expression: After the dreadful switch statement, the switch expression is a breath of fresh air.
The switch expression. It's horrible. I usually avoid it at all cost.
🦆
Yep, updated, meant switch-statement as the horrible construct :^)
Hate in C#
Attributes syntax. @Attribute(parameter)
feel so much nicer.
As an initial step, I thought a love/hate/wish list of C# would not be too bad. Plenty of subjectivity here, but oh well. Love/hate should not be taken too seriously, it could be called like/dislike, even nitpicks went into the hate category.
Love in C
Hate in C
records
) that add equality, hash and print. Why not add the placement-syntax to classes and allow classes to auto-implement the equality and hash? Both derive constructs and tag types exist for this and I can't believe it would have been too much work for the compiler. The newrecord struct
s will make this even worse.readonly struct
but noreadonly class
. These modifiers seem to fly all around randomly, applicable to some things, while not to others, also making it very inconsistent.sealed
andclosed
will enforce the same thing but on different scopes, making the feature redundant.OneOf
for an arbitrary amount of types is kind of doomed.partial
all around. There is also no plan to remove this constraint, because they pose a security concern in the way they were implemented.Equals
/GetHashCode
it's painful and there's crud that needs to be done but the compiler won't do it for you (like overridingbool object.Equals(object? other)
). Admittedly, this is not something that has to be done but I've never written code where it is not desired, hence this is likely a holdback for a 0.1% case or something.IComparable
and I want to also haveIEquatable
(which is common), again there is boilerplate. Again, this is not desired for partial ordering, but most cases are not partial ordering.new
keyword feels like it was just brought in because Java had it. Why not just type out the constructor name?var
andnew()
for inference. Imagine only having to typenew Dictionary<_, _>()
(or something even shorter) there.Miss from C
T1+T2
, andT2+T1
would be automatically implemented, and there would be no way to override that. (just an example, not necessary in this exact case)