public object VisitList(Func <Type, object> recurse, Type listType, Type elementType)
        {
            if (!exhaustiveLists)
            {
                return(GeneratorHelper.ApplyToList(recurse, elementType, maxSize));
            }

            var length = Arbitrary <byte>();

            // start with empty list
            var emptyMethod = emptyListMethod.MakeGenericMethod(elementType);
            var ifMethod    = ifConditionMethod.MakeGenericMethod(listType);

            var list = emptyMethod.Invoke(null, CommonUtilities.EmptyArray);

            for (int i = maxSize; i > 0; i--)
            {
                var guard      = length == Constant((byte)i);
                var trueBranch = GeneratorHelper.ApplyToList(recurse, elementType, i);
                list = ifMethod.Invoke(null, new object[] { guard, trueBranch, list });
            }

            return(list);
        }
Esempio n. 2
0
 public object VisitTuple(Func <Type, object> recurse, Type tupleType, Type innerTypeLeft, Type innerTypeRight)
 {
     return(GeneratorHelper.ApplyToTuple(recurse, innerTypeLeft, innerTypeRight));
 }
Esempio n. 3
0
 public object VisitObject(Func <Type, object> recurse, Type objectType, SortedDictionary <string, Type> fields)
 {
     return(GeneratorHelper.ApplyToObject(recurse, objectType, fields));
 }