Exemple #1
0
        DefaultTypeDefinition GetDummyClassForTypeParameter()
        {
            DefaultTypeDefinition c = new DefaultTypeDefinition(dummyProjectContent, string.Empty, this.Name);

            c.Region = this.Region;
            if (HasValueTypeConstraint)
            {
                c.ClassType = ClassType.Struct;
            }
            else if (HasDefaultConstructorConstraint)
            {
                c.ClassType = ClassType.Class;
            }
            else
            {
                c.ClassType = ClassType.Interface;
            }
            return(c);
        }
Exemple #2
0
        DefaultTypeDefinition GetDummyClassForTypeParameter()
        {
            DefaultTypeDefinition c = new DefaultTypeDefinition(ParentClass ?? ParentMethod.DeclaringTypeDefinition, this.Name);

            c.Region = new DomRegion(parent.Region.FileName, parent.Region.BeginLine, parent.Region.BeginColumn);
            if (HasValueTypeConstraint)
            {
                c.ClassType = ClassType.Struct;
            }
            else if (HasDefaultConstructorConstraint)
            {
                c.ClassType = ClassType.Class;
            }
            else
            {
                c.ClassType = ClassType.Interface;
            }
            return(c);
        }
        private MinimalResolveContext()
        {
            List <ITypeDefinition> types = new List <ITypeDefinition>();

            systemObject = new DefaultTypeDefinition(this, "System", "Object")
            {
                Accessibility = Accessibility.Public
            };
            systemValueType = new DefaultTypeDefinition(this, "System", "ValueType")
            {
                Accessibility = Accessibility.Public,
                BaseTypes     = { systemObject }
            };
            // TypeCode.Empty = void
            types.Add(new VoidTypeDefinition(this));
            // types are added in the order they are defined in the TypeCode enum
            types.Add(systemObject);
            types.Add(CreateClass("System", "DBNull"));
            types.Add(CreateStruct("System", "Boolean"));
            types.Add(CreateStruct("System", "Char"));
            types.Add(CreateStruct("System", "SByte"));
            types.Add(CreateStruct("System", "Byte"));
            types.Add(CreateStruct("System", "Int16"));
            types.Add(CreateStruct("System", "UInt16"));
            types.Add(CreateStruct("System", "Int32"));
            types.Add(CreateStruct("System", "UInt32"));
            types.Add(CreateStruct("System", "Int64"));
            types.Add(CreateStruct("System", "UInt64"));
            types.Add(CreateStruct("System", "Single"));
            types.Add(CreateStruct("System", "Double"));
            types.Add(CreateStruct("System", "Decimal"));
            types.Add(CreateStruct("System", "DateTime"));
            types.Add(systemValueType);             // misuse unused enum value (TypeCode)17 for System.ValueType
            types.Add(CreateClass("System", "String"));
            foreach (ITypeDefinition type in types)
            {
                type.Freeze();
            }
            this.types = types.AsReadOnly();
        }