Header menu logo ionide-analyzers

EmptyStringAnalyzer

Problem

Testing symbolically for an empty string is not the most efficient way.
Using the String.Length property or the String.IsNullOrEmpty method is the preferred way.
This is a port of the Roslyn analyzer ca1820

let s = "foo"
let b = s = "" // Triggers analyzer 

Fix

Use the Length property if you know the reference is not null or the String.IsNullOrEmpty method otherwise.

let s = "foo"
let b = s.Length = 0
val s: string
val b: bool
property System.String.Length: int with get

Type something to start searching.