我有一个结构的Type。如何检查开发人员是否使用StructLayoutAttribute应用了结构布局?它不会在Type.CustomAttributes下列出,因为有一个在所有结构中设置的System.RuntimeType.StructLayoutAttribute,而不管StructLayoutAttribute是否存在。
发布于 2017-10-09 17:57:18
这不是一个CustomAttribute,它是一个普通的Attribute。
这意味着你可以只检查Type.IsLayoutSequential,IsExplicitLayout或Type.IsAutoLayout。
编辑:看起来字段是直接显示的。Type.StructLayoutAttribute
https://stackoverflow.com/questions/46643476
复制相似问题