private IReadOnlyList <ScriptExportField> CreateFields(IScriptExportManager manager) { if (Definition == null) { return(Array.Empty <ScriptExportField>()); } List <ScriptExportField> fields = new List <ScriptExportField>(); foreach (FieldDefinition field in Definition.Fields) { if (!MonoType.IsSerializableModifier(field)) { continue; } // if we can't determine whether it serializable or not, then consider it as serializable if (IsSerializationApplicable(field.FieldType)) { MonoFieldContext scope = new MonoFieldContext(field, manager.Layout); if (!MonoType.IsFieldTypeSerializable(scope)) { continue; } } ScriptExportField efield = manager.RetrieveField(field); fields.Add(efield); } return(fields.ToArray()); }
private IReadOnlyList <ScriptExportField> CreateFields(IScriptExportManager manager) { if (Definition == null) { return(new ScriptExportField[0]); } List <ScriptExportField> fields = new List <ScriptExportField>(); foreach (FieldDefinition field in Definition.Fields) { if (field.FieldType.Module == null) { // if field has unknown type then consider it as serializable } else if (IsContainsGenericParameter(field.FieldType)) { // if field type has generic parameter then consider it as serializable } else if (!MonoField.IsSerializable(field, null)) { continue; } ScriptExportField efield = manager.RetrieveField(field); fields.Add(efield); } return(fields.ToArray()); }
private IReadOnlyList <ScriptExportField> CreateFields(IScriptExportManager manager) { if (Definition == null) { return(new ScriptExportField[0]); } List <ScriptExportField> fields = new List <ScriptExportField>(); foreach (FieldDefinition field in Definition.Fields) { if (field.IsPublic) { if (field.IsNotSerialized) { continue; } } else { if (!ScriptExportMonoField.HasSerializeFieldAttribute(field)) { continue; } } if (field.FieldType.Module == null) { // if field has unknown type then consider it as serializable } else { TypeDefinition fieldTypeDefinition = field.FieldType.Resolve(); if (fieldTypeDefinition.IsInterface) { continue; } if (!MonoType.IsSerializableType(field.FieldType)) { continue; } } ScriptExportField efield = manager.RetrieveField(field); fields.Add(efield); } return(fields.ToArray()); }
private IReadOnlyList <ScriptExportField> CreateFields(IScriptExportManager manager) { List <ScriptExportField> fields = new List <ScriptExportField>(); foreach (FieldDefinition field in Definition.Fields) { if (field.Name == "value__") { continue; } ScriptExportField enumField = manager.RetrieveField(field); fields.Add(enumField); } return(fields); }
public override void Init(IScriptExportManager manager) { if (Type.Module == null) { m_fields = new ScriptExportField[0]; } else { m_fields = CreateFields(manager); } if (Type.IsNested) { m_declaringType = manager.RetrieveType(Type.DeclaringType); AddAsNestedEnum(); } }
private IReadOnlyList <ScriptExportField> CreateFields(IScriptExportManager manager) { if (Definition == null) { return(Array.Empty <ScriptExportField>()); } List <ScriptExportField> fields = new List <ScriptExportField>(); foreach (FieldDefinition field in Definition.Fields) { if (!MonoField.IsSerializableModifier(field)) { continue; } if (field.FieldType.Module == null) { // if field has unknown type then consider it as serializable } else if (field.FieldType.ContainsGenericParameter) { // if field type has generic parameter then consider it as serializable } else { TypeDefinition definition = field.FieldType.Resolve(); if (definition == null) { // if field has unknown type then consider it as serializable } else { MonoSerializableScope scope = new MonoSerializableScope(field); if (!MonoField.IsFieldTypeSerializable(scope)) { continue; } } } ScriptExportField efield = manager.RetrieveField(field); fields.Add(efield); } return(fields.ToArray()); }