Skip to content

Prefer string.AsSpan() over string.Substring() when parsing #33784

@terrajobst

Description

@terrajobst

The rule should flag instances of a pattern like int.Parse(str.Substring(...)) and instead switch to using the span-based int.Parse(str.AsSpan(...)). This would apply to all of the primitive types, and more generally potentially anything that has an overload taking a ReadOnlySpan<char> instead of a string.

Category: Performance

Metadata

Metadata

Assignees

Labels

api-approvedAPI was approved in API review, it can be implementedarea-System.Runtimecode-analyzerMarks an issue that suggests a Roslyn analyzercode-fixerMarks an issue that suggests a Roslyn code fixer

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions