Skip to content

[Breaking change]: IndexOfAnyValues has been renamed to SearchValues #35244

Closed
@MihaZupan

Description

@MihaZupan

Description

.NET 8 preview 1 introduced a new IndexOfAnyValues<T> type used to speed up IndexOfAny-like operations.
With .NET 8 preview 5, the type has been renamed to SearchValues<T>.

Version

.NET 8 Preview 5

Previous behavior

The affected types were named IndexOfAnyValues, IndexOfAnyValues<T>.

New behavior

The types were renamed to SearchValues, SearchValues<T>.

Type of breaking change

  • Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
  • Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code may require source changes to compile successfully.
  • Behavioral change: Existing binaries may behave differently at run time.

Reason for change

See dotnet/runtime#82622

We introduced System.Buffers.IndexOfAnyValues in .NET 8 as a way to cache computation associated with preparing any number of values for being used in a search. We expected to only use it with IndexOfAny, and maybe subsequently in a Contains, which if you squint is an IndexOf operation where you only pay attention to whether the result is negative. However, we've since found places where we'd possibly benefit from exposing overloads of other operations that would take an IndexOfAnyValues, like Count, Replace, or Remove, and in those contexts, the IndexOfAnyValues name is... strange.

We have chosen to rename the type to SearchValues to allow us to extend its functionality in the future without making the name of the type misleading.

Recommended action

Users who have written code using IndexOfAnyValues in previous previews of .NET 8 should replace all usages with SearchValues.
This should be as simple as a text-based find-replace of IndexOfAnyValues with SearchValues.

Feature area

Core .NET libraries

Affected APIs

  • IndexOfAnyValues.Create is now SearchValues.Create
  • IndexOfAnyValues<T> is now SearchValues<T>
  • IndexOfAny extensions on Span<T> that accepted IndexOfAnyValues<T> arguments now accept SearchValues<T>

Associated WorkItem - 97025

Metadata

Metadata

Assignees

Labels

🏁 Release: .NET 8Work items for the .NET 8 release📌 seQUESTeredIdentifies that an issue has been imported into Quest.binary incompatibleExisting binaries may encounter a breaking change in behavior.breaking-changeIndicates a .NET Core breaking changesource incompatibleSource code may encounter a breaking change in behavior when targeting the new version.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions