Skip to content

Conversation

@vasily-kirichenko
Copy link
Contributor

No description provided.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace with |> CommonRoslynHelpers.StartAsyncAsTask cancellationToken now please

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the GotoDefinition implementation we now have

                match classifiedSpan.ClassificationType with
                | ClassificationTypeNames.ClassName
                | ClassificationTypeNames.DelegateName
                | ClassificationTypeNames.EnumName
                | ClassificationTypeNames.InterfaceName
                | ClassificationTypeNames.ModuleName
                | ClassificationTypeNames.StructName
                | ClassificationTypeNames.TypeParameterName
                | ClassificationTypeNames.Identifier -> 

So I'm assuming quickinfo won't work at operators with this PR.

I think you should abstract out the tryClassifyAtPosition implementation and use it in both places.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these needed? thx

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PresentationFrameword is needed for Label type.
WindowsBase is for FrameworkElement.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@dsyme
Copy link
Contributor

dsyme commented Nov 26, 2016

Could you add one or two unit tests that exercises ProvideQuickInfo please? There are many other unit tests already for the underlying logic of course, but having something in place to enable further future testing at the level of ProvideQuickInfo would be great

@dsyme
Copy link
Contributor

dsyme commented Nov 26, 2016

@vasily-kirichenko Absolutely fantastic to see this in place.

Copy link
Contributor

@dsyme dsyme Nov 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@dsyme dsyme Nov 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note I understand nothing about MEF composition :/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, C# provider imports other dependencies, but I don't think it's the problem. We successfully import SVsServiceProvider in several places. I don't know much about MEF either :(

@vasily-kirichenko
Copy link
Contributor Author

Could you add one or two unit tests that exercises ProvideQuickInfo please? There are many other unit tests already for the underlying logic of course, but having something in place to enable further future testing at the level of ProvideQuickInfo would be great

I'd like to make it work first. I still throws exception.

@dsyme dsyme changed the title Implement FSharpQuickInfoProvider (by @OmarTawfik) [WIP] Implement FSharpQuickInfoProvider (by @OmarTawfik) Nov 26, 2016
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it works now.

@vasily-kirichenko
Copy link
Contributor Author

image

@vasily-kirichenko
Copy link
Contributor Author

It kind of works now. The tooltip is always positioned below all visible text, not close to the symbol.

@dsyme
Copy link
Contributor

dsyme commented Nov 26, 2016

@vasily-kirichenko Yeah, getting the positioning right is really important.

@dsyme
Copy link
Contributor

dsyme commented Nov 26, 2016

Great to see the progress!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this cache works given that CWT referential identity of an object as a key

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok. That was my code. Needs to be fixed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vasily-kirichenko Could you check the identity used by ConditionalWeakTable and see if it uses .Equals and .GetHashCode or just object identity? Probably the latter. Thanks. (Not sure if there's any good key available in that case, maybe just remove this CWT for now)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dsyme
Copy link
Contributor

dsyme commented Nov 27, 2016

@vasily-kirichenko See #1855 for one methodology to add tests. I particularly like to write tests without using the TestCase attribute, and instead just a loop. And use modules not classes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove these changes from the PR please? Presumably the lines are needed. Just remove them locally

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines prevents the project to be load in VS.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I know. But we shouldn't check in their removal until we find out what they are for. People working on master who want to load FSHarp.Compiler into VS can just remove them by hand until tomorrow, thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please just use single line formatting for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do, but I don't see your point. Is this better?

image

I cannot even see how many parameters this method has and what's the result type.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use single line formatting for this - multi-line is not useful - it's basically a record in any case

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise - single line please

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use new Label(Content=content, Foreground=SolidColorBrush(Colors.Black))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Single line signature please

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use ParseAndCheckFileInProject (see #1855 )

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is 189? The tokenTag I guess. I think you can use tagOfToken on an identifier

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please just use null given this is implementing a C# interface

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Or use None followed by Option.toObj at the end)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Single line signature please

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(or formatted like the original)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe minimize the diff in this method? Many of the changes are formatting

@dsyme
Copy link
Contributor

dsyme commented Nov 27, 2016

@vasily-kirichenko This looks great. I left a bunch of fairly minor comments.

Copy link
Contributor

@dsyme dsyme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see requested changes (Relatively minor)

@vasily-kirichenko
Copy link
Contributor Author

I've ported somewhat hacky code from VFPT to get current theme colors (https://github.com/fsprojects/VisualFSharpPowerTools/blob/03c613acd3aa67cb5e3a339d3dcf1c7c783f30c2/src/FSharp.Editing.VisualStudio/Common/VSColors.fs)

It works:

image

image

If anybody knows a better way to do it, please tell us.

@forki
Copy link
Contributor

forki commented Nov 27, 2016

Awesome!

@dsyme
Copy link
Contributor

dsyme commented Nov 27, 2016

This is fantastic. Looks ready to go to me, once green

@dsyme dsyme changed the title [WIP] Implement FSharpQuickInfoProvider (by @OmarTawfik) Implement FSharpQuickInfoProvider (by @OmarTawfik) Nov 27, 2016
@dsyme dsyme merged commit f67db1f into dotnet:master Nov 27, 2016
@dsyme
Copy link
Contributor

dsyme commented Nov 27, 2016

@vasily-kirichenko Thank you!

@dsyme
Copy link
Contributor

dsyme commented Nov 27, 2016

Looks like it's pure hash table https://referencesource.microsoft.com/#mscorlib/system/runtime/compilerservices/ConditionalWeakTable.cs,464 Is it ok or I should remove the cache?

Yes, that's an object identity hash, not a call to obj.GetHashCode(). We should remove the cache for now

@dsyme
Copy link
Contributor

dsyme commented Nov 27, 2016

Just to mention that after this change both the QUickInfo and errors show when hovering over a red squiggly

This is good, but disambiguating between these using colors will be necessary
capture7

@vasily-kirichenko
Copy link
Contributor Author

@dsyme we don't have control over errors formatting.

@cloudRoutine
Copy link
Contributor

both the QuickInfo and errors show when hovering over a red squiggly

A long needed and overdue feature 😄

open System.Reflection
open Microsoft.VisualStudio.Shell
open System.Windows.Controls
// A port of https://github.com/tomasr/viasfora/blob/master/Viasfora/Util/VsColors.cs
Copy link
Contributor

@JoshVarty JoshVarty Nov 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you guys are supporting VS 2010 in this release then you'll need to interact with colors this way. In which case I'd add a comment that says something like "We want to support Visual Studio 2010, but EnvironmentColors weren't added until Visual Studio 2012 so we have to load the VS2012 DLL dynamically and interact with themes using reflection." (The file you've linked to doesn't exist at that location anymore)

If this .vsix isn't going to be used in VS2010 then I believe you can take a dependency on Microsoft.VisualStudio.Shell.11.0 and refer to EnvironmentColors directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. We don't support any VS version prior to 2017.
  2. I've already removed that code.
  3. We now use IClassificationFormatMapService https://github.com/Microsoft/visualfsharp/blob/master/vsintegration/src/FSharp.Editor/QuickInfoProvider.fs#L63

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@dsyme
Copy link
Contributor

dsyme commented Nov 29, 2016

@cartermp @brettfo @vasily-kirichenko I'm noticing a lot of issues where VIsual Studio seems to hang while getting QuickInfo during debugging of F# code.

I'm not sure if this is our problem, but it feels like it is. It may make sense to work out how to turn off semantic/error quick info while debugging F# code. At least we need to investigate further

@Pilchie
Copy link
Member

Pilchie commented Nov 29, 2016

Is it quick info, or determining data-tip spans? Perhaps something in that code path is sub-optimal?

@dsyme
Copy link
Contributor

dsyme commented Nov 30, 2016

@Pilchie Hard to tell. It's an outright hang of the VS IDE. I got one stack trace where the main UI thread was on roslyn code calling through to a quick info provider in a blocking wait (the word "QuickInfo" was definitely on the Roslyn call stack on the UI thread). I couldn't see any other useful stacks. I presume it was the F# provider for quick info tips. I'll try to repro and get better stack traces.

Is there a way to disable the F# Quick Info service when debugging is active if we need it?

thanks

@vasily-kirichenko
Copy link
Contributor Author

Maybe it's not related, but I think this code https://github.com/Microsoft/visualfsharp/blob/master/vsintegration/src/FSharp.Editor/QuickInfoProvider.fs#L81-L88 is too heavy weight to get qualified name island, start column of the last part of it and its TextSpan. Maybe it's possible to use something like QuickParse.GetCompleteIdentifierIsland and create a TextSpan from it somehow?

@dsyme
Copy link
Contributor

dsyme commented Nov 30, 2016

@vasily-kirichenko Hmmm... it felt more async-lock-up-the-system than that

@vasily-kirichenko
Copy link
Contributor Author

however, code is not changed during debugging, so FCS should cache everything and answer very fast. It's strange. I've not able to investigate it today, been trying to build behind the proxy.

@vasily-kirichenko
Copy link
Contributor Author

vasily-kirichenko commented Nov 30, 2016

@dsyme on a hello world console application debugger works OK for me: it does not show tooltips and it does show proper debug information (current variable values).

On VFT solution it does not work, hanging on this dialog:

image

Did you mean this behavior?

@cartermp
Copy link
Contributor

@vasily-kirichenko I've noticed that too

@Pilchie
Copy link
Member

Pilchie commented Nov 30, 2016

If it hangs forever, a dump with heap would really make investigations go a lot faster.

@vasily-kirichenko
Copy link
Contributor Author

@Pilchie it does not hang forever, sorry for misinformation. The dialog is shown until you move mouse somewhere else, after that VS is responsive until you hover the mouse over another symbol again.

@vasily-kirichenko
Copy link
Contributor Author

vasily-kirichenko commented Nov 30, 2016

I debugged it and I was wrong: IQuickInfoProvider.GetItemAsync is called in debug mode, however with no results.

@vasily-kirichenko
Copy link
Contributor Author

I make IBreakpointResolutionService no-op and it has not helped:

interface IBreakpointResolutionService with
        member this.ResolveBreakpointAsync(_document: Document, _textSpan: TextSpan, _cancellationToken: CancellationToken): Task<BreakpointResolutionResult> =
            Task.FromResult null

(I mean "Getting datatip text" dialog still hangs)

@vasily-kirichenko
Copy link
Contributor Author

I also make IQuickInfoProvider noop, too and it has not helped either:

interface IQuickInfoProvider with
        override this.GetItemAsync(_document: Document, _position: int, _cancellationToken: CancellationToken): Task<QuickInfoItem> =
            Task.FromResult null

@vasily-kirichenko
Copy link
Contributor Author

Obviously it hangs in ILanguageDebugInfoService.GetDataTipInfoAsync. I added try...with block around it and it did not help.

@dsyme
Copy link
Contributor

dsyme commented Dec 1, 2016

@vasily-kirichenko COuld you add a new bug with repro steps you are using? This seems important to fix (even though we're only seeing it in the VisualFSharp.sln right now, I presume it happens on other large solutions)

@vasily-kirichenko
Copy link
Contributor Author

@dsyme done #1915

nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Jan 26, 2022
* Implement FSharpQuickInfoProvider (by @OmarTawfik)

* extract tryClassifyAtPosition and reuse it in QuickInfoProvider

* address code review

* fix QuickInfo text span

* don't show empty tooltip

* add a QuickInfoProvider test

* QuickInfoProvider respects current theme colors

* revert problem stuff into FSharp.Compiler.fsproj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants