Microsoft .NET 7 Preview 4 brings Regex improvements, cache metrics
Microsoft’s latest preview of .NET 7, the upcoming next version of its software development platform, features improvements for working with regular expressions and caching.
Downloadable from the Microsoft .NET website, the fourth preview of .NET 7 was released on May 10. The production version is scheduled for November.
Microsoft .NET Preview 4 adds the remaining scheduled APIs that add support for scoped types to the Regex (regular expressions) library. Changes add support for matching with
ReadOnlySpan inputs and review the processing of
RegexOptions.IgnoreCase. New duration-based APIs include:
Regex.IsMatch(ReadOnlySpanwhich indicates whether the regular expression finds a match in the input range.
Regex.Count(ReadOnlySpanwhich searches an input string for all occurrences of a regular expression and returns the number of matches.
Regex.EnumerateMatches(ReadOnlySpanwhich searches an input scope for occurrences of a regular expression and returns a
ValueMatchEnumeratorto lazily iterate over matches.
In other Regex improvements, Microsoft said it worked to make code generated by the Regex source generator more readable and easier to debug, and to allow projects with multiple source-generated regular expression patterns to share of the common code.
Preview 4 also introduces metrics support for
IMemoryCache. The main APIs added are
MemoryCacheStatisticswhich contains cache hits and misses, estimated size and count for
GetCurrentStatisticswhich returns an instance of
MemoryCacheStatisticsor null when the
TrackStatistics the indicator is not activated.
Also in Preview 4, Microsoft has finished annotating the
Microsoft.Extensions.* libraries for nullability, introduced a
Activity.Current edit the event to improve OpenTelemetry support for observability, and add the
System.Formats.Tar assembly, which contains cross-platform APIs for reading, archiving, writing, and extracting Tar archives.
Microsoft .NET 7 Preview 1 was released on February 17, followed by .NET 7 Preview 2 and .NET 7 Preview 3 on March 14 and April 13, respectively.
Copyright © 2022 IDG Communications, Inc.