Skip to content

No unification of build and intellisense diagnostics in VS2017 (was in VS2015) #3047

Closed

Description

@dsyme

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.

  1. open any solution, e,g,

    devenv tests\projects\misc\TestProjectChanges\TestProjectChanges.sln

2,. add an error, watch intelliense error appear

  1. do a build, wathc duplicate copy of "build" error appear

  2. fix the error - the "intellisense" copy goes away, but the red suiglly stays

  3. 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

image

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.

Activity

  1. dsyme commented on May 13, 2017

    @dsyme
    ContributorAuthor

    (Note, I haven't yet compared to C# roslyn behavior)

  2. BentTranberg commented on May 13, 2017

    @BentTranberg

    @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.

  3. dsyme commented on May 13, 2017

    @dsyme
    ContributorAuthor

    @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.

  4. dsyme commented on May 13, 2017

    @dsyme
    ContributorAuthor

    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

  5. saul commented on May 14, 2017

    @saul
    Contributor

    @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)

  6. dsyme commented on May 15, 2017

    @dsyme
    ContributorAuthor

    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...

    Thanks, that's very helpful! Here's a copy of the relevant comment:

    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.

  7. dsyme commented on May 15, 2017

    @dsyme
    ContributorAuthor

    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

  8. dsyme commented on May 15, 2017

    @dsyme
    ContributorAuthor

    @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.

  9. dsyme commented on May 15, 2017

    @dsyme
    ContributorAuthor

    @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.

  10. dsyme commented on May 15, 2017

    @dsyme
    ContributorAuthor

    @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)

  11. Pilchie commented on May 15, 2017

    @Pilchie
    Member

    @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.

  12. added
    Impact-High
    on May 15, 2017
  13. 13 remaining items

  14. saul commented on May 17, 2017

    @saul
    Contributor

    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

  15. dsyme commented on May 17, 2017

    @dsyme
    ContributorAuthor

    @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:

    image

  16. saul commented on May 17, 2017

    @saul
    Contributor

    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!

    image

  17. dsyme commented on May 17, 2017

    @dsyme
    ContributorAuthor

    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?

  18. dsyme commented on May 25, 2017

    @dsyme
    ContributorAuthor

    @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!

  19. Pilchie commented on May 25, 2017

    @Pilchie
    Member

    @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.

  20. dsyme commented on May 25, 2017

    @dsyme
    ContributorAuthor

    @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

  21. Pilchie commented on May 25, 2017

    @Pilchie
    Member

    In that case I would recommend either:

    1. Holding the F# change until there is a public build with the fix, which is unforunate.
    2. 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.
  22. dsyme commented on May 26, 2017

    @dsyme
    ContributorAuthor
    1. 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.

    That sounds plausible

  23. added this to the milestone on Jul 10, 2017
  24. dsyme commented on Aug 18, 2017

    @dsyme
    ContributorAuthor

    Fixed by #3071

  25. modified the milestones: , 15.5 on Jun 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-LangService-APIBugImpact-HighReadyRegression

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions