Header menu logo G-Research F# Analyzers

StringAnalyzer

There are multiple analyzers for various string comparison functions:

Problem

The recommendations for string usage mention calling the overloads using StringComparison to increase performance.

"foo".EndsWith("p")

Fix

Signal your intention explicitly by calling an overload.

open System

"foo".EndsWith("p", StringComparison.Ordinal)
namespace System
[<Struct>] type StringComparison = | CurrentCulture = 0 | CurrentCultureIgnoreCase = 1 | InvariantCulture = 2 | InvariantCultureIgnoreCase = 3 | Ordinal = 4 | OrdinalIgnoreCase = 5
<summary>Specifies the culture, case, and sort rules to be used by certain overloads of the <see cref="M:System.String.Compare(System.String,System.String)" /> and <see cref="M:System.String.Equals(System.Object)" /> methods.</summary>
field StringComparison.Ordinal: StringComparison = 4

Type something to start searching.