-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Open
Labels
area-System.Memoryneeds-further-triageIssue has been initially triaged, but needs deeper consideration or reconsiderationIssue has been initially triaged, but needs deeper consideration or reconsideration
Milestone
Description
dotnet/roslyn-analyzers#6898 is adding an analyzer that will flag uses like
const string MyValues = "abcdef";
span.IndexOfAny(MyValues);
and offer a fixer to replace it with
private static readonly SearchValues<char> s_myValues = SearchValues.Create(MyValues);
const string MyValues = "abcdef";
span.IndexOfAny(s_myValues);
For patterns like these, we should consider using interceptors to automagically rewrite them to use SearchValues
, without requiring the user to extract the values to a field.
The logic could also be smarter and rewrite the above example to use IndexOfAnyInRange
directly instead.
This would also help projects that multi-target to TFMs that don't have SearchValues
, as it would let them take advantage of the perf improvements without extra #if
#else
s.
istipeti
Metadata
Metadata
Assignees
Labels
area-System.Memoryneeds-further-triageIssue has been initially triaged, but needs deeper consideration or reconsiderationIssue has been initially triaged, but needs deeper consideration or reconsideration