public static bool IsVoStructOrUnion(this TypeSymbol _type) { // TODO (nvk): there must be a better way! NamedTypeSymbol type = null; if (_type != null) { type = _type.OriginalDefinition as NamedTypeSymbol; } if (type is SourceNamedTypeSymbol) { return((type as SourceNamedTypeSymbol).IsSourceVoStructOrUnion); } if (type is Metadata.PE.PENamedTypeSymbol) { if ((object)type != null && type.Arity == 0 && !type.MangleName) { var attrs = type.GetAttributes(); foreach (var attr in attrs) { var atype = attr.AttributeClass; if (atype.IsOurAttribute(OurTypeNames.VOStructAttribute)) { return(true); } } } } return(false); }
public static int VoStructOrUnionSizeInBytes(this TypeSymbol _type) { // TODO (nvk): there must be a better way! NamedTypeSymbol type = null; if (_type != null) { type = _type.OriginalDefinition as NamedTypeSymbol; } if ((object)type != null && type.Arity == 0 && !type.MangleName) { if (type is SourceNamedTypeSymbol) { var sourceType = (SourceNamedTypeSymbol)type; if (sourceType.IsSourceVoStructOrUnion) { return(sourceType.VoStructSize); } } else if (type is Metadata.PE.PENamedTypeSymbol) { var attrs = type.GetAttributes(); foreach (var attr in attrs) { var atype = attr.AttributeClass; if (atype.IsOurAttribute(OurTypeNames.VOStructAttribute)) { return(attr.ConstructorArguments.FirstOrNullable()?.DecodeValue <int>(SpecialType.System_Int32) ?? 0); } } } } return(0); }
public sealed override ImmutableArray <CSharpAttributeData> GetAttributes() { return(_originalDefinition.GetAttributes()); }