.NET 9, the successor to.NET 8, focuses on cloud-native apps and performance enhancements. It will get standard-term support (STS) for 18 months.
Serialization
In System.Text.Json, .NET 9 has new options for serializing JSON and a new singleton, making it easier to serialize using web defaults.
-
Indentation options
string webJson = JsonSerializer.Serialize(
new { SomeValue = 42 },
JsonSerializerOptions.Web // Defaults to camelCase naming policy.
);
Console.WriteLine(webJson);
// {"someValue":42}
If you want to serialize with the default options that ASP.NET Core uses for web apps, use the new JsonSerializeOptions.Web singleton.Recently added to the toolkit are the CountBy and AggregateBy methods. These functions enable state aggregation by key, eliminating the necessity for intermediate groupings through GroupBy.
CountBy allows for swift computation of the frequency of each key. In the following example, it identifies the word that appears most frequently within a given text string.
AggregateBy provides the capability to execute broader, more versatile workflows. Illustrated in the following example is the calculation of scores associated with a specified key.
In the realm of cryptography, .NET 9 introduces a new one-shot hash method within the CryptographicOperations type. .NET offers various static "one-shot" implementations of hash functions and related functions, such as SHA256.HashData and HMACSHA256.HashData. Utilizing one-shot APIs is preferred due to their potential to optimize performance and minimize or eliminate allocations.
When a developer aims to create an API supporting hashing with the caller defining the hash algorithm, it typically involves accepting a HashAlgorithmName argument. However, employing this pattern with one-shot APIs necessitates switching over every potential HashAlgorithmName and subsequently utilizing the appropriate method. To address this issue, .NET 9 introduces the CryptographicOperations.HashData API. This API enables the generation of a hash or HMAC over an input as a one-shot operation, with the algorithm determined by a HashAlgorithmName.
Conclusion
.NET 9 includes major enhancements designed specifically for cloud-native apps and performance optimization. With an emphasis on serialization, LINQ enhancements, and cryptographic breakthroughs, developers may use new features and APIs to streamline development processes and improve application security. Notable features include improved JSON serialization choices, powerful LINQ methods such as CountBy and AggregateBy, and simple CryptographicOperations.HashData API enables efficient hashing operations. As.NET 9 evolves, it promises to provide developers with powerful tools and capabilities to create modern, high-performance applications for a wide range of use cases.
Best ASP.NET Core 8.0.1 Hosting Recommendation
At HostForLIFE.eu, customers can also experience fast ASP.NET Core hosting. The company invested a lot of money to ensure the best and fastest performance of the datacenters, servers, network and other facilities. Its datacenters are equipped with the top equipments like cooling system, fire detection, high speed Internet connection, and so on. That is why HostForLIFEASP.NET guarantees 99.9% uptime for ASP.NET Core. And the engineers do regular maintenance and monitoring works to assure its Orchard hosting are security and always up.
0 comments:
Post a Comment