public object VisitObject(Func <Type, object> recurse, Type objectType, SortedDictionary <string, Type> fields) { return(this.GenerateRandom(objectType, () => { var asList = fields.ToArray(); var fieldNames = new string[asList.Length]; var values = new object[asList.Length]; for (int i = 0; i < asList.Length; i++) { fieldNames[i] = asList[i].Key; values[i] = recurse(asList[i].Value); } return ReflectionUtilities.CreateInstance(objectType, fieldNames, values); })); }