Search code examples
c#visual-studio-2022intellicode

How to disable raw string conversion suggestions from IntelliCode in Visual Studio?


I write C# files in VS2022.

Oftentimes I will write multi-line strings like so, and Intellisense will repeatedly (it takes < 40 characters) suggest to put it all on the same line, like so:

enter image description here

enter image description here

This is obviously awful, I don't want that, and I'm certainly not in the habit of writing multi-paragraph strings in one line, but it just keeps suggesting it. This would be fine... if a space didn't accept its suggestion, making it virtually impossible to write multi-line strings without turning C# suggestions off entirely.

Is there a way to turn off specifically IntelliCode suggestions to put multi-line strings on the same line? I see no such thing in the place I'd expect to find such an option should it exist:

enter image description here


Solution

  • As you can see, the "[i]ntellicode suggestion is based on recent edits". This means, that it is based on edits you have made, and therefore does not map to any style rule. It proposes this, because you appear to have made similiar edits in the past. However there should be a light bulb, when hovering over this section, on which you can select ignore with a right click. See https://devblogs.microsoft.com/visualstudio/making-repeated-edits-easier-with-intellicode-suggestions/.

    However I would recommend to use "raw string literals" either way. This is of course up to you though..