From c34c08a86afe6996b0551880d56001613533a387 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Fri, 30 Jun 2017 18:50:23 -0500 Subject: [PATCH 01/77] Use IVsUIShell instead of DTE to open the Options dialog Fixes cases where an IOleCommandTarget in the chain fails to propagate the call in a manner that allows arguments, which would crash Visual Studio with a COMException. --- .../PreviewPane/PreviewPane.xaml.cs | 15 ++++++++++----- .../PreviewPane/PreviewPaneService.cs | 10 ++++++---- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/VisualStudio/Core/Def/Implementation/PreviewPane/PreviewPane.xaml.cs b/src/VisualStudio/Core/Def/Implementation/PreviewPane/PreviewPane.xaml.cs index dc03925fe1eb4..ff2ccf4c83359 100644 --- a/src/VisualStudio/Core/Def/Implementation/PreviewPane/PreviewPane.xaml.cs +++ b/src/VisualStudio/Core/Def/Implementation/PreviewPane/PreviewPane.xaml.cs @@ -7,11 +7,12 @@ using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Navigation; -using EnvDTE; using Microsoft.CodeAnalysis.Diagnostics.Log; using Microsoft.VisualStudio.LanguageServices.Implementation.Utilities; using Roslyn.Utilities; using Microsoft.CodeAnalysis.Editor.Implementation.Preview; +using IVsUIShell = Microsoft.VisualStudio.Shell.Interop.IVsUIShell; +using OLECMDEXECOPT = Microsoft.VisualStudio.OLE.Interop.OLECMDEXECOPT; namespace Microsoft.VisualStudio.LanguageServices.Implementation.PreviewPane { @@ -24,7 +25,7 @@ internal partial class PreviewPane : UserControl, IDisposable private readonly string _id; private readonly bool _logIdVerbatimInTelemetry; - private readonly DTE _dte; + private readonly IVsUIShell _uiShell; private bool _isExpanded; private double _heightForThreeLineTitle; @@ -39,14 +40,14 @@ internal partial class PreviewPane : UserControl, IDisposable string helpLinkToolTipText, IReadOnlyList previewContent, bool logIdVerbatimInTelemetry, - DTE dte, + IVsUIShell uiShell, Guid optionPageGuid = default(Guid)) { InitializeComponent(); _id = id; _logIdVerbatimInTelemetry = logIdVerbatimInTelemetry; - _dte = dte; + _uiShell = uiShell; // Initialize header portion. if ((severityIcon != null) && !string.IsNullOrWhiteSpace(id) && !string.IsNullOrWhiteSpace(title)) @@ -358,7 +359,11 @@ private void OptionsButton_Click(object sender, RoutedEventArgs e) { if (_optionPageGuid != default(Guid)) { - _dte.ExecuteCommand("Tools.Options", _optionPageGuid.ToString()); + ErrorHandler.ThrowOnFailure(_uiShell.PostExecCommand( + VSConstants.GUID_VSStandardCommandSet97, + (uint)VSConstants.VSStd97CmdID.ToolsOptions, + (uint)OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT, + _optionPageGuid.ToString())); } } } diff --git a/src/VisualStudio/Core/Def/Implementation/PreviewPane/PreviewPaneService.cs b/src/VisualStudio/Core/Def/Implementation/PreviewPane/PreviewPaneService.cs index ea765534c4c91..5add7a32d0f27 100644 --- a/src/VisualStudio/Core/Def/Implementation/PreviewPane/PreviewPaneService.cs +++ b/src/VisualStudio/Core/Def/Implementation/PreviewPane/PreviewPaneService.cs @@ -18,18 +18,20 @@ using Microsoft.VisualStudio.Imaging.Interop; using Microsoft.VisualStudio.LanguageServices.Implementation.Utilities; using Microsoft.VisualStudio.Shell; +using IVsUIShell = Microsoft.VisualStudio.Shell.Interop.IVsUIShell; +using SVsUIShell = Microsoft.VisualStudio.Shell.Interop.SVsUIShell; namespace Microsoft.VisualStudio.LanguageServices.Implementation.PreviewPane { [ExportWorkspaceServiceFactory(typeof(IPreviewPaneService), ServiceLayer.Host), Shared] internal class PreviewPaneService : ForegroundThreadAffinitizedObject, IPreviewPaneService, IWorkspaceServiceFactory { - private readonly EnvDTE.DTE _dte; + private readonly IVsUIShell _uiShell; [ImportingConstructor] public PreviewPaneService(SVsServiceProvider serviceProvider) { - _dte = serviceProvider.GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE; + _uiShell = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell; } IWorkspaceService IWorkspaceServiceFactory.CreateService(HostWorkspaceServices workspaceServices) @@ -107,7 +109,7 @@ private static Uri GetHelpLink(DiagnosticData diagnostic, string language, strin return new PreviewPane( severityIcon: null, id: null, title: null, description: null, helpLink: null, helpLinkToolTipText: null, - previewContent: previewContent, logIdVerbatimInTelemetry: false, dte: _dte); + previewContent: previewContent, logIdVerbatimInTelemetry: false, uiShell: _uiShell); } var helpLinkToolTipText = string.Empty; @@ -128,7 +130,7 @@ private static Uri GetHelpLink(DiagnosticData diagnostic, string language, strin helpLinkToolTipText: helpLinkToolTipText, previewContent: previewContent, logIdVerbatimInTelemetry: diagnostic.CustomTags.Contains(WellKnownDiagnosticTags.Telemetry), - dte: _dte, + uiShell: _uiShell, optionPageGuid: optionPageGuid); } From d198918eec4deba9a5d264eae1c547b88eb3bb48 Mon Sep 17 00:00:00 2001 From: Jonathon Marolf Date: Tue, 25 Jul 2017 20:31:03 -0700 Subject: [PATCH 02/77] update roslyn version --- build/Targets/Versions.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/Targets/Versions.props b/build/Targets/Versions.props index 21d63c7d200b0..4d946c2949b5e 100644 --- a/build/Targets/Versions.props +++ b/build/Targets/Versions.props @@ -9,9 +9,9 @@ - 2.3.0 + 2.4.0 - 2.3.2 + 2.4.0 dev From d270313c46d242eb585ae9304763274d96df6537 Mon Sep 17 00:00:00 2001 From: Jonathon Marolf Date: Tue, 25 Jul 2017 20:36:16 -0700 Subject: [PATCH 03/77] adding branch to publish list --- src/Tools/MicroBuild/publish-assets.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tools/MicroBuild/publish-assets.ps1 b/src/Tools/MicroBuild/publish-assets.ps1 index 3172e22919234..2db2388c7aa96 100644 --- a/src/Tools/MicroBuild/publish-assets.ps1 +++ b/src/Tools/MicroBuild/publish-assets.ps1 @@ -37,7 +37,7 @@ try switch ($branchName) { - "dev15.3.x" { } + "dev15.4.x" { } "master" { } default { From 1e6e3fb3a27374c7b4f877d7e97faa385b63aee4 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Tue, 25 Jul 2017 16:57:45 -0700 Subject: [PATCH 04/77] Handle navigation to a doc ID without a corresponding doc --- .../ProjectSystem/VisualStudioWorkspaceImpl.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs index d27587ad0e88b..36d7a9d200bba 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs @@ -997,6 +997,12 @@ internal override DocumentId GetDocumentIdInCurrentContext(DocumentId documentId } var hostDocument = GetHostDocument(documentId); + if (hostDocument == null) + { + // This can happen if the document was temporary and has since been closed/deleted. + return base.GetDocumentIdInCurrentContext(documentId); + } + var itemId = hostDocument.GetItemId(); if (itemId == (uint)VSConstants.VSITEMID.Nil) { From e47543b238cd0adf8ed146aedf25ff48f76482ec Mon Sep 17 00:00:00 2001 From: Ravi Chande Date: Mon, 24 Apr 2017 15:01:37 -0700 Subject: [PATCH 05/77] Implement INavigableSymbols Breaks the internal GTD infrastructure into seperate symbols for determining the navigable symbol at the caret position and performing the navigation. --- build/Defaults/Net460/app.config | 2 +- build/Defaults/Net462/app.config | 2 +- build/Targets/Packages.props | 71 ++++++++--------- .../Extension/CompilerExtension.csproj | 3 + .../CSharp/CSharpEditorFeatures.csproj | 2 + .../CSharpGoToDefinitionItemService.cs | 16 ++++ .../CSharpGoToDefinitionService.cs | 5 -- .../CSharpGoToDefinitionSymbolService.cs | 20 +++++ src/EditorFeatures/Core/EditorFeatures.csproj | 6 ++ .../AbstractGoToDefinitionItemService.cs | 48 ++++++++++++ .../AbstractGoToDefinitionService.cs | 33 +------- .../AbstractGoToDefinitionSymbolService.cs | 35 +++++++++ .../GoToDefinition/GoToDefinitionContext.cs | 43 +++++++++++ .../GoToDefinition/GoToDefinitionHelpers.cs | 43 +++++++++-- .../IGoToDefinitionSymbolService.cs | 14 ++++ .../Core/GoToDefinition/IGoToSymbolService.cs | 18 +++++ .../WellKnownDefinitionTypes.cs | 10 +++ .../NavigableSymbolService.NavigableSymbol.cs | 61 +++++++++++++++ ...ableSymbolService.NavigableSymbolSource.cs | 76 +++++++++++++++++++ .../NavigableSymbolService.cs | 39 ++++++++++ ...ntUncommentSelectionCommandHandlerTests.cs | 4 +- .../Test/Utilities/PatternMatcherTests.cs | 4 +- .../NavigableSymbols/NavigableSymbolsTest.vb | 73 ++++++++++++++++++ .../TextEditorFactoryExtensions.cs | 12 ++- .../Workspaces/TestHostDocument.cs | 19 ++++- .../ServicesTestUtilities2.vbproj | 1 + .../Utilities/GoToHelpers/GoToTestHelpers.vb | 6 +- .../VisualBasic/BasicEditorFeatures.vbproj | 2 + .../VisualBasicGoToDefinitionItemService.vb | 11 +++ .../VisualBasicGoToDefinitionService.vb | 4 - .../VisualBasicGoToDefinitionSymbolService.vb | 18 +++++ .../Core/Def/ServicesVisualStudio.csproj | 3 + .../Next/ServicesVisualStudio.Next.csproj | 6 ++ .../Extensions/SemanticModelExtensions.cs | 10 ++- 34 files changed, 625 insertions(+), 95 deletions(-) create mode 100644 src/EditorFeatures/CSharp/GoToDefinition/CSharpGoToDefinitionItemService.cs create mode 100644 src/EditorFeatures/CSharp/GoToDefinition/CSharpGoToDefinitionSymbolService.cs create mode 100644 src/EditorFeatures/Core/GoToDefinition/AbstractGoToDefinitionItemService.cs create mode 100644 src/EditorFeatures/Core/GoToDefinition/AbstractGoToDefinitionSymbolService.cs create mode 100644 src/EditorFeatures/Core/GoToDefinition/GoToDefinitionContext.cs create mode 100644 src/EditorFeatures/Core/GoToDefinition/IGoToDefinitionSymbolService.cs create mode 100644 src/EditorFeatures/Core/GoToDefinition/IGoToSymbolService.cs create mode 100644 src/EditorFeatures/Core/GoToDefinition/WellKnownDefinitionTypes.cs create mode 100644 src/EditorFeatures/Core/NavigableSymbols/NavigableSymbolService.NavigableSymbol.cs create mode 100644 src/EditorFeatures/Core/NavigableSymbols/NavigableSymbolService.NavigableSymbolSource.cs create mode 100644 src/EditorFeatures/Core/NavigableSymbols/NavigableSymbolService.cs create mode 100644 src/EditorFeatures/Test2/NavigableSymbols/NavigableSymbolsTest.vb create mode 100644 src/EditorFeatures/VisualBasic/GoToDefinition/VisualBasicGoToDefinitionItemService.vb create mode 100644 src/EditorFeatures/VisualBasic/GoToDefinition/VisualBasicGoToDefinitionSymbolService.vb diff --git a/build/Defaults/Net460/app.config b/build/Defaults/Net460/app.config index 8db45c0c5c11b..5194a2fa0a970 100644 --- a/build/Defaults/Net460/app.config +++ b/build/Defaults/Net460/app.config @@ -75,7 +75,7 @@ - +