Fsharp: Two documents open for same source file

Created on 18 Jan 2017  路  33Comments  路  Source: dotnet/fsharp

Quite often I see two copies of the same file opened in separate tabs. It seems that the first copy appears when you double click on a file in the solution explorer, the other one - when you execute "Go to Definition" command.

Area-IDE Language Service Severity-Medium

Most helpful comment

All 33 comments

Would be good to have exact repro steps

When I've seen this in prior VS versions it's because the GoToDefinition filename was not normalized e.g. c:\abc\def\..\xyz\foo.fs

I saw this issue many times but not sure how to reproduce it.

I've noticed this as well, but can't nail down a proper repro either.

It's happening all the time. I think it started after one of @dungpa's PRs related to Workspaces (registering all projects / files on solution loading even, etc.)

So my guess: when solution is loading we register files in one way, but when a document is opening - in a slightly different way. Maybe it's the file path that is different, as @dsyme wrote.

(interesting that the very same issue has alive in Nemerle VS integration for years)

It reproduces on RC4 / master every time you execute "Go to Definition". I've debugged it and have not found anything suspicious.

@Pilchie any ideas how it's possible? We just execute IDocumentNavigationService.TryNavigateToSpan https://github.com/Microsoft/visualfsharp/blob/master/vsintegration/src/FSharp.Editor/Navigation/GoToDefinitionService.fs#L100 (I suspect I already asked you about it, but I cannot find the thread)

This is stack trace to SetupNewTextView implemented in our language service as a duplicate tab is opening:

FSharp.Editor.dll!Microsoft.VisualStudio.FSharp.Editor.FSharpLanguageService.SetupNewTextView(Microsoft.VisualStudio.TextManager.Interop.IVsTextView textView) Line 367 F#
Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService.AbstractLanguageService<Microsoft.VisualStudio.FSharp.Editor.FSharpPackage, Microsoft.VisualStudio.FSharp.Editor.FSharpLanguageService>.VsCodeWindowManager.AddAdornments()  Unknown
Microsoft.VisualStudio.Editor.Implementation.dll!Microsoft.VisualStudio.Editor.Implementation.CompoundTextViewWindow.TextDocData_OnNewLanguageService(ref System.Guid sidLangServiceID) Unknown
Microsoft.VisualStudio.Editor.Implementation.dll!Microsoft.VisualStudio.Editor.Implementation.CompoundTextViewWindow.OnPrimaryView_FullyInitialized()   Unknown
Microsoft.VisualStudio.Editor.Implementation.dll!Microsoft.VisualStudio.Editor.Implementation.CompoundTextViewWindow.PrimaryView_TextViewHostUpdated(object sender, System.EventArgs e) Unknown
Microsoft.VisualStudio.Editor.Implementation.dll!Microsoft.VisualStudio.Editor.Implementation.SimpleTextViewWindow.Init_InitializeWpfTextView() Unknown
Microsoft.VisualStudio.Editor.Implementation.dll!Microsoft.VisualStudio.Editor.Implementation.SimpleTextViewWindow.Init_OnActivation()  Unknown
Microsoft.VisualStudio.Editor.Implementation.dll!Microsoft.VisualStudio.Editor.Implementation.SimpleTextViewWindow.SetInfo()    Unknown
Microsoft.VisualStudio.Editor.Implementation.dll!Microsoft.VisualStudio.Editor.Implementation.CompoundTextViewWindow.SetInfo()  Unknown
Microsoft.VisualStudio.Shell.UI.Internal.dll!Microsoft.VisualStudio.PlatformUI.StatusBarService.OnElementValueChanged(uint elementid, object varValueOld, object varValueNew)   Unknown
[Native to Managed Transition]  
[Managed to Native Transition]  
Microsoft.VisualStudio.Platform.WindowManagement.dll!Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.ConnectSelectionContext() Unknown
Microsoft.VisualStudio.Platform.WindowManagement.dll!Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.Activate()    Unknown
Microsoft.VisualStudio.Platform.WindowManagement.dll!Microsoft.VisualStudio.Platform.WindowManagement.WindowManagerService.viewManager_ActiveViewChanged(object sender, Microsoft.VisualStudio.PlatformUI.Shell.ActiveViewChangedEventArgs e)   Unknown
Microsoft.VisualStudio.Utilities.dll!Microsoft.VisualStudio.PlatformUI.ExtensionMethods.RaiseEvent<System.__Canon>(System.EventHandler<System.__Canon> eventHandler, object source, System.__Canon args)    Unknown
Microsoft.VisualStudio.Shell.ViewManager.dll!Microsoft.VisualStudio.PlatformUI.Shell.ViewManager.SetActiveView(Microsoft.VisualStudio.PlatformUI.Shell.View view, Microsoft.VisualStudio.PlatformUI.Shell.ActivationType type)  Unknown
Microsoft.VisualStudio.Shell.ViewManager.dll!Microsoft.VisualStudio.PlatformUI.Shell.ViewManager.ActivateViewFromTabControl(System.Windows.Controls.TabControl tabControl, Microsoft.VisualStudio.PlatformUI.Shell.ActivationType type) Unknown
Microsoft.VisualStudio.Shell.ViewManager.dll!Microsoft.VisualStudio.PlatformUI.Shell.ViewManager.OnTabControlSelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs args)    Unknown
Microsoft.VisualStudio.Shell.ViewManager.dll!Microsoft.VisualStudio.PlatformUI.Shell.ViewManager..cctor.AnonymousMethod__23_27(object sender, System.Windows.Controls.SelectionChangedEventArgs args)   Unknown
PresentationFramework.dll!System.Windows.Controls.SelectionChangedEventArgs.InvokeEventHandler(System.Delegate genericHandler, object genericTarget)    Unknown
PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate handler, object target)   Unknown
PresentationCore.dll!System.Windows.RoutedEventHandlerInfo.InvokeHandler(object target, System.Windows.RoutedEventArgs routedEventArgs) Unknown
PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(object source, System.Windows.RoutedEventArgs args, bool reRaised)    Unknown
PresentationCore.dll!System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject sender, System.Windows.RoutedEventArgs args)   Unknown
PresentationCore.dll!System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs e)  Unknown
PresentationFramework.dll!System.Windows.Controls.TabControl.OnSelectionChanged(System.Windows.Controls.SelectionChangedEventArgs e)    Unknown
Microsoft.VisualStudio.Shell.15.0.dll!Microsoft.VisualStudio.PlatformUI.LayoutSynchronizedTabControl.OnSelectionChanged(System.Windows.Controls.SelectionChangedEventArgs e)    Unknown
PresentationFramework.dll!System.Windows.Controls.Primitives.Selector.InvokeSelectionChanged(System.Collections.Generic.List<System.Windows.Controls.ItemsControl.ItemInfo> unselectedInfos, System.Collections.Generic.List<System.Windows.Controls.ItemsControl.ItemInfo> selectedInfos)  Unknown
PresentationFramework.dll!System.Windows.Controls.Primitives.Selector.SelectionChanger.End()    Unknown
PresentationFramework.dll!System.Windows.Controls.Primitives.Selector.SelectionChanger.SelectJustThisItem(System.Windows.Controls.ItemsControl.ItemInfo info, bool assumeInItemsCollection) Unknown
PresentationFramework.dll!System.Windows.Controls.Primitives.Selector.OnSelectedItemChanged(System.Windows.DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e) Unknown
WindowsBase.dll!System.Windows.DependencyObject.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e)  Unknown
PresentationFramework.dll!System.Windows.FrameworkElement.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e)    Unknown
WindowsBase.dll!System.Windows.DependencyObject.NotifyPropertyChange(System.Windows.DependencyPropertyChangedEventArgs args)    Unknown
WindowsBase.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.EntryIndex entryIndex, System.Windows.DependencyProperty dp, System.Windows.PropertyMetadata metadata, System.Windows.EffectiveValueEntry oldEntry, ref System.Windows.EffectiveValueEntry newEntry, bool coerceWithDeferredReference, bool coerceWithCurrentValue, System.Windows.OperationType operationType) Unknown
WindowsBase.dll!System.Windows.DependencyObject.InvalidateProperty(System.Windows.DependencyProperty dp, bool preserveCurrentValue) Unknown
PresentationFramework.dll!System.Windows.Data.BindingExpressionBase.Invalidate(bool isASubPropertyChange)   Unknown
PresentationFramework.dll!System.Windows.Data.BindingExpression.TransferValue(object newValue, bool isASubPropertyChange)   Unknown
PresentationFramework.dll!System.Windows.Data.BindingExpression.ScheduleTransfer(bool isASubPropertyChange) Unknown
PresentationFramework.dll!MS.Internal.Data.ClrBindingWorker.NewValueAvailable(bool dependencySourcesChanged, bool initialValue, bool isASubPropertyChange)  Unknown
PresentationFramework.dll!MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(int k, System.ComponentModel.ICollectionView collectionView, object newValue, bool isASubPropertyChange)   Unknown
PresentationFramework.dll!MS.Internal.Data.PropertyPathWorker.OnDependencyPropertyChanged(System.Windows.DependencyObject d, System.Windows.DependencyProperty dp, bool isASubPropertyChange)   Unknown
PresentationFramework.dll!MS.Internal.Data.ClrBindingWorker.OnSourceInvalidation(System.Windows.DependencyObject d, System.Windows.DependencyProperty dp, bool isASubPropertyChange)    Unknown
PresentationFramework.dll!System.Windows.Data.BindingExpression.HandlePropertyInvalidation(System.Windows.DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs args)   Unknown
PresentationFramework.dll!System.Windows.Data.BindingExpressionBase.OnPropertyInvalidation(System.Windows.DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs args)   Unknown
PresentationFramework.dll!System.Windows.Data.BindingExpression.OnPropertyInvalidation(System.Windows.DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs args)   Unknown
WindowsBase.dll!System.Windows.DependentList.InvalidateDependents(System.Windows.DependencyObject source, System.Windows.DependencyPropertyChangedEventArgs sourceArgs) Unknown
WindowsBase.dll!System.Windows.DependencyObject.NotifyPropertyChange(System.Windows.DependencyPropertyChangedEventArgs args)    Unknown
WindowsBase.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.EntryIndex entryIndex, System.Windows.DependencyProperty dp, System.Windows.PropertyMetadata metadata, System.Windows.EffectiveValueEntry oldEntry, ref System.Windows.EffectiveValueEntry newEntry, bool coerceWithDeferredReference, bool coerceWithCurrentValue, System.Windows.OperationType operationType) Unknown
WindowsBase.dll!System.Windows.DependencyObject.SetValueCommon(System.Windows.DependencyProperty dp, object value, System.Windows.PropertyMetadata metadata, bool coerceWithDeferredReference, bool coerceWithCurrentValue, System.Windows.OperationType operationType, bool isInternal)    Unknown
Microsoft.VisualStudio.Shell.ViewManager.dll!Microsoft.VisualStudio.PlatformUI.Shell.ViewElement.UpdateParentSelectedElement()  Unknown
Microsoft.VisualStudio.Shell.ViewManager.dll!Microsoft.VisualStudio.PlatformUI.Shell.View.OnIsSelectedChanged() Unknown
Microsoft.VisualStudio.Shell.ViewManager.dll!Microsoft.VisualStudio.PlatformUI.Shell.ViewElement.OnIsSelectedChanged(System.Windows.DependencyObject obj, System.Windows.DependencyPropertyChangedEventArgs args)   Unknown
WindowsBase.dll!System.Windows.DependencyObject.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e)  Unknown
WindowsBase.dll!System.Windows.DependencyObject.NotifyPropertyChange(System.Windows.DependencyPropertyChangedEventArgs args)    Unknown
WindowsBase.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.EntryIndex entryIndex, System.Windows.DependencyProperty dp, System.Windows.PropertyMetadata metadata, System.Windows.EffectiveValueEntry oldEntry, ref System.Windows.EffectiveValueEntry newEntry, bool coerceWithDeferredReference, bool coerceWithCurrentValue, System.Windows.OperationType operationType) Unknown
WindowsBase.dll!System.Windows.DependencyObject.SetValueCommon(System.Windows.DependencyProperty dp, object value, System.Windows.PropertyMetadata metadata, bool coerceWithDeferredReference, bool coerceWithCurrentValue, System.Windows.OperationType operationType, bool isInternal)    Unknown
Microsoft.VisualStudio.Shell.ViewManager.dll!Microsoft.VisualStudio.PlatformUI.Shell.ViewElement.IsSelected.set(bool value) Unknown
Microsoft.VisualStudio.Platform.WindowManagement.dll!Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.ShowInternal(Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.ShowFlags showFlags)    Unknown
Microsoft.VisualStudio.Platform.WindowManagement.dll!Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.Show.AnonymousMethod__504_0() Unknown
Microsoft.VisualStudio.Shell.15.0.dll!Microsoft.VisualStudio.ErrorHandler.CallWithCOMConvention(System.Func<int> method, bool reportError, bool setShellErrorInfo)  Unknown
Microsoft.VisualStudio.Platform.WindowManagement.dll!Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.Show()    Unknown
Microsoft.VisualStudio.Platform.WindowManagement.dll!Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.MarshalingWindowFrame.Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame.Show.AnonymousMethod__12_0()    Unknown
Microsoft.VisualStudio.Shell.15.0.dll!Microsoft.VisualStudio.Shell.ThreadHelper.Invoke<int>(System.Func<int> method)    Unknown
Microsoft.VisualStudio.Platform.WindowManagement.dll!Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.MarshalingWindowFrame.Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame.Show()  Unknown
Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioWorkspaceImpl.OpenDocumentCore(Microsoft.CodeAnalysis.DocumentId documentId, bool activate)    Unknown
Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioWorkspaceImpl.OpenDocument(Microsoft.CodeAnalysis.DocumentId documentId, bool activate)    Unknown
Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.VisualStudioDocumentNavigationService.OpenDocument(Microsoft.CodeAnalysis.Workspace workspace, Microsoft.CodeAnalysis.DocumentId documentId, Microsoft.CodeAnalysis.Options.OptionSet options)   Unknown
Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.VisualStudioDocumentNavigationService.TryNavigateToSpan(Microsoft.CodeAnalysis.Workspace workspace, Microsoft.CodeAnalysis.DocumentId documentId, Microsoft.CodeAnalysis.Text.TextSpan textSpan, Microsoft.CodeAnalysis.Options.OptionSet options)   Unknown
Microsoft.CodeAnalysis.EditorFeatures.dll!Microsoft.CodeAnalysis.Editor.GoToDefinition.GoToDefinitionCommandHandler.TryExecuteCommand.AnonymousMethod__0(Microsoft.CodeAnalysis.Editor.Host.IWaitContext waitContext)   Unknown
Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.Utilities.VisualStudioWaitIndicator.Wait(string title, string message, bool allowCancel, bool showProgress, System.Action<Microsoft.CodeAnalysis.Editor.Host.IWaitContext> action)   Unknown
Microsoft.CodeAnalysis.EditorFeatures.dll!Microsoft.CodeAnalysis.Editor.GoToDefinition.GoToDefinitionCommandHandler.TryExecuteCommand(Microsoft.CodeAnalysis.Document document, int caretPosition, Microsoft.CodeAnalysis.Editor.IGoToDefinitionService goToDefinitionService)  Unknown
Microsoft.CodeAnalysis.EditorFeatures.dll!Microsoft.CodeAnalysis.Editor.GoToDefinition.GoToDefinitionCommandHandler.ExecuteCommand(Microsoft.CodeAnalysis.Editor.Commands.GoToDefinitionCommandArgs args, System.Action nextHandler)    Unknown
Microsoft.CodeAnalysis.EditorFeatures.dll!Microsoft.CodeAnalysis.Editor.Implementation.Commands.CommandHandlerService.ExecuteHandlers<Microsoft.CodeAnalysis.Editor.Commands.GoToDefinitionCommandArgs>(System.Collections.Generic.IList<Microsoft.CodeAnalysis.Editor.ICommandHandler<Microsoft.CodeAnalysis.Editor.Commands.GoToDefinitionCommandArgs>> commandHandlers, Microsoft.CodeAnalysis.Editor.Commands.GoToDefinitionCommandArgs args, System.Action lastHandler)    Unknown
Microsoft.CodeAnalysis.EditorFeatures.dll!Microsoft.CodeAnalysis.Editor.Implementation.Commands.CommandHandlerService.Execute<Microsoft.CodeAnalysis.Editor.Commands.GoToDefinitionCommandArgs>(Microsoft.VisualStudio.Utilities.IContentType contentType, Microsoft.CodeAnalysis.Editor.Commands.GoToDefinitionCommandArgs args, System.Action lastHandler)    Unknown
Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.AbstractOleCommandTarget.ExecuteGoToDefinition(Microsoft.VisualStudio.Text.ITextBuffer subjectBuffer, Microsoft.VisualStudio.Utilities.IContentType contentType, System.Action executeNextCommandTarget) Unknown
Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.AbstractOleCommandTarget.ExecuteVisualStudio97(ref System.Guid pguidCmdGroup, uint commandId, uint executeInformation, System.IntPtr pvaIn, System.IntPtr pvaOut, Microsoft.VisualStudio.Text.ITextBuffer subjectBuffer, Microsoft.VisualStudio.Utilities.IContentType contentType)  Unknown
Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.AbstractOleCommandTarget.Exec(ref System.Guid pguidCmdGroup, uint commandId, uint executeInformation, System.IntPtr pvaIn, System.IntPtr pvaOut) Unknown
Microsoft.VisualStudio.Editor.Implementation.dll!Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.InnerExec(ref System.Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, System.IntPtr pvaIn, System.IntPtr pvaOut)   Unknown
Microsoft.VisualStudio.Editor.Implementation.dll!Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.InnerExec(ref System.Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, System.IntPtr pvaIn, System.IntPtr pvaOut)   Unknown
Microsoft.VisualStudio.Editor.Implementation.dll!Microsoft.VisualStudio.Editor.Implementation.SimpleTextViewWindow.Exec(ref System.Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, System.IntPtr pvaIn, System.IntPtr pvaOut)    Unknown
Microsoft.VisualStudio.Editor.Implementation.dll!Microsoft.VisualStudio.Editor.Implementation.CompoundTextViewWindow.Exec(ref System.Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, System.IntPtr pvaIn, System.IntPtr pvaOut)  Unknown
Microsoft.VisualStudio.Platform.WindowManagement.dll!Microsoft.VisualStudio.Platform.WindowManagement.DocumentObjectSite.Exec(ref System.Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, System.IntPtr pvaIn, System.IntPtr pvaOut)  Unknown
Microsoft.VisualStudio.Platform.WindowManagement.dll!Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.Exec(ref System.Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, System.IntPtr pvaIn, System.IntPtr pvaOut) Unknown

@vasily-kirichenko shouldn't there be a DocumentId for the target span? then the workspace can be queried using the id to see which Documents are currently open and then you can navigate to the corresponding textbuffer instead of creating a new one.

@cloudRoutine all these are done by Roslyn. I just call navigate to document id, span.

I just noticed it on RC4 as well, and could repro. My project had these files:

File1.fs

module File1

module Squares =
    let square x = x * x

Program.fs

// Learn more about F# at http://fsharp.org
// See the 'F# Tutorial' project for more help.

open File1
open File1.Squares

[<EntryPoint>]
let main argv = 
    (square 12) |> ignore
    0 // return an integer exit code

Go to Definition on square in Program.fs will repro this issue:

gotodef-dup

It reproduces even on single Program.fs, just F12 on argv.

Strangely that didn't repro for me...but either way, definitely a bug here.

1

One of the views is "tied" to solution explorer, and the other - to Roslyn.

Yes, this is the case:

1

Maybe it's a bug in our integration with solution explorer rather than with Roslyn?

Ohh. Maybe it's a direct effect of the fact that having our project system is not Roslyn based, we "plug" projects into Roslyn?

That shouldn't be it. We don't use the "roslyn-project-system" for most C#/VB projects either, only the new .NET Core ones. This is likely an issue with the F# project system integration (or the MPF code that it derives from), where it doesn't recognize the existing opened document when Roslyn calls OpenDocumentViaProject via OpenDocumentCore above.

Try setting a breakpoint in CreateEditorInstance, and looking at the stacks there.

@Pilchie

Sharp.ProjectSystem.Base.dll!Microsoft.VisualStudio.FSharp.ProjectSystem.FSharpEditorFactory.CreateEditorInstance(uint grfCreateDoc, string pszMkDocument, string pszPhysicalView, Microsoft.VisualStudio.Shell.Interop.IVsHierarchy pvHier, uint itemid, System.IntPtr punkDocDataExisting, out System.IntPtr ppunkDocView, out System.IntPtr ppunkDocData, out string pbstrEditorCaption, out System.Guid pguidCmdUI, out int pgrfCDW) Line 61    C#
[Native to Managed Transition]  
[Managed to Native Transition]  
FSharp.ProjectSystem.Base.dll!Microsoft.VisualStudio.FSharp.ProjectSystem.FileDocumentManager.Open(bool newFile, bool openWith, uint editorFlags, ref System.Guid editorType, string physicalView, ref System.Guid logicalView, System.IntPtr docDataExisting, out Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame windowFrame, Microsoft.VisualStudio.FSharp.ProjectSystem.WindowFrameShowAction windowFrameAction) Line 211   C#
FSharp.ProjectSystem.Base.dll!Microsoft.VisualStudio.FSharp.ProjectSystem.FileDocumentManager.Open(bool newFile, bool openWith, ref System.Guid logicalView, System.IntPtr docDataExisting, out Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame windowFrame, Microsoft.VisualStudio.FSharp.ProjectSystem.WindowFrameShowAction windowFrameAction) Line 151  C#
FSharp.ProjectSystem.Base.dll!Microsoft.VisualStudio.FSharp.ProjectSystem.FileDocumentManager.Open(bool newFile, bool openWith, System.Guid logicalView, System.Guid fallbackLogicalView, out Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame frame, Microsoft.VisualStudio.FSharp.ProjectSystem.WindowFrameShowAction windowFrameAction) Line 115  C#
FSharp.ProjectSystem.FSharp.dll!Microsoft.VisualStudio.FSharp.ProjectSystem.FSharpFileNode.DoDefaultAction() Line 2173  F#
FSharp.ProjectSystem.Base.dll!Microsoft.VisualStudio.FSharp.ProjectSystem.HierarchyNode.ExecCommandOnNode(System.Guid cmdGroup, uint cmd, uint nCmdexecopt, System.IntPtr pvaIn, System.IntPtr pvaOut) Line 1393    C#
FSharp.ProjectSystem.Base.dll!Microsoft.VisualStudio.FSharp.ProjectSystem.FileNode.ExecCommandOnNode(System.Guid cmdGroup, uint cmd, uint nCmdexecopt, System.IntPtr pvaIn, System.IntPtr pvaOut) Line 482  C#
FSharp.ProjectSystem.FSharp.dll!Microsoft.VisualStudio.FSharp.ProjectSystem.FSharpFileNode.ExecCommandOnNode(System.Guid guidCmdGroup, uint cmd, uint nCmdexecopt, System.IntPtr pvaIn, System.IntPtr pvaOut) Line 2300 F#
FSharp.ProjectSystem.Base.dll!Microsoft.VisualStudio.FSharp.ProjectSystem.HierarchyNode.InternalExecCommand(System.Guid cmdGroup, uint cmdId, uint cmdExecOpt, System.IntPtr vaIn, System.IntPtr vaOut, Microsoft.VisualStudio.FSharp.ProjectSystem.CommandOrigin commandOrigin) Line 1614  C#
FSharp.ProjectSystem.Base.dll!Microsoft.VisualStudio.FSharp.ProjectSystem.HierarchyNode.ExecCommand(uint itemId, ref System.Guid guidCmdGroup, uint nCmdId, uint nCmdExecOpt, System.IntPtr pvain, System.IntPtr p) Line 2679   C#
[Native to Managed Transition]  
[Managed to Native Transition]  
Microsoft.VisualStudio.Shell.15.0.dll!Microsoft.Internal.VisualStudio.PlatformUI.HierarchyUtilities.ExecHierParentChain.AnonymousMethod__1()    Unknown
Microsoft.VisualStudio.Shell.15.0.dll!Microsoft.VisualStudio.ErrorHandler.CallWithCOMConvention(System.Func<int> method, bool reportError, bool setShellErrorInfo)  Unknown
Microsoft.VisualStudio.Shell.15.0.dll!Microsoft.Internal.VisualStudio.PlatformUI.HierarchyUtilities.ExecHierParentChain(Microsoft.VisualStudio.Shell.IVsHierarchyItemManager manager, Microsoft.VisualStudio.Shell.Interop.IVsUIHierarchy lpUIHCmd, Microsoft.VisualStudio.Shell.Interop.IVsUIHierarchy lpUIHCurrent, uint itemidCurrent, ref System.Guid pguidCmdGroupRef, uint nCmdID, uint nCmdexecopt, System.IntPtr pvaIn, System.IntPtr pvaOut)   Unknown
Microsoft.VisualStudio.Shell.TreeNavigation.HierarchyProvider.dll!Microsoft.VisualStudio.PlatformUI.HierarchyItem.HierarchyInvocationController.Invoke(System.Collections.Generic.IEnumerable<object> items, Microsoft.Internal.VisualStudio.PlatformUI.InputSource inputSource, bool preview)  Unknown
Microsoft.VisualStudio.Shell.15.0.dll!Microsoft.Internal.VisualStudio.PlatformUI.InvocationController.Invoke(System.Collections.Generic.IEnumerable<Microsoft.Internal.VisualStudio.PlatformUI.IInvocationPattern> items, Microsoft.Internal.VisualStudio.PlatformUI.InputSource inputSource, bool preview, System.Func<Microsoft.Internal.VisualStudio.PlatformUI.IInvocationPattern, Microsoft.Internal.VisualStudio.PlatformUI.IInvocationController> getController) Unknown
Microsoft.VisualStudio.Shell.15.0.dll!Microsoft.Internal.VisualStudio.PlatformUI.InvocationController.Invoke(System.Collections.Generic.IEnumerable<Microsoft.Internal.VisualStudio.PlatformUI.IInvocationPattern> items, Microsoft.Internal.VisualStudio.PlatformUI.InputSource inputSource, bool preview) Unknown
Microsoft.VisualStudio.Shell.15.0.dll!Microsoft.Internal.VisualStudio.PlatformUI.PivotTreeViewItem.InvokeItem(System.Windows.Input.InputDevice sourceDevice)    Unknown
Microsoft.VisualStudio.Shell.15.0.dll!Microsoft.Internal.VisualStudio.PlatformUI.PivotTreeViewItem.OnMouseLeftButtonDown(System.Windows.Input.MouseButtonEventArgs e)   Unknown
PresentationCore.dll!System.Windows.UIElement.OnMouseLeftButtonDownThunk(object sender, System.Windows.Input.MouseButtonEventArgs e)    Unknown
PresentationCore.dll!System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(System.Delegate genericHandler, object genericTarget) Unknown
PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate handler, object target)   Unknown
PresentationCore.dll!System.Windows.RoutedEventHandlerInfo.InvokeHandler(object target, System.Windows.RoutedEventArgs routedEventArgs) Unknown
PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(object source, System.Windows.RoutedEventArgs args, bool reRaised)    Unknown
PresentationCore.dll!System.Windows.UIElement.ReRaiseEventAs(System.Windows.DependencyObject sender, System.Windows.RoutedEventArgs args, System.Windows.RoutedEvent newEvent)  Unknown
PresentationCore.dll!System.Windows.UIElement.OnMouseDownThunk(object sender, System.Windows.Input.MouseButtonEventArgs e)  Unknown
PresentationCore.dll!System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(System.Delegate genericHandler, object genericTarget) Unknown
PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate handler, object target)   Unknown
PresentationCore.dll!System.Windows.RoutedEventHandlerInfo.InvokeHandler(object target, System.Windows.RoutedEventArgs routedEventArgs) Unknown
PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(object source, System.Windows.RoutedEventArgs args, bool reRaised)    Unknown
PresentationCore.dll!System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject sender, System.Windows.RoutedEventArgs args)   Unknown
PresentationCore.dll!System.Windows.UIElement.RaiseTrustedEvent(System.Windows.RoutedEventArgs args)    Unknown
PresentationCore.dll!System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs args, bool trusted) Unknown
PresentationCore.dll!System.Windows.Input.InputManager.ProcessStagingArea() Unknown
PresentationCore.dll!System.Windows.Input.InputManager.ProcessInput(System.Windows.Input.InputEventArgs input)  Unknown
PresentationCore.dll!System.Windows.Input.InputProviderSite.ReportInput(System.Windows.Input.InputReport inputReport)   Unknown
PresentationCore.dll!System.Windows.Interop.HwndMouseInputProvider.ReportInput(System.IntPtr hwnd, System.Windows.Input.InputMode mode, int timestamp, System.Windows.Input.RawMouseActions actions, int x, int y, int wheel)   Unknown
PresentationCore.dll!System.Windows.Interop.HwndMouseInputProvider.FilterMessage(System.IntPtr hwnd, MS.Internal.Interop.WindowMessage msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled)   Unknown
PresentationCore.dll!System.Windows.Interop.HwndSource.InputFilterMessage(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled)    Unknown
WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) Unknown
WindowsBase.dll!MS.Win32.HwndSubclass.DispatcherCallbackOperation(object o) Unknown
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs)  Unknown
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source, System.Delegate callback, object args, int numArgs, System.Delegate catchHandler) Unknown
WindowsBase.dll!System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, int numArgs)   Unknown
WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam)  Unknown

It's called when I click on a file in Solution Explorer only. It's not called when I execute Go to definition.

Maybe we should register the opened document in Roslyn somehow?

It's not about Roslyn knowing about it. It's about the F# project system knowing about it.

So, I would set breakpoints back up through FSharp.ProjectSystem.Base.dll!Microsoft.VisualStudio.FSharp.ProjectSystem.FileDocumentManager.Open and see if that is being called, and what is different.

Open by clicking on a file in Solution Explorer:

image

Go to definition:

image

Looks like logicalView is different only. What it's for?

From https://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.ivsuishellopendocument.openstandardeditor.aspx:

guidLogicalView
Type: System.Guid
[in] GUID identifying the logical view. If the editor implements IVsMultiViewDocumentView on the document view object, then the value passed into the rguidLogicalView parameter determines which view is activated when the editor window is shown. By specifying the logical view GUID, you can request the specific view that matches the reason you are requesting the view. For example, specify LOGVIEWID_Debugging to get the view appropriate for debugging, or LOGVIEWID_TextView to get the view appropriate for the text editor (that is, a view that implements IVsCodeWindow).

In my experience, the main use of this is to decide whether to open the designer or the code editor for files that are winforms/controls/components/etc. However, it looks like docDataExisting is also different, and probably important...

For completeness, these are the arguments passed to Open.

click on solution explorer:

image

go to definition

image

What happens in OpenItem in the Go To Definition case? I would expect it to come in with docDataExisting being a valid pointer in the case where the file is already open.

image

image

Looks like someone ( @KevinRansom or @brettfo ), needs to dig in to what is happening in the native code between Roslyn and F# here. I would expect punkDocDataExisting to come in with the existing opened document in this case.

I see. Thanks for the help!

@vasily-kirichenko please close

Love it

Was this page helpful?
0 / 5 - 0 ratings