.NET 7 发布了第 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的实现