{"action":"created","issue":{"url":"https://api.github.com/repos/jefffhaynes/BinarySerializer/issues/52","repository_url":"https://api.github.com/repos/jefffhaynes/BinarySerializer","labels_url":"https://api.github.com/repos/jefffhaynes/BinarySerializer/issues/52/labels{/name}","comments_url":"https://api.github.com/repos/jefffhaynes/BinarySerializer/issues/52/comments","events_url":"https://api.github.com/repos/jefffhaynes/BinarySerializer/issues/52/events","html_url":"https://github.com/jefffhaynes/BinarySerializer/issues/52","id":196463014,"number":52,"title":"Should I use value converter or a custom serialization?","user":{"login":"FYGonzalo","id":8304703,"avatar_url":"https://avatars.githubusercontent.com/u/8304703?v=3","gravatar_id":"","url":"https://api.github.com/users/FYGonzalo","html_url":"https://github.com/FYGonzalo","followers_url":"https://api.github.com/users/FYGonzalo/followers","following_url":"https://api.github.com/users/FYGonzalo/following{/other_user}","gists_url":"https://api.github.com/users/FYGonzalo/gists{/gist_id}","starred_url":"https://api.github.com/users/FYGonzalo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FYGonzalo/subscriptions","organizations_url":"https://api.github.com/users/FYGonzalo/orgs","repos_url":"https://api.github.com/users/FYGonzalo/repos","events_url":"https://api.github.com/users/FYGonzalo/events{/privacy}","received_events_url":"https://api.github.com/users/FYGonzalo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-12-19T16:45:01Z","updated_at":"2016-12-20T00:58:14Z","closed_at":null,"body":"Hello, first of all I am sorry if this isn't the correct place to ask, I am not so familiar with github.\r\n\r\nThis framework is amazing, I'm glad that I found it, but I am a bit confused about Value Converter.\r\nI have a packet structure where one of its props is the payload length (as UInt16), it comes \"ciphered\" (xor with 0x1357) and I am not sure if this is the proper use for a Value Converter.\r\n\r\nThis is most because I don't get why I can't set a ConverterType for FieldOrder, maybe because the length result from the convert may be different of the field size? \r\nI know I can set a the converter as a proper of FieldSize but then I am defining the size two times because I already have set the variable as UInt16. \r\n\r\nAnyway, really sorry if this is not the correct place or my question offends you (I don't know if my question is stupid), I readed the readme many times but I don't get it.\r\n\r\nThank!\r\n\r\n**EDIT:** nvm, I misunderstood all, value converter is for bindings (https://github.com/jefffhaynes/BinarySerializer/issues/19). Seems like the proper way to do this is having some method that \"cipher\" all the header before serializing the packet, and decipher after deserializing it.\r\nLooks like I did not read well all readme (excuse me, english is not my native language).\r\n\r\n**EDIT2:** I think this will be a good moment to use a custom serialization, What do you think? The code will be cleaner and will abstract all the packet processing (encryption, compression and checksum), is there something I am missing or its so good as it sounds?\r\n"},"comment":{"url":"https://api.github.com/repos/jefffhaynes/BinarySerializer/issues/comments/268123402","html_url":"https://github.com/jefffhaynes/BinarySerializer/issues/52#issuecomment-268123402","issue_url":"https://api.github.com/repos/jefffhaynes/BinarySerializer/issues/52","id":268123402,"user":{"login":"FYGonzalo","id":8304703,"avatar_url":"https://avatars.githubusercontent.com/u/8304703?v=3","gravatar_id":"","url":"https://api.github.com/users/FYGonzalo","html_url":"https://github.com/FYGonzalo","followers_url":"https://api.github.com/users/FYGonzalo/followers","following_url":"https://api.github.com/users/FYGonzalo/following{/other_user}","gists_url":"https://api.github.com/users/FYGonzalo/gists{/gist_id}","starred_url":"https://api.github.com/users/FYGonzalo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FYGonzalo/subscriptions","organizations_url":"https://api.github.com/users/FYGonzalo/orgs","repos_url":"https://api.github.com/users/FYGonzalo/repos","events_url":"https://api.github.com/users/FYGonzalo/events{/privacy}","received_events_url":"https://api.github.com/users/FYGonzalo/received_events","type":"User","site_admin":false},"created_at":"2016-12-20T00:58:14Z","updated_at":"2016-12-20T00:58:14Z","body":"Yeah, I was a little confused about how works FieldLength and now I figured that when the field is serialized, the frameworks set the length to the field that FieldLength is pointer.\r\n\r\nI am having another problem now with an enum, I don't really know whats going on.\r\nWhen I try serialize my objects I get an exception:\r\n> An unhandled exception of type 'System.InvalidOperationException' occurred in BinarySerializer.dll\r\n> Additional information: There was an error reflecting member 'OperationCode'\r\n\r\n\r\n```c#\r\n\r\n    public enum AOOperationCodes : UInt16\r\n    {\r\n        CipherKey = ((UInt16)(0x0000)),\r\n        LoginData = ((UInt16)(0x0000)),\r\n    }\r\n\r\n    class AOMessage\r\n    {\r\n        [Ignore]\r\n        private AOOperationCodes operationCode;\r\n\r\n        [Ignore]\r\n        private AOObject aoObject; \r\n\r\n        [FieldOrder(0)]\r\n        public AOOperationCodes OperationCode\r\n        {  get { return operationCode;  } set { operationCode = value; } }\r\n\r\n        [FieldOrder(1)]\r\n        public AOObject AoObject\r\n        { get { return aoObject; } set { aoObject = value; }  }\r\n\r\n        public AOMessage(AOObject aoObject)\r\n        {\r\n            this.aoObject = aoObject;\r\n            operationCode = this.aoObject.GetOperationCode();\r\n        }\r\n        public AOMessage() { }\r\n    }\r\n```\r\n\r\nAlso had a problem with a custom serialization that uses a Queue, the constructor creates a new queue and then I fill that queue from another class and all goes ok, but when I try serialize it, the queue is empty, solved this using a List but I wish know if there is something I am missing, already checked my code and I never call the constructor again or something like that but the constructor is called twice.\r\n\r\nIf you want to take a deep look into my code (Just in case you want to see something else) , here is where I define all the clases to be serialized:\r\nhttps://github.com/FYGonzalo/DevilsHateLS/blob/master/DevilsHateLS/AOProtocol.cs\r\n\r\nAnd here is where I serialize all those objects\r\nhttps://github.com/FYGonzalo/DevilsHateLS/blob/master/DevilsHateLS/AOOutgoingMessageManager.cs\r\n\r\nJust a short explanation of what I am doing so if you read my code may be easier to understand:\r\nI am emulating a game server. Each TCP packet has a 6 bytes header, the first ushort has the payload length, the next ushort has the number of messages (AKA objects or classes) contained in the payload, the next ushort indicates if the payload is encrypted or compressed and the last is byte is checksum.\r\nI created a custom serializator for a class I called \"AOPacketPayload\" because the payload can be encrypted or compressed, so there I can write all the code to decompress or decipher it (I didn't wrote that yet).\r\nAfter that, the payload becomes an array of messages, because an unencrypted payload should look like this:\r\n[FirstMessageLength][FirstMessage],[SecondMessageLength][SecondMessage],...\r\nEach message comes with an operation code that identifiques the class that it belongs, and the rest of bytes are the props of each class.\r\n[OperationCode][ObjectData]\r\n\r\n"}}
{"actor":{"display_login":"FYGonzalo"}}