检查开发人员是否应用了StructLayout

时间:2017-10-09 09:48:06

标签: c# struct marshalling

我有一个Type结构。如何检查开发人员是否使用StructLayoutAttribute应用了结构布局?它未列在Type.CustomAttributes下,因为无论是否存在System.RuntimeType.StructLayoutAttribute,都会在所有结构中设置StructLayoutAttribute

1 个答案:

答案 0 :(得分:2)

这不是CustomAttribute,而是常规Attribute

这意味着您只需检查Type.IsLayoutSequentialIsExplicitLayoutType.IsAutoLayout

编辑: 似乎该字段是直接暴露的。 Type.StructLayoutAttribute

相关问题