TypeAttributes GetExtendedTypeAttributes(TypeAttributes attributes, TypeMember type)
{
switch (type.NodeType)
{
case NodeType.ClassDefinition:
{
attributes |= (TypeAttributes.AnsiClass | TypeAttributes.AutoLayout);
attributes |= TypeAttributes.Class;
if (!((ClassDefinition) type).HasDeclaredStaticConstructor)
{
attributes |= TypeAttributes.BeforeFieldInit;
}
if (type.IsAbstract)
{
attributes |= TypeAttributes.Abstract;
}
if (type.IsFinal)
{
attributes |= TypeAttributes.Sealed;
}
if (type.IsStatic) //static type is Sealed+Abstract in SRE
attributes |= TypeAttributes.Sealed | TypeAttributes.Abstract;
else if (!type.IsTransient)
attributes |= TypeAttributes.Serializable;
if (((IType)type.Entity).IsValueType)
{
attributes |= TypeAttributes.SequentialLayout;
}
break;
}
case NodeType.EnumDefinition:
{
attributes |= TypeAttributes.Sealed;
attributes |= TypeAttributes.Serializable;
break;
}
case NodeType.InterfaceDefinition:
{
attributes |= (TypeAttributes.Interface | TypeAttributes.Abstract);
break;
}
case NodeType.Module:
{
attributes |= TypeAttributes.Sealed;
break;
}
}
return attributes;
}