Repository navigation
Description
Switching between Debug and Release configurations, the syntax coloring between #if-#endif does not update properly (stays greyed out when it should not be and vice-versa).
Closing and re-opening the file sometimes helps, sometimes it ends up with no coloring at all:
Cut-pasting the line between the #if and #else clauses leads to half-way coloring sometimes. Here the color is correct on "Console" but not on WriteLine, however WriteLine correctly appears bold (I have set methods to appear bold).
Repro steps
- File -> New Project -> Visual F# -> Console Application
- Replace Program.fs with the following code:
open System
[<EntryPoint>]
let main argv =
#if DEBUG
Console.WriteLine "debug"
#else
Console.WriteLine "release"
#endif
0
- Switch to Release configuration
After ~1 second the coloring changes but only partially.
After 8-11 seconds the coloring changes again and this time it is correct.
- Switch to Debug configuration.
- Focus some other windows outside Visual Studio and keep the mouse cursor outside the Visual Studio client area.
This time you can observe additional phases in coloring and it takes even longer before it becomes correct.
Repro steps
- File -> New Project -> Visual F# -> Console Application
- Replace Program.fs with the following code:
open System
[<EntryPoint>]
let main argv =
#if DEBUG
Console.WriteLine "debug"
#else
Console.WriteLine "release"
#endif
0
- Switch to Release configuration
After ~1 second the coloring changes but only partially.
After 8-11 seconds the coloring changes again and this time it is correct.
- Switch to Debug configuration.
- Focus some other windows outside Visual Studio and keep the mouse cursor outside the Visual Studio client area.
This time you can observe additional phases in coloring and it takes even longer before it becomes correct.
Version info
Visual FSharp Tools 15.4.1.17051001.



Activity
vasily-kirichenko commentedon May 20, 2017
Could you check if it's reproduced on C# files as well? I suspect it's a Roslyn bug.
asik commentedon May 20, 2017
Sometimes it briefly happens for C# as well but it always ends up correct after a few seconds.
dsyme commentedon May 21, 2017
I wonder if #3025 was included in that build, that contained fixes to switching configurations.
Would also be good to have an exact repro
dsyme commentedon Jun 20, 2017
@asik Could you please try again on latest nightly? It is likely #3025 fixed this
asik commentedon Jun 20, 2017
When I switch from Release to Debug or vice-versa, initially the coloring is incorrect as described above, but it fixes itself after about 10 seconds. This is a test project with a single 40-line file, so while it is working, it is very slow.
dsyme commentedon Jun 20, 2017
@asik Related: #3000 (comment)
asik commentedon Jun 20, 2017
It is much longer than the 1,5 seconds Roslyn delay, more like 10 seconds; there must be something more going on.
dsyme commentedon Jun 21, 2017
@asik Could you attach exact step-by-step repro with an example project please.
asik commentedon Jun 21, 2017
After ~1 second the coloring changes but only partially.
After 8-11 seconds the coloring changes again and this time it is correct.
This time you can observe additional phases in coloring and it takes even longer before it becomes correct.
dsyme commentedon Jun 21, 2017
@asik Thanks, I repro that behaviour too
dsyme commentedon Jun 21, 2017
Here is a trace from the reactor thread when the configuration switch happens:
dsyme commentedon Jun 21, 2017
The problems are
three calls to "pausing 1 second" by the FSharp.Compiler.Service before beginning background work. I believe these can basically be removed, perhaps we pause 0.05 seconds instead to allow more UI requests to be processed
a very long 3.5 second pause by Roslyn here:
I don't know why it is pausing that long before firing an analyzer (or more precisely, for the analyzer request to come through to FCS)
This is because the analyzers aren't being triggered in parallel in this case. I've asked on the Roslyn thread about this, and whether some DocumentDiagnosticAnalyzers can be higher priority than others
dsyme commentedon Jun 21, 2017
This is what the log looks like after
The overall reaction time is better (~5 seconds instead of 8-10) but it is still too long
The remaining problems appear to be a 2 second Roslyn pause before the DocumentDiagnosticAnalyzers are run:
followed by another three second pause before the SemanticColorization analyzer is called:
dsyme commentedon Jun 22, 2017
@asik #3238 makes some improvements if you would like to give it a go.
asik commentedon Jun 22, 2017
I am going on a long vacation so I probably won't be firing up Visual Studio anytime soon. But I'm happy to see progress being made on this issue.
dsyme commentedon Jun 22, 2017
@asik Thanks for reporting this. I'll close it now #3238 has been fixed. As metnioned on the bug this doesn't make everything "instantaneous", but it is a good improvement