示例#1
0
        public static void ValidateTypeArg(ParseInfo parseInfo, AnonymousType typeArg, CodeType type, DocRange errorRange)
        {
            // 'single' attribute, type-arg is not parallelable.
            if (typeArg.AnonymousTypeAttributes.Single)
            {
                // Bad struct
                if (type.Attributes.IsStruct)
                {
                    parseInfo.Script.Diagnostics.Error("Struct types cannot be used with 'single' type args", errorRange);
                    return;
                }

                // Extract anonymous types.
                var subtypes = type.ExtractAnonymousTypes();

                foreach (var subtype in subtypes)
                {
                    if (!subtype.AnonymousTypeAttributes.Single)
                    {
                        parseInfo.Script.Diagnostics.Error("The anonymous type used here as a type arg needs to be marked as 'single'", errorRange);
                        return;
                    }
                }
            }
        }