提交 d2793f4d 编写于 作者: J Jonathon Marolf

add dialog window

上级 eb5d3f83
......@@ -70,7 +70,7 @@ public override void HandleException(object provider, Exception exception)
base.HandleException(provider, exception);
_errorReportingService?.ShowErrorInfo(String.Format(WorkspacesResources._0_encountered_an_error_and_has_been_disabled, provider.GetType().Name),
new ErrorReportingUI(WorkspacesResources.Enable, ErrorReportingUI.UIKind.HyperLink, () => LaunchExceptionInfoWindow(exception)),
new ErrorReportingUI(WorkspacesResources.Show_Stack_Trace, ErrorReportingUI.UIKind.HyperLink, () => ShowDetailedErrorInfo(exception), closeAfterAction: false),
new ErrorReportingUI(WorkspacesResources.Enable, ErrorReportingUI.UIKind.Button, () => { EnableProvider(provider); LogEnableProvider(provider); }),
new ErrorReportingUI(WorkspacesResources.Enable_and_ignore_future_errors, ErrorReportingUI.UIKind.Button, () => { EnableProvider(provider); LogEnableProvider(provider); }),
new ErrorReportingUI(String.Empty, ErrorReportingUI.UIKind.Close, () => LogLeaveDisabled(provider)));
......@@ -93,9 +93,9 @@ public override void HandleException(object provider, Exception exception)
_errorLoggerService?.LogException(provider, exception);
}
private void LaunchExceptionInfoWindow(Exception exception)
private void ShowDetailedErrorInfo(Exception exception)
{
throw new NotImplementedException();
_errorReportingService.ShowDetailedErrorInfo(exception);
}
private static void LogLeaveDisabled(object provider)
......
......@@ -8,6 +8,11 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.Workspaces
{
internal class EditorErrorReportingService : IErrorReportingService
{
public void ShowDetailedErrorInfo(Exception exception)
{
Logger.Log(FunctionId.Extension_Exception, exception.StackTrace);
}
public void ShowErrorInfo(string message, params ErrorReportingUI[] items)
{
Logger.Log(FunctionId.Extension_Exception, message);
......
<ui:DialogWindow x:Class="Microsoft.VisualStudio.LanguageServices.Implementation.DetailedErrorInfoDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:local="clr-namespace:Microsoft.VisualStudio.LanguageServices.Implementation"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.14.0"
xmlns:vs="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.14.0"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
mc:Ignorable="d"
ShowInTaskbar="False"
WindowStartupLocation="CenterOwner"
Background="{DynamicResource {x:Static vs:VsBrushes.ToolboxBackgroundKey}}"
Foreground="{DynamicResource {x:Static vs:VsBrushes.ToolboxGradientKey}}"
d:DesignHeight="300" d:DesignWidth="300"
SizeToContent="Height"
MaxWidth="768"
MinWidth="300"
MinHeight="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="38"/>
</Grid.RowDefinitions>
<ScrollViewer Grid.Column="0" Grid.Row="0" HorizontalScrollBarVisibility="Auto" Style="{DynamicResource {x:Static vs:VsResourceKeys.ScrollViewerStyleKey}}">
<TextBox Name="stackTraceText" IsReadOnly="True"
Background="{DynamicResource {x:Static vs:VsBrushes.ToolboxBackgroundKey}}"
Foreground="{DynamicResource {x:Static vs:VsBrushes.ButtonTextKey}}"/>
</ScrollViewer>
<StackPanel Grid.Row="1" Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Name="CopyButton" Height="24" Margin="0,0,10,0" Click="CopyMessageToClipBoard" Style="{DynamicResource {x:Static vs:VsResourceKeys.ButtonStyleKey}}"/>
<Button Name="CloseButton" Height="24" Width="70" Margin="0,0,10,0" Click="CloseWindow" Style="{DynamicResource {x:Static vs:VsResourceKeys.ButtonStyleKey}}"/>
</StackPanel>
</Grid>
</ui:DialogWindow>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.VisualStudio.PlatformUI;
using Microsoft.VisualStudio.Shell;
namespace Microsoft.VisualStudio.LanguageServices.Implementation
{
/// <summary>
/// Interaction logic for UserControl1.xaml
/// </summary>
public partial class DetailedErrorInfoDialog : DialogWindow
{
string errorInfo;
internal DetailedErrorInfoDialog(string title, string errorInfo)
{
InitializeComponent();
this.errorInfo = errorInfo;
this.Title = title;
stackTraceText.AppendText(errorInfo);
this.CopyButton.Content = ServicesVSResources.Copy_to_clipboard;
this.CloseButton.Content = ServicesVSResources.Close;
}
private void CopyMessageToClipBoard(object sender, RoutedEventArgs e)
{
System.Windows.Clipboard.SetText(errorInfo);
}
private void CloseWindow(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}
......@@ -8,6 +8,7 @@
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.VisualStudio.Imaging;
using Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem;
using Microsoft.VisualStudio.PlatformUI;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Roslyn.Utilities;
......@@ -147,46 +148,23 @@ public void OnClosed(IVsInfoBarUIElement infoBarUIElement)
}
}
private class CodeFixInfoBarEvents : IVsInfoBarUIEvents
private static bool TryCreateInfoBarUI(IVsInfoBarUIFactory infoBarUIFactory, IVsInfoBar infoBar, out IVsInfoBarUIElement uiElement)
{
private readonly Action _onClose;
private readonly Action _onEnable;
private readonly Action _onEnableAndIgnore;
public CodeFixInfoBarEvents(Action onClose, Action onEnable = null, Action onEnableAndIgnore = null)
{
Contract.ThrowIfNull(onClose);
_onClose = onClose;
_onEnable = onEnable;
_onEnableAndIgnore = onEnableAndIgnore;
}
public void OnActionItemClicked(IVsInfoBarUIElement infoBarUIElement, IVsInfoBarActionItem actionItem)
{
if (actionItem.Equals(s_enableItem))
{
_onEnable?.Invoke();
}
if (actionItem.Equals(s_enableAndIgnoreItem))
{
_onEnableAndIgnore?.Invoke();
}
uiElement = infoBarUIFactory.CreateInfoBar(infoBar);
return uiElement != null;
}
infoBarUIElement.Close();
}
public void ShowDetailedErrorInfo(Exception exception)
{
string errorInfo = exception.Message + Environment.NewLine + exception.StackTrace;
public void OnClosed(IVsInfoBarUIElement infoBarUIElement)
while (exception.InnerException != null)
{
_onClose();
exception = exception.InnerException;
errorInfo += Environment.NewLine + exception.Message + Environment.NewLine + exception.StackTrace;
}
}
private static bool TryCreateInfoBarUI(IVsInfoBarUIFactory infoBarUIFactory, IVsInfoBar infoBar, out IVsInfoBarUIElement uiElement)
{
uiElement = infoBarUIFactory.CreateInfoBar(infoBar);
return uiElement != null;
(new DetailedErrorInfoDialog(exception.Message, errorInfo)).ShowModal();
}
}
}
Microsoft.VisualStudio.LanguageServices.Implementation.DetailedErrorInfoDialog
Microsoft.VisualStudio.LanguageServices.Implementation.DetailedErrorInfoDialog.InitializeComponent() -> void
\ No newline at end of file
......@@ -343,6 +343,15 @@ internal class ServicesVSResources {
}
}
/// <summary>
/// Looks up a localized string similar to Close.
/// </summary>
internal static string Close {
get {
return ResourceManager.GetString("Close", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Computing remove suppressions fix....
/// </summary>
......@@ -361,6 +370,15 @@ internal class ServicesVSResources {
}
}
/// <summary>
/// Looks up a localized string similar to Copy to Clopboard.
/// </summary>
internal static string Copy_to_clipboard {
get {
return ResourceManager.GetString("Copy_to_clipboard", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Could not find location of folder on disk.
/// </summary>
......
......@@ -699,4 +699,10 @@ Additional information: {1}</value>
<data name="Prefer_predefined_type" xml:space="preserve">
<value>Prefer predefined type</value>
</data>
<data name="Copy_to_clipboard" xml:space="preserve">
<value>Copy to Clopboard</value>
</data>
<data name="Close" xml:space="preserve">
<value>Close</value>
</data>
</root>
\ No newline at end of file
......@@ -160,6 +160,9 @@
<Compile Include="Implementation\Watson\Watson.cs" />
<Compile Include="Implementation\Watson\WatsonErrorReport.cs" />
<Compile Include="Implementation\Watson\WatsonReporter.cs" />
<Compile Include="Implementation\Workspace\DetailedErrorInfoDialog.xaml.cs">
<DependentUpon>DetailedErrorInfoDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Implementation\Workspace\Esent\EsentStorage.ProjectDocumentTableAccessor.cs" />
<Compile Include="Implementation\Workspace\Esent\EsentLogger.cs" />
<Compile Include="Implementation\Workspace\Esent\EsentStorage.ProjectDocumentTable.cs" />
......@@ -714,6 +717,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Implementation\Workspace\DetailedErrorInfoDialog.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="ServicesVSResources.resx">
......
......@@ -9,6 +9,7 @@ namespace Microsoft.CodeAnalysis.Extensions
internal interface IErrorReportingService : IWorkspaceService
{
void ShowErrorInfo(string message, params ErrorReportingUI[] items);
void ShowDetailedErrorInfo(Exception exception);
}
internal struct ErrorReportingUI
......
......@@ -918,6 +918,15 @@ internal class WorkspacesResources {
}
}
/// <summary>
/// Looks up a localized string similar to Show Stack Trace.
/// </summary>
internal static string Show_Stack_Trace {
get {
return ResourceManager.GetString("Show_Stack_Trace", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Solution file not found: &apos;{0}&apos;.
/// </summary>
......
......@@ -483,4 +483,7 @@
<data name="_0_encountered_an_error_and_has_been_disabled" xml:space="preserve">
<value>'{0}' encountered an error and has been disabled.</value>
</data>
<data name="Show_Stack_Trace" xml:space="preserve">
<value>Show Stack Trace</value>
</data>
</root>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册