Language injections in C#

Last modified: 25 September 2024

If a string literal contains some other formal language, such as regular expression, HTML, and so on, JetBrains Rider can provide code inspection, quick-fixes, code completion, context actions, and many other features specific to that language right inside this excerpt.

JetBrains Rider supports the following languages inside C# string literals:

There are cases when language excerpts in another language file can be detected unambiguously, for example, SQL inside the SqlCommand() constructor. In these cases, JetBrains Rider detects embedded languages automatically. If necessary, you can configure automatic language injections in specific cases on the Editor | Language Injections page of JetBrains Rider settings .

When a formal language inside a string literal cannot be detected automatically, JetBrains Rider allows you to manually mark the literal as containing specific language in one of the following ways: