You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
No unification of build and intellisense diagnostics in VS2017 (was in VS2015) #3047
There are likely multiple issues with the Visual Studio Error list.. I'm splitting out one known repro for a basic one, which is the lack of "Error Unification" between build and intellisense errors.
do a build, wathc duplicate copy of "build" error appear
fix the error - the "intellisense" copy goes away, but the red suiglly stays
do a build - the "build" error goes away
Although logical, it is painful to have the red squiggly stay around even after you've fixed the error. In practice this means that once you do a build, and there are errors, you have to keep doing builds do clear all your red-squigglies, or else resort to showing Intellisense errors only.
This is a regression (or at least a change) from how F# worked in VS2015 and before, when build and intellisense errors were "unified" and fixing an error made it disappear from the error list - the user just was not particularly aware of the distinction between build and intellisense errors.
Now I'm not sure how deeply this distinction is built into Roslyn - it may not be something we control anymore - advice welcome please @Pilchie@DustinCampbell
Note that the diagnostic ID is also missing for the build error - this could be the underlying problem since some comments in the F# language service code imply that error de-duplication should be ocurring. It's possible this is a problem with whichever error parser is being used by default
Here is the output from the build, it contains FS0039
3>C:\GitHub\dsyme\visualfsharp\tests\projects\misc\TestProjectChanges\TestProjectChanges\Program.fs(7,58): error FS0039: The field, constructor or member 'PropertyA' is not defined. Maybe you want one of the following: PropertyAlwaysAvailable
3>Done building project "TestProjectChanges.fsproj" -- FAILED.
@dsyme, I compared C# and F# in VS 2015 and VS 2017, and the results is in a comment a bit down in #2548. I don't understand that much of this, but it looks to me there's pretty much the same issue in VS 2015, but just not that obvious to the user.
@BentTranberg Ah yes, thanks. Good analysis. TBH I much prefer the "unified error list" model of F# in VS2015 (all errors are just one kind of error), I wonder why C#/roslyn didn't adopt this model.
One of the odd things here is that this recently added code seems to indicate that we are trying to do error unification.
// Normalize the error message into the same format that we will receive it from the compiler.
// This ensures that IntelliSense and Compiler errors in the 'Error List' are de-duplicated.
// (i.e the same error does not appear twice, where the only difference is the line endings.)
However the displayed error message in the error list above still has newline characters. Odd, will debug through this
@dsyme we are trying but we aren't reporting build errors through Roslyn, so it doesn't see the build/intellisense errors as identical (as the former don't have error IDs amongst other data). I believe I put more info in my PR: #2839 (comment)
we are trying but we aren't reporting build errors through Roslyn, so it doesn't see the build/intellisense errors as identical (as the former don't have error IDs amongst other data). I believe I put more info in my PR...
F# build errors are passed to the IDE via the ErrorListProvider, which is wrapped by a Microsoft.VisualStudio.Shell.TaskProvider. See DocumentTask.cs@506 in the F# code.
I think the correct solution for this is to move over to Roslyn's ProjectExternalErrorReporter. We currently don't report any errors through this, but this class implements IVsLanguageServiceBuildErrorReporter2 so we can report build errors through the ReportError2 method. This is what the Roslyn project system does.
More notes. The current F# project system has IDEBuildLogger which is added to MSBuild loggers in DoMSBuildSubmission
loggerList.Add(buildLogger);
MSBuild then raises events and these get pushed to ErrorHandler and WarningHandler and thus to AddToErrorList. This creates a DefaultCompilerError (which does contain the error code) and a DocumentTask which doesn't. The task gets registered using taskReporter.AddTask. As @saul mentions, this last call should be removed and we should probably use ProjectExternalErrorReporter
@Pilchie I'd appreciate some guidance here: does Roslyn come with any mechanism for listening to build output (e.g. from an MSBuild build logger) and creating matching tasks from the Error and Warning items that come from MSBuild? And matching those to the text being shown in the output window?
The context is that F# intellisense errors (via roslyn) and the F# build errors (via non-roslyn) are not being de-duplicated. This is because of subtle differences in the content of the error/task items being produced by these two paths (slightly different text in multi-line error messages, and a missing ID for the non-Roslyn errors). Ideally we want to produce all errors via roslyn to better ensure consistency. But we don't want to reinvent the wheel here.
Glancing around the Roslyn code I see GetExternalErrorReporter but also note there is no F# mapping here, which must be why we create our own. It would be helpful to start removing the C#/VB-specific things from Roslyn and just make it a multi-language framework.
@saul If you get the chance could you take a glance over that draft and see what you think? The idea is to literally delete the use of TasKReporter and TaskProvider in the ProjectSystem.Base and replace it with a propagated IVsLanguageServiceBuildErrorReporter2 (i.e. a ProjectExternalErrorReporter)
@heejaechang has pretty much done everything related to the Error List since Roslyn started, and I'll admit that I've lost track of it.
HeeJae - can you confirm my understanding is correct?
IIRC, Roslyn has no ability to insert msbuild loggers or anything, but the C# project system looks for error output and creates the "Build" tasks. Roslyn only reports the "IntelliSense" errors from it's in-memory model.
In which case, the errors should definitely go through ErrorLogger.NormalizeErrorString |> ErrorLogger.NewlineifyErrorString.
Your last screenshot also doesn't agree with the screenshot I put on the PR, which does have new lines in both cases. Maybe it's something specific to the suggested names? Either way it should have new lines!
In which case, the errors should definitely go through ErrorLogger.NormalizeErrorString |> ErrorLogger.NewlineifyErrorString.
Yes, I was wondering that. Though don't forget the error text is scraped from the output of fsc.exe by MSBuild (with --flaterrors). Does that even have the magic characters needed?
@dsyme We don't install roslyn binaries here. As there are no API changes involved in the Roslyn change, this should just start working on newer builds of VS with that Roslyn change.
@Pilchie Ah. The problem is that we can't use the functionality until we can be sure we have the fix - if we ended up running against the old binaries we bring down the whole VS process because we end up hitting the FailFast here (I suggested a more gracious error handling technique would have been sensible :) )
Holding the F# change until there is a public build with the fix, which is unforunate.
Conditioning the F# change on the file version of the Roslyn binary being higher than the first Roslyn signed build with this fix (looks like that's 20170524.5) and filing an issue to remove the lightup check once F# depends on a public version with the fix.
Conditioning the F# change on the file version of the Roslyn binary being higher than the first Roslyn signed build with this fix (looks like that's 20170524.5) and filing an issue to remove the lightup check once F# depends on a public version with the fix.
Activity
dsyme commentedon May 13, 2017
(Note, I haven't yet compared to C# roslyn behavior)
BentTranberg commentedon May 13, 2017
@dsyme, I compared C# and F# in VS 2015 and VS 2017, and the results is in a comment a bit down in #2548. I don't understand that much of this, but it looks to me there's pretty much the same issue in VS 2015, but just not that obvious to the user.
dsyme commentedon May 13, 2017
@BentTranberg Ah yes, thanks. Good analysis. TBH I much prefer the "unified error list" model of F# in VS2015 (all errors are just one kind of error), I wonder why C#/roslyn didn't adopt this model.
dsyme commentedon May 13, 2017
One of the odd things here is that this recently added code seems to indicate that we are trying to do error unification.
However the displayed error message in the error list above still has newline characters. Odd, will debug through this
saul commentedon May 14, 2017
@dsyme we are trying but we aren't reporting build errors through Roslyn, so it doesn't see the build/intellisense errors as identical (as the former don't have error IDs amongst other data). I believe I put more info in my PR: #2839 (comment)
dsyme commentedon May 15, 2017
Thanks, that's very helpful! Here's a copy of the relevant comment:
dsyme commentedon May 15, 2017
More notes. The current F# project system has
IDEBuildLoggerwhich is added to MSBuild loggers inDoMSBuildSubmissionMSBuild then raises events and these get pushed to
ErrorHandlerandWarningHandlerand thus toAddToErrorList. This creates aDefaultCompilerError(which does contain the error code) and aDocumentTaskwhich doesn't. The task gets registered usingtaskReporter.AddTask. As @saul mentions, this last call should be removed and we should probably useProjectExternalErrorReporterdsyme commentedon May 15, 2017
@Pilchie I'd appreciate some guidance here: does Roslyn come with any mechanism for listening to build output (e.g. from an MSBuild build logger) and creating matching tasks from the Error and Warning items that come from MSBuild? And matching those to the text being shown in the output window?
The context is that F# intellisense errors (via roslyn) and the F# build errors (via non-roslyn) are not being de-duplicated. This is because of subtle differences in the content of the error/task items being produced by these two paths (slightly different text in multi-line error messages, and a missing ID for the non-Roslyn errors). Ideally we want to produce all errors via roslyn to better ensure consistency. But we don't want to reinvent the wheel here.
dsyme commentedon May 15, 2017
@saul @Pilchie I notice we do already create our own ProjectExternalErrorReporter, perhaps we just have to use that
Glancing around the Roslyn code I see GetExternalErrorReporter but also note there is no F# mapping here, which must be why we create our own. It would be helpful to start removing the C#/VB-specific things from Roslyn and just make it a multi-language framework.
dsyme commentedon May 15, 2017
@saul @Pilchie
I took a look at what it would take to junk the existing F# code for build task creation and use ProjectExternalErrorReporter. A draft of what would be needed is here:
https://github.com/Microsoft/visualfsharp/compare/master...dsyme:eld?expand=1
@saul If you get the chance could you take a glance over that draft and see what you think? The idea is to literally delete the use of TasKReporter and TaskProvider in the ProjectSystem.Base and replace it with a propagated
IVsLanguageServiceBuildErrorReporter2(i.e. a ProjectExternalErrorReporter)Pilchie commentedon May 15, 2017
@heejaechang has pretty much done everything related to the Error List since Roslyn started, and I'll admit that I've lost track of it.
HeeJae - can you confirm my understanding is correct?
IIRC, Roslyn has no ability to insert msbuild loggers or anything, but the C# project system looks for error output and creates the "Build" tasks. Roslyn only reports the "IntelliSense" errors from it's in-memory model.
13 remaining items
saul commentedon May 17, 2017
Hmm then something isn't right... or the build errors are being reported to the IDE in a different way now? There is code that explicitly replaces the fake newline character with the real one before passing it to the platform: https://github.com/Microsoft/visualfsharp/blob/ce473ddab307c1bbbf027207badf086e71a238ff/vsintegration/src/FSharp.Editor/Common/RoslynHelpers.fs#L108-L111
dsyme commentedon May 17, 2017
@saul That's right for Intellisense errors. The question is build errors, which go via the IDEBuildLogger class.
The screenshots above are for my branch when using a fixed Roslyn
When using master, you get this:
saul commentedon May 17, 2017
In which case, the errors should definitely go through
ErrorLogger.NormalizeErrorString |> ErrorLogger.NewlineifyErrorString.Your last screenshot also doesn't agree with the screenshot I put on the PR, which does have new lines in both cases. Maybe it's something specific to the suggested names? Either way it should have new lines!
dsyme commentedon May 17, 2017
Yes, I was wondering that. Though don't forget the error text is scraped from the output of fsc.exe by MSBuild (with --flaterrors). Does that even have the magic characters needed?
dsyme commentedon May 25, 2017
@brettfo The fix is now in roslyn - dotnet/roslyn#19561. Could you update this issue when we have those Roslyn binaries in this repo please? THanks!
Pilchie commentedon May 25, 2017
@dsyme We don't install roslyn binaries here. As there are no API changes involved in the Roslyn change, this should just start working on newer builds of VS with that Roslyn change.
dsyme commentedon May 25, 2017
@Pilchie Ah. The problem is that we can't use the functionality until we can be sure we have the fix - if we ended up running against the old binaries we bring down the whole VS process because we end up hitting the FailFast here (I suggested a more gracious error handling technique would have been sensible :) )
https://github.com/dotnet/roslyn/blob/175c1605927859bc3cfcd4a84b720b27c4054ba9/src/Features/Core/Portable/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer.StateManager.cs#L139
Pilchie commentedon May 25, 2017
In that case I would recommend either:
dsyme commentedon May 26, 2017
That sounds plausible
dsyme commentedon Aug 18, 2017
Fixed by #3071