public static void TraceNode(this NewExpression newExpression, StringBuilder sb, int level = 0) { if (sb == null || newExpression == null) { return; } newExpression.TraceBaseInfo(sb, level); var levelSpace = new string(' ', level *NumberOfSpaces); sb.Append($"|{levelSpace}|- newExpression.Constructor?.Name: {newExpression.Constructor?.Name}{Nl}"); if (newExpression.Constructor?.GetParameters() != null) { sb.Append($"|{levelSpace}|- newExpression.Constructor?.GetParameters(): " + $"{string.Join(",", newExpression.Constructor?.GetParameters().Select(p=>$"{p.ParameterType.Name} {p.Name}"))}" + $"{Nl}"); } level++; if (newExpression.Arguments != null) { sb.Append($"|{levelSpace}|{Nl}"); sb.Append($"|{levelSpace}|- Arguments Count: {newExpression.Arguments.Count}{Nl}"); foreach (var expression in newExpression.Arguments) { expression.TraceNode(sb, level); } } if (newExpression.Members != null) { sb.Append($"|{levelSpace}|{Nl}"); sb.Append($"|{levelSpace}|- Members Count: {newExpression.Members.Count}{Nl}"); foreach (var memberInfo in newExpression.Members) { sb.Append($"|{levelSpace}|- memberInfo.Name: {memberInfo.Name}"); } } }