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

responding to PR feedback

上级 d2793f4d
......@@ -8,6 +8,7 @@
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"
x:ClassModifier="internal"
ShowInTaskbar="False"
WindowStartupLocation="CenterOwner"
Background="{DynamicResource {x:Static vs:VsBrushes.ToolboxBackgroundKey}}"
......@@ -22,14 +23,27 @@
<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 Grid.Column="0" Grid.Row="0"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto"
Style="{DynamicResource {x:Static vs:VsResourceKeys.ScrollViewerStyleKey}}">
<TextBox
Name="stackTraceText"
IsReadOnly="True"
Style="{DynamicResource {x:Static vs:VsResourceKeys.TextBoxStyleKey}}"/>
</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}}"/>
<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
......@@ -18,14 +18,11 @@
namespace Microsoft.VisualStudio.LanguageServices.Implementation
{
/// <summary>
/// Interaction logic for UserControl1.xaml
/// </summary>
public partial class DetailedErrorInfoDialog : DialogWindow
internal partial class DetailedErrorInfoDialog : DialogWindow
{
string errorInfo;
private readonly string errorInfo;
internal DetailedErrorInfoDialog(string title, string errorInfo)
internal DetailedErrorInfoDialog(string title, string errorInfo)
{
InitializeComponent();
this.errorInfo = errorInfo;
......@@ -33,11 +30,19 @@ internal DetailedErrorInfoDialog(string title, string errorInfo)
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);
try
{
System.Windows.Clipboard.SetText(errorInfo);
}
catch (Exception)
{
// rdpclip.exe not running in a TS session, ignore
}
}
private void CloseWindow(object sender, RoutedEventArgs e)
......
......@@ -155,16 +155,45 @@ private static bool TryCreateInfoBarUI(IVsInfoBarUIFactory infoBarUIFactory, IVs
}
public void ShowDetailedErrorInfo(Exception exception)
{
string errorInfo = GetErrorInfoForException(exception);
(new DetailedErrorInfoDialog(exception.Message, errorInfo)).ShowModal();
}
private static string GetErrorInfoForException(Exception exception)
{
string errorInfo = exception.Message + Environment.NewLine + exception.StackTrace;
var aggregateException = exception as AggregateException;
if (aggregateException?.InnerExceptions != null)
{
foreach (var ex in aggregateException.InnerExceptions)
{
errorInfo = AppendExceptionInfo(errorInfo, ex);
}
}
else
{
if (exception.InnerException != null)
{
errorInfo = AppendExceptionInfo(errorInfo, exception.InnerException);
}
}
return errorInfo;
}
private static string AppendExceptionInfo(string errorInfo, Exception exception)
{
errorInfo += Environment.NewLine + exception.Message + Environment.NewLine + exception.StackTrace;
while (exception.InnerException != null)
{
exception = exception.InnerException;
errorInfo += Environment.NewLine + exception.Message + Environment.NewLine + exception.StackTrace;
}
(new DetailedErrorInfoDialog(exception.Message, errorInfo)).ShowModal();
return errorInfo;
}
}
}
Microsoft.VisualStudio.LanguageServices.Implementation.DetailedErrorInfoDialog
Microsoft.VisualStudio.LanguageServices.Implementation.DetailedErrorInfoDialog.InitializeComponent() -> void
\ No newline at end of file
......@@ -700,9 +700,9 @@ Additional information: {1}</value>
<value>Prefer predefined type</value>
</data>
<data name="Copy_to_clipboard" xml:space="preserve">
<value>Copy to Clopboard</value>
<value>Copy to Clipboard</value>
</data>
<data name="Close" xml:space="preserve">
<value>Close</value>
</data>
</root>
\ No newline at end of file
</root>
......@@ -742,7 +742,6 @@
<Compile Include="SymbolSearch\SymbolSearchService.PatchService.cs" />
<None Include="project.json" />
<PublicAPI Include="PublicAPI.Shipped.txt" />
<PublicAPI Include="PublicAPI.Unshipped.txt" />
</ItemGroup>
<ItemGroup>
<VSCTCompile Include="Commands.vsct">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册