Search code examples
vb.netstringvisual-studio-2015resharperstring-interpolation

String Interpolation gives "Unexpected token" error in VB.NET project


Am working on a legacy solution which includes some VB.NET projects.

Code like this

Throw New InvalidOperationException($"Cannot update {entity.Id} because it does not yet exist.") 

yields a red squiggly error "Unexpected token" at the dollar sign. I managed build the code by adding 14 to every build configuration in the relevant .vbproj file, but I am still haunted by these red squigglies. Not only under the $ dollar sign, but also under every End If/End Using/End Sub that follows it, which is considerably annoying.

Am using VS2015 Update 1, and the C# 6 language features, including string interpolation, have always just worked, even within this same solution.

I create File->New Project (implying, an entirely new solution) -> VB.NET Class library, and the code still builds fine but the IDE still gives me the squigglies. Perhaps the problem lies in some obscure machine.config setting? Some VS plugin I need to install?


Solution

  • It looks like the issue is caused by Resharper as of the latest version from today, 23 Dec 2015, and version 10.0.2 Build 104.0.20151218.120627. I've submitted a bug to the JetBrains folks.

    I'm not certain how broadly-applicable this problem might be, or if there are any confounding configuration items on my machine, etc.

    The issue goes away when I Tools->Options->ReSharper->Suspend Now, and returns when I "Resume Now" ReSharper.