News

Microsoft Ships Last Preview of .NET 7 Before Release Candidate

Microsoft today (Aug. 9) shipped .NET 7 Preview 7, the final preview before it hits Release Candidate stage in advance of a Nov. 10 debut.

Preview 7 has been tested with Visual Studio 17.4 Preview 1, which also was released today along with the final VS 2022 v17.3 release.

.NET 7 will finally unify all the disparate .NET dev tooling components, enabling developers to build all types of apps -- desktop, mobile, web and more -- on the same Base Class Library (BCL), runtime and compilers. This was actually the goal of .NET 5 -- a successor to the .NET Core offerings -- when it debuted in November 2020. However, development problems exacerbated by the COVID-19 pandemic kept that from happening, so not all the planned bits made it into .NET 5 and were postponed until .NET 6 arrived in November 2021 as a Long Term Support (LTS) release. Even then, though, Microsoft's overarching unification effort was incomplete because some components, such as .NET Multi-platform App UI (.NET MAUI), slipped the schedule. .NET MAUI has since reached General Availability, so full unification is expected in November.

The .NET Schedule
[Click on image for larger view.] The .NET Schedule (source: Microsoft).

For Preview 7, the dev team focused on improving System.LINQ, Unix file permissions, low-level structs, p/Invoke source generation, code generation and websockets, said Jeremy Likness, senior program manager, in an Aug. 9 announcement post. All those specific items fall somewhere under general guidance provided in the Themes of .NET site.

Themes of .NET for v7 Milestone
[Click on image for larger view.] Themes of .NET for v7 Milestone (source: Microsoft).

Here are summaries of those improvements, with links to associated GitHub issues and pull requests for more information:

  • Simplified ordering with System.LINQ: System.Linq now sports new methods, Order and OrderDescending, which are used to order an IEnumerable according to T. This stems from dotnet/runtime#67194.
  • Support for Unix file modes: This uses a new enum and APIs to address the lack of built-in support for getting and setting Unix file permissions, used to control which users can read, write and execute files and directories. This stems from dotnet/runtime PR#69980.
  • Low-level struct improvements: ref field support: The .NET 7 runtimes now fully support ref fields within ByRefLike types: ref and struct. "There was extensive language design behind this much requested feature that users can read about: low-level struct improvements," Likness said. "With this feature, types previously requiring specialized handling in the runtimes (for example, Span<T> and ReadOnlySpan<T>), can now be fully implemented in C#."
  • LibraryImport P/Invoke source generator: Likness said this reflects the culmination of more than 18 months of work on the LibraryImport source generator, intended to be a drop-in replacement for most DllImport uses in both the runtime product and in user code. LibraryImport has been rolled out to all .NET libraries, which have been shipping with source generated marshalling code since .NET 7 Preview 1. "The source generator ships with the .NET 7 TFM and is readily available for consumption," Likness said. "In order to get the benefit of the source generated marshalling, replace usages of DllImport with LibraryImport. There are Analyzers and Fixers that can assist with this process." This stems from dotnet/runtime#60595.
  • ClientWebSocket upgrade response details: ClientWebSocket now provides details about upgrade responses, specifically information about response headers and status codes, which can be valuable in both failure and success scenarios. The latter can help developers distinguish between retriable and non-retriable errors when failures occur, while headers might also contain additional information on how to handle such situations and also prove helpful even in successful web socket connections, in that they can contain a token tied to a session, some info related to the subprotocol version and other information. This stems from dotnet/runtime#25918.

Likness also listed several improvements to CodeGen and loop optimizations, along with some breaking changes in the preview.

About the Author

David Ramel is an editor and writer for Converge360.

comments powered by Disqus

Featured

Subscribe on YouTube