We are facing issue when defining verbatim multiline strings (@"some string"
) in Visual Studio 2022. Although we are compling code on Windows machine and variable Environment.NewLine
defines \r\n
as new line, verbatim multiline string contains just \n
. See below.
Does anybody have idea why carriage return is missing in string?
Finally found answer, thanks to John Skeet who gave me a hint.
Behaviour was caused by the code editor - in our case Visual Studio 2022. Basically each code editor allows you to define line breaks behaviour and you can override it by settings in
.editorconfig
- propertyend_of_line
- see documentationHere is an example of the
.editorConfig
file:You can also define behaviour for files in Git repository using
.gitattributes
file:Visual Studio also allows you to reformat current file using option
Edit->Advanced->Set End of Line Sequence
but this is just applied to currently opened file.