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
better error protection for language service - #3379
Some watson dump error reports reported automatically to Microsoft are showing failures where exceptions are escaping the language service. This fix adds error protection to more language service entry points, and adds error recovery for incomplete assembly reference sets in some extra cases.
The situation is a missing assembly reference in the user’s project file. This is legitimate but not particularly common. For the most part we handle this situation correctly.
The correct behaviour in this situation is as follows
The missing assembly reference causes the compiler to trigger an error when exploring the metadata for that assembly.
During command-line compilation, the correct behaviour for the compiler in this situation is to report an error. The user will normally see this error and fix the problem.
For the language service intellisense requests, the correct behaviour is to skip over the missing assembly reference when, for example, collecting declarations to show in the IDE. This is done using calls to “protectAssemblyExploration” which can be found already in several places the code
Our methodology to prepare a fix is to do two things:
find the first callstack entry that is unique to the language service where it is possible to return a “default” value and to use “protectAssemblyExploration” to do that.
find the entrypoint to the language service which is manipulating F# symbols and protect that using ErrorScope.Protect, again returning a default value. This is a catch-all.
The PR resolves this as follows
Looking back down the stack, we find suitable places to protection are
ResolveCompletionsInType (the first stack frame specific to FCS)
GetSymbolUseAtLocation (the entry point to FCS, which, sure enough, was missing this protection).
On review, I have also added protection here:
IsItemResolvable (new unprotected code added in VS2017 that is specific to FCS and was unprotected and where it is reasonable to return a default value)
GetVisibleNamespacesAndModulesAtPoint (new unprotected code added in VS2017 that is specific to FCS where it is reasonable to return a default value)
GetMethodsAsSymbols (a new entry point to FCS added in VS2017, though as yet unused by the Visual F# Tools)
GetSemanticClassification (a new entry point to FCS added in VS2017, used extensively by colorization in the Visual F# Tools)
The cause is that new code has been brought over from the Visual F# Power Tools which manipulates symbols (and thus does assembly exploration).
Our testing of the language service in the presence of incomplete assembly reference sets is not great – we have some smoke tests but nothing systematic (e.g. where we systematically delete assembly references and re-run existing tests checking only that no exceptions are escaping).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some watson dump error reports reported automatically to Microsoft are showing failures where exceptions are escaping the language service. This fix adds error protection to more language service entry points, and adds error recovery for incomplete assembly reference sets in some extra cases.