{"action":"opened","issue":{"url":"https://api.github.com/repos/AdamsLair/duality/issues/328","repository_url":"https://api.github.com/repos/AdamsLair/duality","labels_url":"https://api.github.com/repos/AdamsLair/duality/issues/328/labels{/name}","comments_url":"https://api.github.com/repos/AdamsLair/duality/issues/328/comments","events_url":"https://api.github.com/repos/AdamsLair/duality/issues/328/events","html_url":"https://github.com/AdamsLair/duality/issues/328","id":155096808,"number":328,"title":"Reduce Struct Array Serialization Verbosity","user":{"login":"ilexp","id":14859411,"avatar_url":"https://avatars.githubusercontent.com/u/14859411?v=3","gravatar_id":"","url":"https://api.github.com/users/ilexp","html_url":"https://github.com/ilexp","followers_url":"https://api.github.com/users/ilexp/followers","following_url":"https://api.github.com/users/ilexp/following{/other_user}","gists_url":"https://api.github.com/users/ilexp/gists{/gist_id}","starred_url":"https://api.github.com/users/ilexp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilexp/subscriptions","organizations_url":"https://api.github.com/users/ilexp/orgs","repos_url":"https://api.github.com/users/ilexp/repos","events_url":"https://api.github.com/users/ilexp/events{/privacy}","received_events_url":"https://api.github.com/users/ilexp/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/AdamsLair/duality/labels/Core","name":"Core","color":"bfe5bf"},{"url":"https://api.github.com/repos/AdamsLair/duality/labels/Task","name":"Task","color":"c7def8"},{"url":"https://api.github.com/repos/AdamsLair/duality/labels/Unit-Test%20This","name":"Unit-Test This","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/AdamsLair/duality/milestones/2","html_url":"https://github.com/AdamsLair/duality/milestones/General%20Improvements","labels_url":"https://api.github.com/repos/AdamsLair/duality/milestones/2/labels","id":856226,"number":2,"title":"General Improvements","description":"Improving the existing functionality of Duality without creating whole new modules or systems.","creator":{"login":"AdamsLair","id":5013908,"avatar_url":"https://avatars.githubusercontent.com/u/5013908?v=3","gravatar_id":"","url":"https://api.github.com/users/AdamsLair","html_url":"https://github.com/AdamsLair","followers_url":"https://api.github.com/users/AdamsLair/followers","following_url":"https://api.github.com/users/AdamsLair/following{/other_user}","gists_url":"https://api.github.com/users/AdamsLair/gists{/gist_id}","starred_url":"https://api.github.com/users/AdamsLair/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AdamsLair/subscriptions","organizations_url":"https://api.github.com/users/AdamsLair/orgs","repos_url":"https://api.github.com/users/AdamsLair/repos","events_url":"https://api.github.com/users/AdamsLair/events{/privacy}","received_events_url":"https://api.github.com/users/AdamsLair/received_events","type":"Organization","site_admin":false},"open_issues":44,"closed_issues":95,"state":"open","created_at":"2014-11-06T17:02:30Z","updated_at":"2016-05-16T18:59:32Z","due_on":null,"closed_at":null},"comments":0,"created_at":"2016-05-16T18:59:31Z","updated_at":"2016-05-16T18:59:31Z","closed_at":null,"body":"#### Summary\r\n\r\nIn the course of issue #279, it became apparent that both XML and Binary serialization write a lot of unnecessary information when serializing a large amount of structs. Investigate ways to reduce the amount of written data in the case of struct and struct array serialization.\r\n\r\n#### Analysis\r\n\r\n- While `null` values can be serialized easily, there currently is no special case for `default(T)` struct values. They could be omitted safely just as well.\r\n  - `XmlSerializer`: Just don't populate the current struct element in `WriteStruct`.\r\n  - `BinarySerializer`: Use the skip-field array to skip all fields.\r\n  - Note: This is only viable for non-custom serialization.\r\n- Theoretically, this could be extended towards omitting `default(T)` fields of a struct value.\r\n  - Doesn't work for classes, as they can have arbitrary constructors, so their field's default is unknown.\r\n  - May result in less readable XML. Could be considered for binary serialization.\r\n- Add unit tests that check specifically for potential problems with the omission of values.\r\n\r\n#### Attachments\r\n\r\nSample excerpt of verbose XML struct array serialization:\r\n```xml\r\n<data dataType=\"Array\" type=\"Duality.Plugins.Tilemaps.TileInput[]\" id=\"295733828\" length=\"556\">\r\n  <item dataType=\"Struct\" type=\"Duality.Plugins.Tilemaps.TileInput\">\r\n    <Collision dataType=\"Struct\" type=\"Duality.Plugins.Tilemaps.TileCollisionShapes\">\r\n      <Layer0 dataType=\"Enum\" type=\"Duality.Plugins.Tilemaps.TileCollisionShape\" name=\"Free\" value=\"0\" />\r\n      <Layer1 dataType=\"Enum\" type=\"Duality.Plugins.Tilemaps.TileCollisionShape\" name=\"Free\" value=\"0\" />\r\n      <Layer2 dataType=\"Enum\" type=\"Duality.Plugins.Tilemaps.TileCollisionShape\" name=\"Free\" value=\"0\" />\r\n      <Layer3 dataType=\"Enum\" type=\"Duality.Plugins.Tilemaps.TileCollisionShape\" name=\"Free\" value=\"0\" />\r\n    </Collision>\r\n    <DepthOffset dataType=\"Int\">0</DepthOffset>\r\n    <IsVertical dataType=\"Bool\">false</IsVertical>\r\n  </item>\r\n  <item dataType=\"Struct\" type=\"Duality.Plugins.Tilemaps.TileInput\">\r\n    <Collision dataType=\"Struct\" type=\"Duality.Plugins.Tilemaps.TileCollisionShapes\">\r\n      <Layer0 dataType=\"Enum\" type=\"Duality.Plugins.Tilemaps.TileCollisionShape\" name=\"Free\" value=\"0\" />\r\n      <Layer1 dataType=\"Enum\" type=\"Duality.Plugins.Tilemaps.TileCollisionShape\" name=\"Free\" value=\"0\" />\r\n      <Layer2 dataType=\"Enum\" type=\"Duality.Plugins.Tilemaps.TileCollisionShape\" name=\"Free\" value=\"0\" />\r\n      <Layer3 dataType=\"Enum\" type=\"Duality.Plugins.Tilemaps.TileCollisionShape\" name=\"Free\" value=\"0\" />\r\n    </Collision>\r\n    <DepthOffset dataType=\"Int\">0</DepthOffset>\r\n    <IsVertical dataType=\"Bool\">false</IsVertical>\r\n  </item>\r\n  <!-- etc. -->\r\n</data>\r\n```"}}