Skip to content

IndexOfAnyValues type name change #35657

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/core/compatibility/8.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Breaking changes in .NET 8
titleSuffix: ""
description: Navigate to the breaking changes in .NET 8.
ms.date: 05/05/2023
ms.date: 06/05/2023
no-loc: [Blazor, Razor, Kestrel]
---
# Breaking changes in .NET 8
Expand Down Expand Up @@ -35,6 +35,7 @@ If you're migrating an app to .NET 8, the breaking changes listed here might aff
| [FileStream writes when pipe is closed](core-libraries/8.0/filestream-disposed-pipe.md) | Behavioral change | Preview 1 |
| [GC.GetGeneration might return Int32.MaxValue](core-libraries/8.0/getgeneration-return-value.md) | Behavioral change | Preview 4 |
| [GetFolderPath behavior on Unix](core-libraries/8.0/getfolderpath-unix.md) | Behavioral change | Preview 1 |
| [IndexOfAnyValues renamed to SearchValues](core-libraries/8.0/indexofanyvalues-renamed.md) | Source/binary incompatible | Preview 5 |
| [ITypeDescriptorContext nullable annotations](core-libraries/8.0/itypedescriptorcontext-props.md) | Source incompatible | Preview 1 |
| [Legacy Console.ReadKey removed](core-libraries/8.0/console-readkey-legacy.md) | Behavioral change | Preview 1 |

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
title: ".NET 8 breaking change: IndexOfAnyValues renamed to SearchValues"
description: Learn about the .NET 8 breaking change in core .NET libraries where the IndexOfAnyValues type was renamed to SearchValues.
ms.date: 06/05/2023
---
# IndexOfAnyValues renamed to SearchValues

.NET 8 Preview 1 introduced a new `System.Buffers.IndexOfAnyValues<T>` type to speed up `IndexOfAny`-like operations. In .NET 8 Preview 5, the type has been renamed to <xref:System.Buffers.SearchValues%601>.

## Previous behavior

In previous preview versions of .NET 8, the affected types were named `IndexOfAnyValues` and `System.Buffers.IndexOfAnyValues<T>`.

## New behavior

`IndexOfAnyValues` and `System.Buffers.IndexOfAnyValues<T>` are now named <xref:System.Buffers.SearchValues> and <xref:System.Buffers.SearchValues%601>.

## Version introduced

.NET 8 Preview 5

## Type of breaking change

This change can affect [source compatibility](../../categories.md#source-compatibility) and [binary compatibility](../../categories.md#binary-compatibility).

## Reason for change

The type was renamed to `SearchValues` to allow us to extend its functionality in the future without making the name of the type misleading. `IndexOfAnyValues` was introduced in a previous preview version of .NET 8 as a way to cache computation associated with preparing any number of values for use in a search. We expected to only use it with `IndexOfAny` and possibly `Contains`. However, there are other places that could benefit from exposing overloads of other operations that would take an `IndexOfAnyValues`, like `Count`, `Replace`, or `Remove`, and in those contexts, the `IndexOfAnyValues` name doesn't make sense.

## Recommended action

If you've written code using `IndexOfAnyValues` in a previous preview version of .NET 8, replace all usages with `SearchValues`.
This should be as simple as a text-based find-and-replace of "IndexOfAnyValues" with "SearchValues".

## Affected APIs

- `System.Buffers.IndexOfAnyValues<T>`
- `System.Buffers.IndexOfAnyValues.Create()`
- `System.MemoryExtensions.IndexOfAny<T>(ReadOnlySpan<T>, IndexOfAnyValues<T>)`
- `System.MemoryExtensions.IndexOfAny<T>(Span<T>, IndexOfAnyValues<T>)`
- `System.MemoryExtensions.IndexOfAnyExcept<T>(ReadOnlySpan<T>, IndexOfAnyValues<T>)`
- `System.MemoryExtensions.IndexOfAnyExcept<T>(Span<T>, IndexOfAnyValues<T>)`
4 changes: 4 additions & 0 deletions docs/core/compatibility/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ items:
href: core-libraries/8.0/getgeneration-return-value.md
- name: GetFolderPath behavior on Unix
href: core-libraries/8.0/getfolderpath-unix.md
- name: IndexOfAnyValues renamed to SearchValues
href: core-libraries/8.0/indexofanyvalues-renamed.md
- name: ITypeDescriptorContext nullable annotations
href: core-libraries/8.0/itypedescriptorcontext-props.md
- name: Legacy Console.ReadKey removed
Expand Down Expand Up @@ -992,6 +994,8 @@ items:
href: core-libraries/8.0/getgeneration-return-value.md
- name: GetFolderPath behavior on Unix
href: core-libraries/8.0/getfolderpath-unix.md
- name: IndexOfAnyValues renamed to SearchValues
href: core-libraries/8.0/indexofanyvalues-renamed.md
- name: ITypeDescriptorContext nullable annotations
href: core-libraries/8.0/itypedescriptorcontext-props.md
- name: Legacy Console.ReadKey removed
Expand Down