Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const TypeAttributes typeAttributes = TypeAttributes.Public |
- TypeAttributes.SequentialLayout |
- TypeAttributes.UnicodeClass;
- var typeBuilder = moduleBuilder.DefineType("MyType", typeAttributes, typeof(ValueType));
- ConstructorInfo structLayoutAttributeConstructorInfo = typeof(StructLayoutAttribute).GetConstructor(new[] { typeof(LayoutKind) });
- FieldInfo charSetFieldInfo = typeof(StructLayoutAttribute).GetField(nameof(StructLayoutAttribute.CharSet));
- CustomAttributeBuilder attr = new CustomAttributeBuilder(structLayoutAttributeConstructorInfo,
- new object[] { LayoutKind.Sequential },
- new FieldInfo[] { charSetFieldInfo },
- new object[] { CharSet.Unicode });
- typeBuilder.SetCustomAttribute(structLayoutAttributeBuilder);
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
Add Comment
Please, Sign In to add comment