Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge release/dev16.11 to main #53062

Merged
5 commits merged into from
May 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletions src/EditorFeatures/Core.Wpf/QuickInfo/LazyToolTip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Windows;
using System.Windows.Controls;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.ErrorReporting;

namespace Microsoft.CodeAnalysis.Editor.QuickInfo
{
Expand Down Expand Up @@ -50,26 +51,40 @@ public static void AttachTo(FrameworkElement element, IThreadingContext threadin

private void OnToolTipOpening(object sender, ToolTipEventArgs e)
{
AssertIsForeground();
try
{
AssertIsForeground();

Debug.Assert(_element.ToolTip == this);
Debug.Assert(_disposableToolTip == null);
Debug.Assert(_element.ToolTip == this);
Debug.Assert(_disposableToolTip == null);

_disposableToolTip = _createToolTip();
_element.ToolTip = _disposableToolTip.ToolTip;
_disposableToolTip = _createToolTip();
_element.ToolTip = _disposableToolTip.ToolTip;
}
catch (Exception ex) when (FatalError.ReportAndCatch(ex))
{
// Do nothing, since this is a WPF event handler and propagating the exception would cause a crash
}
}

private void OnToolTipClosing(object sender, ToolTipEventArgs e)
{
AssertIsForeground();
try
{
AssertIsForeground();

Debug.Assert(_disposableToolTip != null);
Debug.Assert(_element.ToolTip == _disposableToolTip.ToolTip);
Debug.Assert(_disposableToolTip != null);
Debug.Assert(_element.ToolTip == _disposableToolTip.ToolTip);

_element.ToolTip = this;
_element.ToolTip = this;

_disposableToolTip.Dispose();
_disposableToolTip = null;
_disposableToolTip.Dispose();
_disposableToolTip = null;
}
catch (Exception ex) when (FatalError.ReportAndCatch(ex))
{
// Do nothing, since this is a WPF event handler and propagating the exception would cause a crash
}
}
}
}
Expand Down