private void GenerateSubTypes(Type sourceType, out bool hasVariableSerializableLength) { hasVariableSerializableLength = false; // Check do we have all cpp types required to generate a type. // foreach (FieldInfo fieldInfo in sourceType.GetPublicInstanceFields()) { if (fieldInfo.IsString()) { // Structure contains a string field. // hasVariableSerializableLength = true; } // For arrays, ensure the array element type has been generated. // Type fieldType = fieldInfo.IsFixedSizedArray() ? fieldInfo.FieldType.GetElementType() : fieldInfo.FieldType; if (CppTypeMapper.TryGetCppType(fieldType, out CppType cppType)) { // Cpp type has been generated, safe to use. // if (cppType.HasVariableData) { // Field type is variable length, so containing structure is also variable length. // hasVariableSerializableLength = true; } continue; } // Recursively generate field type. // if (!this.GenerateType(fieldType)) { // There are errors, however continue, so we can report on all of them in one shot. // } } }
private bool IsSupportedFieldType(FieldInfo fieldInfo, out CppType cppFieldType) { Type fieldType = fieldInfo.IsFixedSizedArray() ? fieldInfo.FieldType.GetElementType() : fieldInfo.FieldType; return(CppTypeMapper.TryGetCppType(fieldType, out cppFieldType)); }