3

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?

3
  • I believe you MUST take off the dolar sign if the project is VB.NET. And since you have that kind of error in source code, it is normal to editor create "ghost errors" after this. Try to erase the "$" and probably you will see the code without any other error in editor. Commented Dec 23, 2015 at 2:06
  • 2
    Removing the $ causes the expression to become a string literal, with no interpolation. Every example I see on the internet seems to demonstrate string interpolation in VB.NET working just like C#, each one beginning with a $. I think the solution might lie elsewhere. msdn.microsoft.com/en-us/magazine/dn890368.aspx Commented Dec 23, 2015 at 2:16
  • I can create a new solution in VS 2015 and that statement compiles with no errors as long as entity.Id is declared (and if it isn't, I get a different error). Commented Dec 23, 2015 at 3:28

1 Answer 1

6

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.

Sign up to request clarification or add additional context in comments.

2 Comments

More accurately, ReSharper does not yet support VB.NET 14, although you can vote for the addition of support here youtrack.jetbrains.com/issue/RSRP-442744 I haven't yet added my vote though. Not sure if I should influence their development resources in that direction. :-)
don't hate! it takes a lot of effort to move a big project off of vb.net, and not worth the time put in in at all. Especially with a small shop. New features bring in the cash, not c#.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.