Skip to content

Commit e9528da

Browse files
committed
Display invalid expression error in Type column
1 parent bf2707d commit e9528da

File tree

9 files changed

+69
-47
lines changed

9 files changed

+69
-47
lines changed

solution/GraphicalDebugging/Debugger.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ public class Expression
77
{
88
public string Name;
99
public string Type;
10-
public bool IsValid;
10+
public string Value;
11+
public bool IsValid;
1112
}
1213

1314
class Debugger
@@ -190,7 +191,12 @@ public string GetValue(string valName)
190191
public Expression GetExpression(string valName)
191192
{
192193
var expr = debugger.GetExpression(valName);
193-
Expression result = new Expression { IsValid = expr.IsValidValue, Name = expr.Name };
194+
Expression result = new Expression
195+
{
196+
Name = expr.Name,
197+
Value = expr.Value,
198+
IsValid = expr.IsValidValue
199+
};
194200
if (IsLanguageCpp)
195201
result.Type = Util.CppNormalizeType(expr.Type);
196202
else

solution/GraphicalDebugging/ExpressionLoader.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,13 @@ public static bool AllValidValues(Expression[] exprs)
175175
return false;
176176
return true;
177177
}
178+
public static string ErrorFromExpressions(Expression[] exprs)
179+
{
180+
foreach (Expression e in exprs)
181+
if (!e.IsValid)
182+
return e.Value;
183+
return "";
184+
}
178185

179186
public static string TypeFromExpressions(Expression[] exprs)
180187
{

solution/GraphicalDebugging/GeometryWatchControl.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@
115115
<DataGridTemplateColumn Header="Type" Width="*" IsReadOnly="True">
116116
<DataGridTemplateColumn.CellTemplate>
117117
<DataTemplate>
118-
<TextBlock Text="{Binding Type}">
118+
<TextBlock Text="{Binding TypeOrError}">
119119
<TextBlock.ToolTip>
120-
<TextBlock Text="{Binding TypeOrError}" TextWrapping="Wrap">
120+
<TextBlock Text="{Binding ErrorOrType}" TextWrapping="Wrap">
121121
<TextBlock.Style>
122122
<Style TargetType="{x:Type TextBlock}">
123123
<Style.Triggers>
@@ -132,7 +132,7 @@
132132
<TextBlock.Style>
133133
<Style TargetType="{x:Type TextBlock}">
134134
<Style.Triggers>
135-
<DataTrigger Binding="{Binding IsError}" Value="true">
135+
<DataTrigger Binding="{Binding IsTypeAndError}" Value="true">
136136
<Setter Property="Foreground" Value="{x:Static Brushes.Red}" />
137137
</DataTrigger>
138138
<Trigger Property="Text" Value="{x:Static sys:String.Empty}">

solution/GraphicalDebugging/GeometryWatchControl.xaml.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,12 @@
77
namespace GraphicalDebugging
88
{
99
using System;
10-
using System.Diagnostics.CodeAnalysis;
10+
using System.Collections.ObjectModel;
11+
using System.Drawing;
1112
using System.Windows;
1213
using System.Windows.Controls;
13-
14-
using System.Drawing;
15-
using System.Drawing.Imaging;
16-
using System.IO;
1714
using System.Windows.Media.Imaging;
1815

19-
using EnvDTE;
20-
using Microsoft.VisualStudio.PlatformUI;
21-
22-
using System.Collections.Generic;
23-
using System.Collections.ObjectModel;
24-
2516
/// <summary>
2617
/// Interaction logic for GeometryWatchControl.
2718
/// </summary>
@@ -265,6 +256,14 @@ private void UpdateItems(bool load, int modified_index = -1)
265256

266257
tryDrawing = true;
267258
}
259+
else if (expressions != null)
260+
{
261+
var errorStr = ExpressionLoader.ErrorFromExpressions(expressions);
262+
if (!string.IsNullOrEmpty(errorStr))
263+
{
264+
geometry.Error = errorStr;
265+
}
266+
}
268267
}
269268

270269
// set new row

solution/GraphicalDebugging/GraphicalWatchControl.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@
9898
<DataGridTemplateColumn Header="Type" Width="*" IsReadOnly="True">
9999
<DataGridTemplateColumn.CellTemplate>
100100
<DataTemplate>
101-
<TextBlock Text="{Binding Type}" TextWrapping="Wrap">
101+
<TextBlock Text="{Binding TypeOrError}" TextWrapping="Wrap">
102102
<TextBlock.ToolTip>
103-
<TextBlock Text="{Binding TypeOrError}" TextWrapping="Wrap">
103+
<TextBlock Text="{Binding ErrorOrType}" TextWrapping="Wrap">
104104
<TextBlock.Style>
105105
<Style TargetType="{x:Type TextBlock}">
106106
<Style.Triggers>
@@ -115,7 +115,7 @@
115115
<TextBlock.Style>
116116
<Style TargetType="{x:Type TextBlock}">
117117
<Style.Triggers>
118-
<DataTrigger Binding="{Binding IsError}" Value="true">
118+
<DataTrigger Binding="{Binding IsTypeAndError}" Value="true">
119119
<Setter Property="Foreground" Value="{x:Static Brushes.Red}" />
120120
</DataTrigger>
121121
<Trigger Property="Text" Value="{x:Static sys:String.Empty}">

solution/GraphicalDebugging/GraphicalWatchControl.xaml.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,12 @@
66

77
namespace GraphicalDebugging
88
{
9-
using System.Diagnostics.CodeAnalysis;
9+
using System;
10+
using System.Collections.ObjectModel;
11+
using System.Drawing;
1012
using System.Windows;
1113
using System.Windows.Controls;
12-
using System.Windows.Media.Imaging;
13-
using System.Windows.Media;
14-
using System.Drawing;
15-
16-
using EnvDTE;
17-
using Microsoft.VisualStudio.PlatformUI;
18-
19-
using System.Collections.ObjectModel;
20-
using System;
21-
14+
2215
/// <summary>
2316
/// Interaction logic for GraphicalWatchControl.
2417
/// </summary>
@@ -245,6 +238,14 @@ private void UpdateItem(bool load, int index)
245238

246239
variable.Type = ExpressionLoader.TypeFromExpressions(expressions);
247240
}
241+
else
242+
{
243+
var errorStr = ExpressionLoader.ErrorFromExpressions(expressions);
244+
if (!string.IsNullOrEmpty(errorStr))
245+
{
246+
variable.Error = errorStr;
247+
}
248+
}
248249
}
249250
}
250251

solution/GraphicalDebugging/PlotWatchControl.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@
115115
<DataGridTemplateColumn Header="Type" Width="*" IsReadOnly="True">
116116
<DataGridTemplateColumn.CellTemplate>
117117
<DataTemplate>
118-
<TextBlock Text="{Binding Type}">
118+
<TextBlock Text="{Binding TypeOrError}">
119119
<TextBlock.ToolTip>
120-
<TextBlock Text="{Binding TypeOrError}" TextWrapping="Wrap">
120+
<TextBlock Text="{Binding ErrorOrType}" TextWrapping="Wrap">
121121
<TextBlock.Style>
122122
<Style TargetType="{x:Type TextBlock}">
123123
<Style.Triggers>
@@ -132,7 +132,7 @@
132132
<TextBlock.Style>
133133
<Style TargetType="{x:Type TextBlock}">
134134
<Style.Triggers>
135-
<DataTrigger Binding="{Binding IsError}" Value="true">
135+
<DataTrigger Binding="{Binding IsTypeAndError}" Value="true">
136136
<Setter Property="Foreground" Value="{x:Static Brushes.Red}" />
137137
</DataTrigger>
138138
<Trigger Property="Text" Value="{x:Static sys:String.Empty}">

solution/GraphicalDebugging/PlotWatchControl.xaml.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,12 @@
77
namespace GraphicalDebugging
88
{
99
using System;
10-
using System.Diagnostics.CodeAnalysis;
10+
using System.Collections.ObjectModel;
11+
using System.Drawing;
1112
using System.Windows;
1213
using System.Windows.Controls;
13-
14-
using System.Drawing;
15-
using System.Drawing.Imaging;
16-
using System.IO;
1714
using System.Windows.Media.Imaging;
1815

19-
using EnvDTE;
20-
using Microsoft.VisualStudio.PlatformUI;
21-
22-
using System.Collections.Generic;
23-
using System.Collections.ObjectModel;
24-
2516
/// <summary>
2617
/// Interaction logic for PlotWatchControl.
2718
/// </summary>
@@ -273,6 +264,14 @@ private void UpdateItems(bool load, int modified_index = -1)
273264

274265
tryDrawing = true;
275266
}
267+
else if (expressions != null)
268+
{
269+
var errorStr = ExpressionLoader.ErrorFromExpressions(expressions);
270+
if (!string.IsNullOrEmpty(errorStr))
271+
{
272+
plot.Error = errorStr;
273+
}
274+
}
276275
}
277276

278277
// set new row

solution/GraphicalDebugging/VariableItem.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,24 @@ public bool IsEnabled
5858
}
5959
}
6060

61+
public string TypeOrError
62+
{
63+
get { return string.IsNullOrEmpty(Type) ? Error : Type; }
64+
}
65+
66+
public string ErrorOrType
67+
{
68+
get { return string.IsNullOrEmpty(Error) ? Type : Error; }
69+
}
70+
6171
public bool IsError
6272
{
63-
get { return Error != null && Error != ""; }
73+
get { return !string.IsNullOrEmpty(Error); }
6474
}
6575

66-
public string TypeOrError
76+
public bool IsTypeAndError
6777
{
68-
get { return IsError ? Error : Type; }
78+
get { return !string.IsNullOrEmpty(Type) && !string.IsNullOrEmpty(Error); }
6979
}
7080
}
7181

0 commit comments

Comments
 (0)