Skip to content

Commit

Permalink
Merge pull request #21703 from rchande/restoreChanges
Browse files Browse the repository at this point in the history
Restore changes intended for 15.4 P2
  • Loading branch information
natidea authored Aug 24, 2017
2 parents a194462 + 0cad0ba commit 46e6634
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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;
Expand All @@ -39,14 +40,14 @@ public PreviewPane(
string helpLinkToolTipText,
IReadOnlyList<object> 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))
Expand Down Expand Up @@ -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()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand All @@ -128,7 +130,7 @@ object IPreviewPaneService.GetPreviewPane(
helpLinkToolTipText: helpLinkToolTipText,
previewContent: previewContent,
logIdVerbatimInTelemetry: diagnostic.CustomTags.Contains(WellKnownDiagnosticTags.Telemetry),
dte: _dte,
uiShell: _uiShell,
optionPageGuid: optionPageGuid);
}

Expand Down
20 changes: 20 additions & 0 deletions src/Workspaces/Core/Portable/Utilities/TaskExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ public static Task SafeContinueWith(
TaskContinuationOptions continuationOptions,
TaskScheduler scheduler)
{
Contract.ThrowIfNull(continuationAction, nameof(continuationAction));

Func<Task, bool> continuationFunction = antecedent =>
{
continuationAction(antecedent);
Expand All @@ -116,6 +118,8 @@ public static Task<TResult> SafeContinueWith<TInput, TResult>(
TaskContinuationOptions continuationOptions,
TaskScheduler scheduler)
{
Contract.ThrowIfNull(continuationFunction, nameof(continuationFunction));

return task.SafeContinueWith<TResult>(
(Task antecedent) => continuationFunction((Task<TInput>)antecedent), cancellationToken, continuationOptions, scheduler);
}
Expand All @@ -127,6 +131,8 @@ public static Task SafeContinueWith<TInput>(
TaskContinuationOptions continuationOptions,
TaskScheduler scheduler)
{
Contract.ThrowIfNull(continuationAction, nameof(continuationAction));

return task.SafeContinueWith(
(Task antecedent) => continuationAction((Task<TInput>)antecedent), cancellationToken, continuationOptions, scheduler);
}
Expand Down Expand Up @@ -156,6 +162,8 @@ public static Task<TResult> SafeContinueWith<TResult>(
// 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<Task, TResult> outerFunction = t =>
{
try
Expand Down Expand Up @@ -223,6 +231,8 @@ public static Task<TResult> ContinueWithAfterDelay<TInput, TResult>(
TaskContinuationOptions taskContinuationOptions,
TaskScheduler scheduler)
{
Contract.ThrowIfNull(continuationFunction, nameof(continuationFunction));

return task.SafeContinueWith(t =>
Task.Delay(millisecondsDelay, cancellationToken).SafeContinueWith(
_ => continuationFunction(t), cancellationToken, TaskContinuationOptions.None, scheduler),
Expand All @@ -237,6 +247,8 @@ public static Task<TNResult> ContinueWithAfterDelay<TNResult>(
TaskContinuationOptions taskContinuationOptions,
TaskScheduler scheduler)
{
Contract.ThrowIfNull(continuationFunction, nameof(continuationFunction));

return task.SafeContinueWith(t =>
Task.Delay(millisecondsDelay, cancellationToken).SafeContinueWith(
_ => continuationFunction(t), cancellationToken, TaskContinuationOptions.None, scheduler),
Expand All @@ -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),
Expand All @@ -264,6 +278,8 @@ public static Task<TResult> SafeContinueWithFromAsync<TInput, TResult>(
TaskContinuationOptions continuationOptions,
TaskScheduler scheduler)
{
Contract.ThrowIfNull(continuationFunction, nameof(continuationFunction));

return task.SafeContinueWithFromAsync<TResult>(
(Task antecedent) => continuationFunction((Task<TInput>)antecedent), cancellationToken, continuationOptions, scheduler);
}
Expand Down Expand Up @@ -350,6 +366,8 @@ public static Task<TNResult> ContinueWithAfterDelayFromAsync<TNResult>(
TaskContinuationOptions taskContinuationOptions,
TaskScheduler scheduler)
{
Contract.ThrowIfNull(continuationFunction, nameof(continuationFunction));

return task.SafeContinueWith(t =>
Task.Delay(millisecondsDelay, cancellationToken).SafeContinueWithFromAsync(
_ => continuationFunction(t), cancellationToken, TaskContinuationOptions.None, scheduler),
Expand All @@ -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),
Expand Down

0 comments on commit 46e6634

Please sign in to comment.