From 0b0a068c04b774ce18b708a082670fc78751dd79 Mon Sep 17 00:00:00 2001 From: Nat Ayewah Date: Tue, 22 Aug 2017 13:21:21 -0700 Subject: [PATCH 1/3] Keep PreviewPaneService.cs This reverts commit 64b95c625a5b98bd5517ea51811c4f302a7ed239. --- .../Implementation/PreviewPane/PreviewPaneService.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 @@ object IPreviewPaneService.GetPreviewPane( 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 @@ object IPreviewPaneService.GetPreviewPane( helpLinkToolTipText: helpLinkToolTipText, previewContent: previewContent, logIdVerbatimInTelemetry: diagnostic.CustomTags.Contains(WellKnownDiagnosticTags.Telemetry), - dte: _dte, + uiShell: _uiShell, optionPageGuid: optionPageGuid); } From 6dedf003be6ce4855a38ef1290f27f63dad7f682 Mon Sep 17 00:00:00 2001 From: Nat Ayewah Date: Tue, 22 Aug 2017 13:24:09 -0700 Subject: [PATCH 2/3] Keep TaskExtensions.cs changes --- .../Core/Portable/Utilities/TaskExtensions.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Workspaces/Core/Portable/Utilities/TaskExtensions.cs b/src/Workspaces/Core/Portable/Utilities/TaskExtensions.cs index 2f1c4287eb833..5d027fd410976 100644 --- a/src/Workspaces/Core/Portable/Utilities/TaskExtensions.cs +++ b/src/Workspaces/Core/Portable/Utilities/TaskExtensions.cs @@ -90,6 +90,8 @@ public static Task SafeContinueWith( TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { + Contract.ThrowIfNull(continuationAction, nameof(continuationAction)); + Func continuationFunction = antecedent => { continuationAction(antecedent); @@ -116,6 +118,8 @@ public static Task SafeContinueWith( TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { + Contract.ThrowIfNull(continuationFunction, nameof(continuationFunction)); + return task.SafeContinueWith( (Task antecedent) => continuationFunction((Task)antecedent), cancellationToken, continuationOptions, scheduler); } @@ -127,6 +131,8 @@ public static Task SafeContinueWith( TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { + Contract.ThrowIfNull(continuationAction, nameof(continuationAction)); + return task.SafeContinueWith( (Task antecedent) => continuationAction((Task)antecedent), cancellationToken, continuationOptions, scheduler); } @@ -156,6 +162,8 @@ public static Task SafeContinueWith( // We do not want this, so we pass the LazyCancellation flag to the TPL which implements // the behavior we want. + Contract.ThrowIfNull(continuationFunction, nameof(continuationFunction)); + Func outerFunction = t => { try @@ -223,6 +231,8 @@ public static Task ContinueWithAfterDelay( TaskContinuationOptions taskContinuationOptions, TaskScheduler scheduler) { + Contract.ThrowIfNull(continuationFunction, nameof(continuationFunction)); + return task.SafeContinueWith(t => Task.Delay(millisecondsDelay, cancellationToken).SafeContinueWith( _ => continuationFunction(t), cancellationToken, TaskContinuationOptions.None, scheduler), @@ -237,6 +247,8 @@ public static Task ContinueWithAfterDelay( TaskContinuationOptions taskContinuationOptions, TaskScheduler scheduler) { + Contract.ThrowIfNull(continuationFunction, nameof(continuationFunction)); + return task.SafeContinueWith(t => Task.Delay(millisecondsDelay, cancellationToken).SafeContinueWith( _ => continuationFunction(t), cancellationToken, TaskContinuationOptions.None, scheduler), @@ -251,6 +263,8 @@ public static Task ContinueWithAfterDelay( TaskContinuationOptions taskContinuationOptions, TaskScheduler scheduler) { + Contract.ThrowIfNull(continuationAction, nameof(continuationAction)); + return task.SafeContinueWith(t => Task.Delay(millisecondsDelay, cancellationToken).SafeContinueWith( _ => continuationAction(), cancellationToken, TaskContinuationOptions.None, scheduler), @@ -264,6 +278,8 @@ public static Task SafeContinueWithFromAsync( TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { + Contract.ThrowIfNull(continuationFunction, nameof(continuationFunction)); + return task.SafeContinueWithFromAsync( (Task antecedent) => continuationFunction((Task)antecedent), cancellationToken, continuationOptions, scheduler); } @@ -350,6 +366,8 @@ public static Task ContinueWithAfterDelayFromAsync( TaskContinuationOptions taskContinuationOptions, TaskScheduler scheduler) { + Contract.ThrowIfNull(continuationFunction, nameof(continuationFunction)); + return task.SafeContinueWith(t => Task.Delay(millisecondsDelay, cancellationToken).SafeContinueWithFromAsync( _ => continuationFunction(t), cancellationToken, TaskContinuationOptions.None, scheduler), @@ -364,6 +382,8 @@ public static Task ContinueWithAfterDelayFromAsync( TaskContinuationOptions taskContinuationOptions, TaskScheduler scheduler) { + Contract.ThrowIfNull(continuationFunction, nameof(continuationFunction)); + return task.SafeContinueWith(t => Task.Delay(millisecondsDelay, cancellationToken).SafeContinueWithFromAsync( _ => continuationFunction(t), cancellationToken, TaskContinuationOptions.None, scheduler), From 0cad0ba7391ec7fabece82db730b1bf26b5873a3 Mon Sep 17 00:00:00 2001 From: Ravi Chande Date: Wed, 23 Aug 2017 14:03:30 -0700 Subject: [PATCH 3/3] Revert "Revert "Merge pull request #20592 from sharwell/fix-options-page"" This reverts commit 64b95c625a5b98bd5517ea51811c4f302a7ed239. --- .../PreviewPane/PreviewPane.xaml.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 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 @@ public PreviewPane( 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())); } } }