Minor changes in .NET 9.0 Release Candidate 1

0
33
Minor changes in .NET 9.0 Release Candidate 1


After seven preview versions, Microsoft has released .NET 9.0 Release Candidate 1. .NET has mastered compression for years with zlib and brotli. With .NET 9.0, Microsoft now has two classes ZLibCompressionOptions And BrotliCompressionOptions with which specific compression settings can be made. In class ZLibCompressionOptions There are properties CompressionStrategy (a calculation) and CompressionLevel (an integer from 0 to 9), where 0 means no compression. In the class BrotliCompressionOptions There is only one property Quality (integers from 0 to 11).

Advertisement


Listing 1 shows an application example that outputs the size of a compressed text with 100,000 characters for all ten zlib compression levels as well as all twelve quality levels for Brotli compression. Figure 1 shows the output of the listing.

 // Erzeuge einen Text mit 100000 zufälligen Zeichen
 string text = new string(Enumerable.Range(0, 100000).Select(i => (char)(65 + i % 26)).ToArray());
 Console.WriteLine("Originaltext: " + text.Length);
 
 for (int i = 0; i <= 9; i++)
 {
  // Kopiere den Text in einen MemoryStream
  var uncompressedStream = new MemoryStream(Encoding.UTF8.GetBytes(text));
  var compressedStream = new MemoryStream();
  using var zipStream = new ZLibStream(compressedStream, new ZLibCompressionOptions() { CompressionLevel = i, CompressionStrategy = ZLibCompressionStrategy.Default });
  uncompressedStream.CopyTo(zipStream);
  zipStream.Flush();
 
  Console.WriteLine($"Länge bei ZLib-Komprimierungslevel #{i}: " + compressedStream.Length);
 }
 
 for (int i = 0; i <= 11; i++)
 {
  // Kopiere den Text in einen MemoryStream
  var uncompressedStream = new MemoryStream(Encoding.UTF8.GetBytes(text));
  var compressedStream = new MemoryStream();
  using var brotliStream = new BrotliStream(compressedStream, new BrotliCompressionOptions() { Quality = i });
  uncompressedStream.CopyTo(brotliStream);
  brotliStream.Flush();
 
  Console.WriteLine($"Länge bei Brotli-Komprimierungslevel #{i}: " + compressedStream.Length);
 }

Listing 1: Use of ZLibCompressionOptions and brotliCompressionOptions



Output of Listing 1 (Figure 1).

Output of Listing 1 (Figure 1).

(Image: Dr. Holger Schwittenberg)

in class TarEntry .NET 9.0 now offers new feature DataOffsetwhich allows developers to read the position of the first byte of an entry in a TAR archive stream. According to Microsoft, this can be useful for parallel access to large TAR files.

Provides MAUI 9.0 controls in .NET Microsoft.Maui.Controls.Label Now next to Align Left (HorizontalTextAlignment="Start"), right-aligned (HorizontalTextAlignment="End") and centered (HorizontalTextAlignment="Center") ultimately also justification (HorizontalTextAlignment="Justify"), see Listing 2 and Figure 2.

Bank scam | If you have a savings account, be very careful: The scam called ‘from your bank’Bank scam | If you have a savings account, be very careful: The scam called ‘from your bank’

Listing 2: Justification using Microsoft.Maui.Controls.Label


Text formatting options in the Label control in .NET MAUI 9.0 (Figure 2).

Text formatting options in the Label control in .NET MAUI 9.0 (Figure 2).

Text formatting options in the Label control in .NET MAUI 9.0 (Figure 2).

(Image: Dr. Holger Schwittenberg)

In Blazor, developers can now take control HTML Attribute type For example, put

ohne type
type="range"
type="text"

In .NET 8.0, Microsoft introduced dependency injection keys that developers can use to register multiple instances of a class in the dependency injection container with different keys. In ASP.NET Core 9.0, middleware classes can now also contain services encoded in constructors and methods Invoke() And InvokeAsync() consume.

It was already possible to use the property with a WebSockets connection KeepAliveInterval Specify (in both client and server) how often a ping message should be sent to the other side. But so far there is no result if the other side does not respond. Now you can do it through KeepAliveTimeout Force the connection to end if the other party does not respond within a certain time. For example, you configure a short message to the server every ten seconds and terminate the connection if the server does not respond within two seconds:

app.UseWebSockets(
    new WebSocketOptions { 
        KeepAliveInterval = TimeSpan.FromSeconds(10), 
        KeepAliveTimeout = TimeSpan.FromSeconds(2)
        });

Views the configuration of the client property KeepAliveTimeout Like this:

var httpClient = new HttpClient();
var uri = new Uri("wss://server:1234/ws"); // wss: für SSL!
var cancellationToken = new CancellationTokenSource().Token;
using var client = new ClientWebSocket();
client.Options.HttpVersionPolicy = HttpVersionPolicy.RequestVersionOrHigher;
client.Options.KeepAliveInterval = TimeSpan.FromSeconds(15);
client.Options.KeepAliveTimeout = TimeSpan.FromSeconds(1); // neu in .NET 9
await client.ConnectAsync(uri, httpClient, cancellationToken);
CUI.Yellow("Verbunden mit WebSockets Server");

Already familiar .NET SDK command line commands

dotnet dev-certs https --trust

With which developers can trust the development certificate generated by ASP.NET Core, it now works not only on Windows and macOS as before, but also on Ubuntu and Fedora Linux with Chrome and Firefox.

New .NET SDK commands

dotnet workload history

Shows the timing of changes to SDK workload installations on a development system.

As with the preview versions Preview 6 and Preview 7, there are no release notes from the Entity Framework Core development team. Also the documentation “What’s new in EF Core 9?“There are no changes as of June 11, 2024. However, you can find 45 closed issues in the milestone on GitHub”9.0.0-rc1“, including the following points:

  • Near UseSqlServer() can be done by method OnConfiguring() now in the reference class UseAzureSql() Or UseAzureSynapse() To connect to the cloud variant of SQL Server. Microsoft wants special features of the cloud variant like It has its own data type JSON can be exploited. However, this has not been documentedWhat features does the cloud variant that Microsoft specifically uses have. However, a quick test revealed missing features: UseNetTopologySuite() And UseHierarchyId() Do not compile with UseAzureSql(),
  • After lengthy discussions, Microsoft has adopted the compatibility level for Microsoft SQL Server adopted by Entity Framework Core 9.0 into the standard reduced to 150which corresponds to Microsoft SQL Server 2019. In Entity Framework Core 8.0 this level was 160 (SQL Server 2022). Developers must specify the compatibility level explicitly UseCompatibilityLevel() If you work with SQL Server versions other than Standard.
  • Since Entity Framework Core 8.0, Microsoft has supported a set of primitive types (for example) int(), List), but not, for example, mapping nested sets int()(). This remains the case in Entity Framework Core 9.0, but the error message is now more specific: “int()() is a primitive collection of a primitive collection. Nested primitive collections are not yet supported with relational database providers.” Previously it was more generally stated: “Is not a supported primitive type or a valid entity type”.

.NET 9.0 Release Candidate 1 is installed as part of Visual Studio 2022 version 17.12 Preview 2 or independently Using the setup package from the website. There are some new entries In the list of breaking changes In .NET 9.0 vs .NET 8.0.

Microsoft has officially announced the release date of .NET 9.0 as November 12, 2024. Until then, Release Candidate 2 will be available in October. Heise, iX and dpunkt.verlag are presenting the stable version in an online event together with www.IT-Visions.de BetterCode() .NET 9.0 A week later, on November 19, 2024.


(May)

Security patch: Gitlab fixes vulnerabilities in server versionsSecurity patch: Gitlab fixes vulnerabilities in server versions

LEAVE A REPLY

Please enter your comment!
Please enter your name here