ReSharper 2024.3 Help

Code inspection: Avoid mixing of variable-length escape sequences and text

This code inspection warns about escape sequences that start with \x. These sequences can work with hex numbers of various lengths, thus allowing you to accidentally "attach" first letters of the text that follows to the \x sequence if the text starts with letters ABCDEF.

In contrast to that, \u escape sequences always require exactly 4 hex digits after \u.

There are quick-fixes to make such escape sequences less fragile: by using a \u escape sequence, or by splitting the string literal to visually separate the escape sequence and the text that follows.

Console.WriteLine("\x20Abracadabra");
Console.WriteLine("\x20Ab" + "racadabra");
Last modified: 08 August 2024