private static void WriteGenericSignature(ModuleBuilder module, ByteBuffer bb, Type type) { Type[] typeArguments = type.GetGenericArguments(); CustomModifiers[] customModifiers = type.__GetGenericArgumentsCustomModifiers(); if (!type.IsGenericTypeDefinition) { type = type.GetGenericTypeDefinition(); } bb.Write(ELEMENT_TYPE_GENERICINST); if (type.IsValueType) { bb.Write(ELEMENT_TYPE_VALUETYPE); } else { bb.Write(ELEMENT_TYPE_CLASS); } bb.WriteTypeDefOrRefEncoded(module.GetTypeToken(type).Token); bb.WriteCompressedUInt(typeArguments.Length); for (int i = 0; i < typeArguments.Length; i++) { WriteCustomModifiers(module, bb, customModifiers[i]); WriteType(module, bb, typeArguments[i]); } }