Skip to content

Analyzer proposal: Use String.Contains(char) instead of String.Contains(String) #47180

Closed
dotnet/roslyn-analyzers
#4908
@xtqqczze

Description

@xtqqczze

Suggested category: Performance
Suggested default severity: Suggestion
Fix is breaking or non-breaking: Non-breaking

Cause

This rule locates calls to Contains(String) when the string consists of a single char, and suggests using Contains(char) instead

Rule description

When Contains(String) is used with a single char, the call can be safely substituted with Contains(char).

Additional context

#24068
dotnet/coreclr#15740
#36310

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