public void TestStruct1() { NStruct builder = NStruct.RandomDomain(); var script = builder .CustomUsing() .HiddenNamespace() .Attribute("[StructLayout(LayoutKind.Explicit)]") .Access(Natasha.Reverser.Model.AccessTypes.Public) .Name("EnumUT1") .Field(item => { item.Attribute <FieldOffsetAttribute>("0").Public().Name("Apple").Type <int>(); }) .Field(item => { item.Attribute <FieldOffsetAttribute>("0").Public().Name("Orange").Type <int>(); }) .Script; Assert.Equal($"using System.Runtime.InteropServices;{Environment.NewLine}using System;{Environment.NewLine}[StructLayout(LayoutKind.Explicit)]{Environment.NewLine}public struct EnumUT1{{{Environment.NewLine}[System.Runtime.InteropServices.FieldOffsetAttribute(0)]{Environment.NewLine}public System.Int32 Apple;{Environment.NewLine}[System.Runtime.InteropServices.FieldOffsetAttribute(0)]{Environment.NewLine}public System.Int32 Orange;{Environment.NewLine}}}", script); Assert.NotNull(builder.GetType()); }
public void TestStruct() { NStruct builder = NStruct.RandomDomain(); var script = builder .CustomUsing() .HiddenNamespace() .Access(Natasha.Reverser.Model.AccessTypes.Public) .Name("EnumUT1") .Field(item => { item.Public().Name("Apple").Type <int>(); }) .Field(item => { item.Public().Name("Orange").Type <string>(); }) .Property(item => { item.Public().Name("Banana").Type <NClass>(); }) .Script; Assert.Equal($"using System;{Environment.NewLine}using Natasha.CSharp;{Environment.NewLine}public struct EnumUT1{{{Environment.NewLine}public System.Int32 Apple;{Environment.NewLine}public System.String Orange;{Environment.NewLine}public Natasha.CSharp.NClass Banana{{{Environment.NewLine}get;{Environment.NewLine}set;{Environment.NewLine}}}{Environment.NewLine}}}", script); Assert.NotNull(builder.GetType()); }