.Net8 RC1发布了,更新了哪些

1.前言
.Net8 RC1经历多个预览版的迭代,于2023年9月12日发布了。按照官方的介绍,它是两个候选版本中的一个。这其实也预示着离真正的.Net8 LTS版不远了?本篇看下部分功能

2.概述
一:System.Text.Json改进
System.Net.Http.JsonIAsyncEnumerable的扩展
RC1包含 IAsyncEnumerable 流式反序列化扩展方法

const string RequestUri = "https://api.contoso.com/books";
using var client = new HttpClient();
IAsyncEnumerable<Book> books = await client.GetFromJsonAsAsyncEnumerable<Book>(RequestUri);
await foreach (Book book in books)
{
    Console.WriteLine($"Read book '{book.title}'");
}
public record Book(int id, string title, string author, int publishedYear);

二:AndroidStripILAfterAOT安卓模式

一般来说程序的目的主要是兼容预编译AOT的体积大小和速度快慢,如果你不是关系程序大小而是性能,那么你就可以使用它。
为 Android 应用设置以下 MsBuild 属性:

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
  <AndroidStripILAfterAOT>true</AndroidStripILAfterAOT>
</PropertyGroup>

默认情况下设置为true将覆盖默认设置,从而允许删除所有可修剪的AOT方法。通过显式设置以下两个选项,可以同时使用分析的AOT和IL剥离:

AndroidStripILAfterAOTAndroidEnableProfiledAot

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
  <AndroidStripILAfterAOT>true</AndroidStripILAfterAOT>
  <AndroidEnableProfiledAot>true</AndroidEnableProfiledAot>
</PropertyGroup>

三:WasmStripILAfterAOTWASM模式

Blazor WebAssembly和WASM浏览器支持提前AOT编译,你可以在其中将 .NET 代码直接编译到WebAssembly中。AOT编译可提高运行时性能,但代价是应用大小更大。这种新的剥离模式根据我们在上述 github 问题中提到的测试,将_framework文件夹的大小减少了 1.7% – 4.2%。

何时考虑使用 :WasmStripILAfterAOT
此功能非常适合启用 AOT 编译的任何时候,因此请尝试较小的应用程序!

如何使用:WasmStripILAfterAOT
为 Blazor WebAssembly 或WASM浏览器应用设置以下MsBuild属性:

<PropertyGroup>
  <RunAOTCompilation>true</RunAOTCompilation>
  <WasmStripILAfterAOT>true</WasmStripILAfterAOT>
</PropertyGroup>

它将修剪大多数已编译方法的IL代码,包括库中的方法和应用开发人员编写的方法。

更多可以了解微软官方链接:

https://devblogs.microsoft.com/dotnet/announcing-dotnet-8-rc1/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值