dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.9k stars 783 forks source link

Certain errors show only when F# file is focused in VS 2017 #3229

Closed BentTranberg closed 7 years ago

BentTranberg commented 7 years ago

Error messages appear almost immediately in Error List pane when I open and focus one particular file, but stays only as long as I keep that file tab focused.

Screenshot of editor and error list:

image

The entire solution compiles successfully, and an application that uses the assemblies in question runs just fine. The problem is only that these errors appear in the Error List pane, apparently for no good reason.

The word "focused" is certainly the correct term here.

The errors will come and go almost immediately most of the time, but sometimes there is a few seconds delay - sufficiently long to remind me it's Intellisense at work here.

However, the first time I observed this, the errors would not go away, so I restarted VS to get rid of them.

When doing a build, the compiler reports success all over, in spite of the errors displayed in the Error List pane. One more reminder it's Intellisense.

The assembly uses another assembly, which effectively only contains the following. The reason for this is that I don't want to put my business F# code in an assembly that is forced to use an earlier F# version (4.3.1.0), which is the case when using this type provider.

So the assembly that only has this, uses F# 4.3.1.0.

open FSharp.Data.TypeProviders
type Tredata = DbmlFile<"Tredata.dbml">

And everything else uses F# 4.4.0.0.

Is this a compiler bug related to type providers in general? Or is the problem with this particular type provider? Or with the F# version(s)? Does it have something to do with the type provider having to be called at design time? I don't think I am making a mistake reporting, because A) it happens in 2017 but not 2015, and B) there shouldn't be errors in the Error List pane when the compiler reports success and the program runs fine, but could there be exceptions when it comes to type providers and Intellisense?

I may previously have seen other issue reports where actually this issue has been reported but drowned in other information. I am searching for them.

Present in VS 2017 Pro 15.2 (26430.13), F# Nightly 15.4.1.17062002 Not present in VS 2015 Pro 14.0.25431.01 Update 3 .NET Framework 4.5.2 Severity: Only a nuisance. Note to self: my 912 to create a repro for this. Is a repro wanted/needed?

dsyme commented 7 years ago

May be related to #3049

dsyme commented 7 years ago

@BentTranberg A standalone repro would help enormously to determine the problem and fix it

BentTranberg commented 7 years ago

When working on reducing source for a minimal repro for this, I ran into the problem that an actual error during build is not reported in the Error List pane. Only in the Output pane.

image

The error is that in the expression "sqlPakkedata sort", the sqlPakkedata is no longer a function, but just a string. When investigating this issue, you can add the "sort" parameter as shown in the picture, and see if you have the same problem with the error list. This appeared to be easily reproducible, but I didn't do much research.

PS: Repro in a few minutes.

BentTranberg commented 7 years ago

While working on reducing source for a minimal repro for this, I discovered the following behavior.

1) When starting VS, opening the repro the first time (no binaries produced yet, no packages downloaded), building the solution, and then opening LegacyReportsTypedSql.fs, the following errors appear.

image

It's the same errors repeating to the end.

This is not the errors I reported about initially. The behavior is otherwise as reported above.

2) Then I restart VS. The binaries and packages are now in place already. Now I get this when the file is opened.

image

We're back to my initial report. This is reproducible. If you want to reproduce it, then delete the bin and obj folders in the projects, and/or the downloaded NuGet packages. Then follow my steps in this post.

BentTranberg commented 7 years ago

Here is the repro, a compilable solution. I believe the zip contains source only.

Repro.zip

dsyme commented 7 years ago

@BentTranberg Can you check against master? This looks like the same bug as #3120 and it appears fixed when I am using master

I had to build the solution in order to get intellisense to show