|C# 8.X Plans Revealed|
|Written by Kay Ewbank|
|Thursday, 04 July 2019|
We may still be waiting for the final release of C# 8.0, but the developers are already discussing what will form the basis of C# 8.X. The list reveals some details of what will miss the cut-off for C# 8.0.
The plans for C# 8.X have appeared on GitHub as a milestone, somewhat worryingly (and probably to prevent speculation on a release date) with a due date January 01, 2089.
Once C# 8.0 is released and out of the way, one headline inclusion in C# 8.X will be data records. This was supposed to be a C# 8.0 feature, but proved too complex to make the cut. The new plans don't even say whether it will be in C# 8.1 or a later release. Records are intended to make it simpler to create Data Transfer Object (DTO) classes, especially those that only consist of read-only properties and fields. The records syntax will create the code to create DTO classes.
Another item planned for these future releases is a Caller Expression Attribute. This will mean developers can capture the expressions passed to a method, and the idea is that it will enable better error messages in diagnostic testing APIs, and reduce keystrokes in automated testing.
Target-Typed 'new' expressions are another main improvement. The idea is that such expressions avoid the need to have type specification for constructors when the type is known. The motivation for this is to allow field initialization without duplicating the type.
The Null-Enhanced Common Type is another change that the milestone suggests will be added to 8.X.The thinking is that in some circumstances, the current common-type algorithm results are counter-intuitive, so programmers have to add what feels like a redundant cast to the code.
The planned change would provide a way of avoiding the need to have explicit casts if your value types and ternary operators are nullable.
For example, an expression such as
The full list of proposed improvements can be seen on the milestone plan on GitHub.
or email your comment to: firstname.lastname@example.org