LINQBridge and QuickWatch/Results View

426 views
Skip to first unread message

Karel Kral

unread,
Sep 4, 2008, 10:47:55 AM9/4/08
to LINQBridge
Hello,
thanks for this excellent library!
I have one small problem. I would like to see query results in Watch
and QuickWatch windows. But for LinqBridge there is no "Results View"
item as for normal System.Linq queries. So if I want to view results,
I must use some form of logging.

Does anybody know how to connect LinqBridge results with Results View?
IMHO, this would be possible by applying some attribute to LinqBridge
assembly.

Atif Aziz

unread,
Sep 4, 2008, 11:02:48 AM9/4/08
to linqb...@googlegroups.com
Does anybody know how to connect LinqBridge results with Results View?

A quick workaround, meanwhile, would be to simply call ToArray on your query to view the results in, for eaxmple, the QuickWatch. This assumes, of course, that the query is re-runnable.
 
- Atif

Richard

unread,
Oct 20, 2008, 9:39:50 AM10/20/08
to LINQBridge
> Does anybody know how to connect LinqBridge results with Results View?

If you add the internal SystemCore_EnumerableDebugView and
SystemCore_EnumerableDebugView<T> classes to the System.Linq
namespace, you will automatically get the results view in VS2008. For
example:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;

namespace System.Linq
{
internal sealed class SystemCore_EnumerableDebugView
{
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private object[] cachedCollection;

[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private int count;

[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private IEnumerable enumerable;

public SystemCore_EnumerableDebugView(IEnumerable enumerable)
{
if (null == enumerable) throw new
ArgumentNullException("enumerable");
this.enumerable = enumerable;
}

[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public object[] Items
{
get
{
var list = new List<object>();
IEnumerator enumerator = this.enumerable.GetEnumerator();
if (enumerator != null)
{
this.count = 0;
while (enumerator.MoveNext())
{
list.Add(enumerator.Current);
this.count++;
}
}
this.cachedCollection = new object[this.count];
list.CopyTo(this.cachedCollection, 0);
return this.cachedCollection;
}
}
}

internal sealed class SystemCore_EnumerableDebugView<T>
{
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private T[] cachedCollection;

[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private int count;

[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private IEnumerable<T> enumerable;

public SystemCore_EnumerableDebugView(IEnumerable<T> enumerable)
{
if (null == enumerable) throw new
ArgumentNullException("enumerable");
this.enumerable = enumerable;
}

[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public T[] Items
{
get
{
var list = new List<T>();
IEnumerator<T> enumerator = this.enumerable.GetEnumerator();
if (enumerator != null)
{
this.count = 0;
while (enumerator.MoveNext())
{
list.Add(enumerator.Current);
this.count++;
}
}
this.cachedCollection = new T[this.count];
list.CopyTo(this.cachedCollection, 0);
return this.cachedCollection;
}
}
}
}


If it doesn't work automatically, try adding DebuggerTypeProxy
attributes to the assembly:

[assembly:
DebuggerTypeProxy("System.Linq.SystemCore_EnumerableDebugView", Target
= typeof(System.Collections.IEnumerable))]
[assembly:
DebuggerTypeProxy("System.Linq.SystemCore_EnumerableDebugView<>",
Target = typeof(System.Collections.Generic.IEnumerable<>))]
Reply all
Reply to author
Forward
0 new messages