VS Code Bug - Interpolation and Commented Lines, Workaround

This is a quick post with a workaround to a bug in VS Code that occurs when you use string with @$ - the verbatim character and the interpolation characters.

If you have a piece of code that looks like this -

1string text = @$"any text as long as there is a new line
2/*";

Everything that comes after it will look commented out, like so -

This is a bit annoying because all coloring is lost below that /*.

You might not have hit this, but if start using Pulumi for IaC in AWS, you will because many permissions on resources often end with /*, or if you want to print some slashes and stars to the console.

Fortunately, there is a very easy workaround! Use $@ instead of @$.

1string text = $@"any text as long as there is a new line
2/*";

Much better!

comments powered by Disqus

Related