Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When adding a long string, syntax highlighting stops working

This is not in any way related to this issue

broken syntax highlight example

The IDE I am using is Visual Studio Ultimate 2013

For demonstration purposes, the long string is a base64 encoded image 44,517 characters long (too large to paste here in a code block so I have it up on pastebin here)

The reason why I am embedding the image directly into the class is out of laziness. I do not wish to add all the images as resources for every project I wish to use this class inside, and since Resources loads the image from a base64 encoded version anyway, this is functionally no different but has the advantage of making the class a drop-in object (embedded, not compiled as an extra dll).

CodeSense continues to work, but as you can imagine lack of syntax highlighting, makes me feel like my dev environment just time-warped backwards 20+ years.

Any suggestions on how to correct this problem AND still embed the images directly into the class. (yes, I know, I want to have my cake AND eat it -- else why have a cake ? )

like image 934
Kraang Prime Avatar asked Jul 10 '15 19:07

Kraang Prime


1 Answers

This problem seems to have been fixed in Visual Studio 2015. I cannot reproduce it there using the code from your pastebin. I was however able to reproduce it in VS2013, so it's not just you.

In the meantime, one workaround that immediately comes to mind is to split the literal into chunks, since highlighting works just fine if the literals are short enough. Even just two 20-kilobyte chunks does the trick in my case. I'm not sure what the magic number is, but it's probably not worth trying to find out.

Scratch that — the magic number is, just as I suspected, 32,768, found through liberal use of copy and paste. This limit is specifically of the total length of a single line of code, including whitespace and punctuation (quotes, parens, etc), so when chunking the string literal make sure each chunk is on its own line. It's fine to concatenate them within a single statement so long as the statement is split across lines.

like image 169
BoltClock Avatar answered Oct 20 '22 16:10

BoltClock