Menu
Microsoft .NET 7 Preview 4 brings Regex improvements, cache metrics

Microsoft .NET 7 Preview 4 brings Regex improvements, cache metrics

Fourth preview of the forthcoming .NET upgrade adds span support to the Regex library and hit and miss stats for IMemoryCache.

Credit: Dreamstime

Microsoft’s latest preview of .NET 7, the forthcoming next version of its software development platform, features enhancements for working with regular expressions and caching.

Downloadable from the Microsoft .NET website, the fourth preview of .NET 7 was published May 10. The production release is due in November.

Microsoft .NET Preview 4 adds remaining planned APIs that add support for span types to the Regex (regular expressions) library. The changes add support for matching with ReadOnlySpan<char> inputs and overhaul the handling of RegexOptions.IgnoreCase

The new span-based APIs include:

  • Regex.IsMatch(ReadOnlySpan<char> input), which indicates whether the regular expression finds a match in the input span.
  • Regex.Count(ReadOnlySpan<char> input), which searches an input string for all occurrences of a regular expression and returns the number of matches.
  • Regex.EnumerateMatches(ReadOnlySpan<char> input), which searches an input span for occurrences of a regular expression and returns a ValueMatchEnumerator to lazily iterate over the matches.

In other Regex improvements, Microsoft said it has worked to make the code generated by the Regex source generator more readable and easier to debug, and to enable projects with multiple source-generated regular expression patterns to share common code.

Preview 4 also introduces metrics support for IMemoryCache. The main APIs being added are MemoryCacheStatistics, which holds cache hit, miss, estimated size, and count for IMemoryCache, and GetCurrentStatistics, which returns an instance of MemoryCacheStatistics, or null when the TrackStatistics flag is not enabled.

Also in Preview 4, Microsoft has finished annotating the Microsoft.Extensions.* libraries for nullability, introduced an Activity.Current change event to enhance OpenTelemetry support for observability, and added 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 February 17, followed by .NET 7 Preview 2 and .NET 7 Preview 3 on March 14 and April 13, respectively.


Follow Us

Join the newsletter!

Or

Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.

Tags Microsoft

Events

SustainTech

Join key decision-makers within Environmental, Social, and Governance (ESG) that have the power to affect real change and drive sustainable practices. SustainTech will bridge the gap between ambition and tangible action, promoting strategies that attendees can use in their day-to-day operations within their business.

EDGE 2023

EDGE is the leading technology conference for business leaders in Australia and New Zealand, built on the foundations of collaboration, education and advancement.

WIICTA 2023

ARN has celebrated gender diversity and recognised female excellence across the Australian tech channel since first launching WIICTA in 2012, acknowledging the achievements of a talented group of female front runners who have become influential figures across the local industry.

ARN Innovation Awards 2023

Innovation Awards is the market-leading awards program for celebrating ecosystem innovation and excellence across the technology sector in Australia.

Show Comments