/// <summary> /// Creates an expression which, when evaluated, creates a List<T> in the debugee /// filled with contents of IEnumerable<T> from the debugee. /// </summary> /// <param name="iEnumerableVariable">Expression for IEnumerable variable in the debugee.</param> /// <param name="itemType"> /// The generic argument of IEnumerable<T> that <paramref name="iEnumerableVariable"/> implements.</param> public static Expression CreateDebugListExpression(Expression iEnumerableVariable, DebugType itemType, out DebugType listType) { // is using itemType.AppDomain ok? listType = DebugType.CreateFromType(itemType.AppDomain, typeof(System.Collections.Generic.List <>), itemType); var iEnumerableType = DebugType.CreateFromType(itemType.AppDomain, typeof(IEnumerable <>), itemType); // explicitely cast the variable to IEnumerable<T>, where T is itemType Expression iEnumerableVariableExplicitCast = new CastExpression(iEnumerableType.GetTypeReference(), iEnumerableVariable, CastType.Cast); return(new ObjectCreateExpression(listType.GetTypeReference(), iEnumerableVariableExplicitCast.SingleItemList())); }