private static void CreatePropertyInterface(this ModuleDefinition module, Type type, string namespaceName) { // public interface Int32Property // { // void Allocate(ref BlobBuilder builder, ref BlobVariable<Int32> blobVariable); // } // .class interface public abstract auto ansi // EntitiesBT.Editor.Int32Property // { // // .method public hidebysig virtual newslot abstract instance void // Allocate( // valuetype [Unity.Entities]Unity.Entities.BlobBuilder& builder, // valuetype [EntitiesBT.Runtime]EntitiesBT.Variable.BlobVariable`1<int32>& blobVariable // ) cil managed // { // // Can't find a body // } // end of method Int32Property::Allocate // } // end of class EntitiesBT.Editor.Int32Property const TypeAttributes interfaceAttributes = TypeAttributes.Class | TypeAttributes.Interface | TypeAttributes.Public | TypeAttributes.Abstract | TypeAttributes.AutoClass | TypeAttributes.AnsiClass; var interfaceType = new TypeDefinition(namespaceName, $"{type.Name}Property", interfaceAttributes, module.TypeSystem.Object); const MethodAttributes methodAttributes = MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Virtual | MethodAttributes.NewSlot | MethodAttributes.Abstract; var allocateMethod = new MethodDefinition("Allocate", methodAttributes, module.TypeSystem.Void); var builderParameter = new ParameterDefinition( "builder" , ParameterAttributes.None , module.ImportReference(typeof(BlobBuilder)).MakeByReferenceType() ); var blobVariableParameter = new ParameterDefinition( "blobVariable" , ParameterAttributes.None , module.ImportReference(typeof(BlobVariable <>).MakeGenericType(type)).MakeByReferenceType() ); allocateMethod.Parameters.Add(builderParameter); allocateMethod.Parameters.Add(blobVariableParameter); interfaceType.Methods.Add(allocateMethod); module.Types.Add(interfaceType); foreach (var propertyType in _PROPERTY_TYPES.Value) { module.CreatePropertyClass(namespaceName, type, propertyType, new InterfaceImplementation(interfaceType)); } }