.NET 7 Preview 4 发布

346阅读模式

.NET 7 发布了第 4 个预览版。

.NET 7 Preview 4 发布

文章源自懂站帝-http://www.sfdkj.com/12922.html

重要变化一览文章源自懂站帝-http://www.sfdkj.com/12922.html

  • 增强 OpenTelemetry 的 .NET 实现的可观测性
  • 为日期和时间结构体增加微秒和纳秒属性
  • 为缓存扩展 (caching extensions) 引入新指标
  • 提升 “On Stack Replacement” 性能
  • 增加新的 tar API
  • 优化 .NET 7 中正则表达式的性能、增加功能

为 TimeStamp、DateTime、DateTimeOffset 和 TimeOnly 添加微秒和纳秒属性文章源自懂站帝-http://www.sfdkj.com/12922.html

在 Preview 4 之前,各种日期和时间结构体中,可用的最小时间增量是 Ticks 属性中可用的 “tick”。在 .NET 中,一个 tick 是 100ns。此前开发者必须对 "tick" 值执行计算以确定微秒和纳秒值。现在,Preview 4 通过在日期和时间实现中引入微秒和毫秒来解决这个问题。文章源自懂站帝-http://www.sfdkj.com/12922.html

增加新的 tar API文章源自懂站帝-http://www.sfdkj.com/12922.html

此版本添加了新的程序集,包含可读取、写入、归档和提取 tar 存档的跨平台 API。文章源自懂站帝-http://www.sfdkj.com/12922.html

使用示例文章源自懂站帝-http://www.sfdkj.com/12922.html

// Generates a tar archive where all the entry names are prefixed by the root directory 'SourceDirectory'
TarFile.CreateFromDirectory(sourceDirectoryName: "/home/dotnet/SourceDirectory/", destinationFileName: "/home/dotnet/destination.tar", includeBaseDirectory: true);

// Extracts the contents of a tar archive into the specified directory, but avoids overwriting anything found inside
TarFile.ExtractToDirectory(sourceFileName: "/home/dotnet/destination.tar", destinationDirectoryName: "/home/dotnet/DestinationDirectory/", overwriteFiles: false);
// Generates a tar archive where all the entry names are prefixed by the root directory 'SourceDirectory'
using MemoryStream archiveStream = new();
TarFile.CreateFromDirectory(sourceDirectoryName: @"D:SourceDirectory", destination: archiveStream, includeBaseDirectory: true);

// Extracts the contents of a stream tar archive into the specified directory, and avoids overwriting anything found inside
TarFile.ExtractToDirectory(source: archiveStream, destinationDirectoryName: @"D:DestinationDirectory", overwriteFiles: false);

为缓存扩展 (caching extensions) 引入新指标文章源自懂站帝-http://www.sfdkj.com/12922.html

此版本为IMemoryCache添加了指标支持,主要的 API 包括:文章源自懂站帝-http://www.sfdkj.com/12922.html

  • MemoryCacheStatistics 用于记录命中 / 未命中 / 估算缓存大小的数据,以及针对IMemoryCache的计数
  • GetCurrentStatistics:返回MemoryCacheStatistics实例,当TrackStatistics flag 未启用则返回 null。该库内置了可用于MemoryCache的实现
文章源自懂站帝-http://www.sfdkj.com/12922.html文章源自懂站帝-http://www.sfdkj.com/12922.html
懂站帝
  • 本文由 发表于 2022年5月14日 12:22:07
  • 版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至395045033@qq.com举报,一经查实,本站将立刻删除。
评论  0  访客  0