Skip to content

Commit 1623f56

Browse files
committed
Add debugger display for LToken instances.
1 parent 056671b commit 1623f56

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

Luaon.NET/Linq/LField.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace Luaon.Linq
77
{
8+
[DebuggerDisplay("{Name}={Value}")]
89
public class LField : LToken
910
{
1011

Luaon.NET/Linq/LTable.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ namespace Luaon.Linq
1111
/// Represents a table in Lua.
1212
/// </summary>
1313
/// <remarks>See <a herf="http://www.lua.org/manual/5.3/manual.html#2.1">2.1 Values and Types</a> for the basic concepts on Lua tables.</remarks>
14+
[DebuggerDisplay("Count = {Count}")]
15+
[DebuggerTypeProxy(typeof(DebuggerView))]
1416
public class LTable : LToken, ICollection<LField>
1517
{
1618

@@ -293,7 +295,7 @@ internal override bool DeepEquals(LToken other)
293295
{
294296
var y = other as LTable;
295297
if (y == null) return false;
296-
if (ReferenceEquals(this, y)) return true;
298+
if (ReferenceEquals(this, y)) return true;
297299
if (store.Count != y.store.Count) return false;
298300
var count = store.Count;
299301
for (int i = 0; i < count; i++)
@@ -322,5 +324,24 @@ IEnumerator IEnumerable.GetEnumerator()
322324
{
323325
return GetEnumerator();
324326
}
327+
328+
internal sealed class DebuggerView
329+
{
330+
331+
private LTable myTable;
332+
333+
public DebuggerView(LTable table)
334+
{
335+
Debug.Assert(table != null);
336+
myTable = table;
337+
}
338+
339+
public LField[] Items
340+
{
341+
get { return myTable.store.ToArray(); }
342+
}
343+
344+
}
345+
325346
}
326347
}

Luaon.NET/Linq/LValue.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics;
34
using System.Text;
45

56
namespace Luaon.Linq
67
{
78
/// <summary>
89
/// Represents a read-only Lua value node.
910
/// </summary>
11+
[DebuggerDisplay("{Value}")]
1012
public class LValue : LToken, IEquatable<LValue>
1113
{
1214

0 commit comments

Comments
 (0)