{"id":16774640,"url":"https://github.com/salarcode/bois","last_synced_at":"2025-04-13T00:44:39.690Z","repository":{"id":25325551,"uuid":"28752582","full_name":"salarcode/Bois","owner":"salarcode","description":"Salar.Bois is a compact, fast and powerful binary serializer for .NET Framework. With Bois you can serialize your existing objects with almost no change.","archived":false,"fork":false,"pushed_at":"2024-11-23T12:22:49.000Z","size":18778,"stargazers_count":63,"open_issues_count":4,"forks_count":10,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-13T00:44:34.908Z","etag":null,"topics":["binary","bois-format","c-sharp","compact","formatter","serialization","serializer"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/salarcode.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-01-03T19:27:01.000Z","updated_at":"2025-03-17T17:20:32.000Z","dependencies_parsed_at":"2023-01-14T03:30:21.200Z","dependency_job_id":"ee69b05c-d722-477e-940a-897274be6876","html_url":"https://github.com/salarcode/Bois","commit_stats":{"total_commits":226,"total_committers":5,"mean_commits":45.2,"dds":"0.017699115044247815","last_synced_commit":"01b543d7c7e24befdff35bef697c895d14734146"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salarcode%2FBois","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salarcode%2FBois/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salarcode%2FBois/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salarcode%2FBois/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/salarcode","download_url":"https://codeload.github.com/salarcode/Bois/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650419,"owners_count":21139672,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binary","bois-format","c-sharp","compact","formatter","serialization","serializer"],"created_at":"2024-10-13T06:49:44.923Z","updated_at":"2025-04-13T00:44:39.665Z","avatar_url":"https://github.com/salarcode.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"Salar.Bois is the most compact, extermly fast binary serializer for .Net Standard, .NET Code and .NET Framework.\n\n* No compression is done, the high compact ratio is the result of Bois format.\n* No configuration.\n* No change to your classes.\n* Compression is provided as a seperate package.\n\n## Why Salar.Bois?\n* Because payload size matters. Bois serializer generates the smallest payload size.\n* Because speed matters. Both serialization and deserialization are extremely fast.\n* Easy to use, `Serialize\u003cT\u003e` and `Deserialize\u003cT\u003e` are all you need.\n* No configuration required. No separate schema required. \n\n## [NuGet Package](https://www.nuget.org/packages/Salar.Bois)\n```\nPM\u003e Install-Package Salar.Bois\n```\n\n[LZ4 Compression wrapper package](https://www.nuget.org/packages/Salar.Bois.LZ4)\n```\nPM\u003e Install-Package Salar.Bois.LZ4\n```\n\n\u003e Minimum frameworks supported are .Net Core 2.0, .Net Standard 2.1 and .Net Framework 4.5\n\n### Getting Started:\nIt is easy to use , just add the package to your project and voila, you can now use it.\n\nAll you need to do is to call `Serialize` method.\n```csharp\nBoisSerializer.Initialize\u003cPerson\u003e();\nvar boisSerializer = new BoisSerializer();\n\nusing (var mem = new MemoryStream())\n{\n\tboisSerializer.Serialize(personInstance, mem);\n\n\treturn mem.ToArray();\n}\n```\nNote: Calling `BoisSerializer.Initialize` is not required at all, but if the performance of application is important to you, it is better to do it at the begining of your application.\n\nHere is the complete example:\n```csharp\npublic class Project\n{\n\tpublic int ID { get; set; }\n\tpublic string Name { get; set; }\n\tpublic string Description { get; set; }\n\tpublic string ProjectUrl { get; set; }\n\tpublic Version Version { get; set; }\n}\n\nclass Program\n{\n\tstatic void Main()\n\t{\n\t\t// Initialize is optional, but recommended for better performance\n\t\tBoisSerializer.Initialize\u003cProject\u003e();\n\n\t\tvar projectInstance = new Project()\n\t\t{\n\t\t\tID = 1,\n\t\t\tName = \"Salar.Bois\",\n\t\t\tProjectUrl = \"https://github.com/salarcode/Bois\",\n\t\t\tVersion = new Version(3, 0, 0, 0),\n\t\t\tDescription = \"Salar.Bois is a compact, fast and powerful binary serializer for .NET Framework.\"\n\t\t};\n\n\t\tvar boisSerializer = new BoisSerializer();\n\n\t\tusing (var file = new FileStream(\"output.data\", FileMode.Create))\n\t\t{\n\t\t\tboisSerializer.Serialize(projectInstance, file);\n\t\t}\n\n\t\t// All done.\n\n\t\t// ...\n\t\t// if you want to have more compression using LZ4 wrapper\n\n\t\tvar boisLz4Serializer = new BoisLz4Serializer();\n\n\t\tusing (var file = new FileStream(\"output-compressed.data\", FileMode.Create))\n\t\t{\n\t\t\tboisLz4Serializer.Pickle(projectInstance, file);\n\t\t}\n\n\t}\n}\n```\n### How to deserialize an object:\n```csharp\nvar boisSerializer = new BoisSerializer();\nreturn boisSerializer.Deserialize\u003cProject\u003e(dataStream);\n\n// and the compressed data\nvar boisLz4Serializer = new BoisLz4Serializer();\nreturn boisLz4Serializer.Unpickle\u003cProject\u003e(dataStream);\n```\n\n## Defining objects\nNothing special is really required. Just these small easy rules.\n\n* Having parameter-less public constructor.\n* Collections/Lists should be generic and implement one of ICollection\u003c\u003e, IList\u003c\u003e or IDictionary\u003c\u003e\n\n## Compression\nThe `BoisLz4Serializer` class is in a separate package called `Salar.Bois.LZ4`. It is provided for anyone looking for more compact serialization. To use it just create a new instance of `BoisLz4Serializer` and to serialize and compress the objects call `Pickle` and to deserialize and uncompress call `Unpickle`.\nPlease note that `BoisLz4Serializer` -for now- is implemented as a wrapper around [LZ4](https://github.com/MiloszKrajewski/K4os.Compression.LZ4).\n\n\n## Bois Format\nIf you are interested to know how Salar.Bois has gain this amazing compact format check out its Bois format wiki page.\n\n[Bois Format Schema](https://github.com/salarcode/Bois/wiki/Bois-Schema-Specs).\n\n## Benchmarks\n\nThe benchmarks sourcecode is available. Every elapsed time is calculated for 5000 iteration (v3.0).\n\nPlease note that in these tests no configuration required for Bois versus attributes required for Avro, Zero, MsPack and ProtoZBuff. Also Zero required the properties to be virtual.\n\n-Serialization against: ArrayTypes with small data\n\nSerializer | \tPayload Size (bytes)  | Serialization | Deserialization | Format | Note\n------------ | ------------ | ------------ | ------------ | ------------ | ------------\nSalar.Bois\t|\t**58**\t|\t6 ms\t|\t5 ms\t|\tBinary \nSalar.Bois.LZ4\t|\t**59**\t|\t25 ms\t|\t6 ms\t|\tBinary \nMicrosoft.Avro\t|\t87\t|\t9 ms\t|\t10 ms\t|\tBinary \nMessagePack\t|\t127\t|\t4 ms\t|\t4 ms\t|\tBinary \nMessagePackLZ4\t|\t125\t|\t18 ms\t|\t5 ms\t|\tBinary \nprotobuf-net\t|\t92\t|\t7 ms\t|\t12 ms\t|\tBinary \nBinaryFormatter\t|\t458\t|\t59 ms\t|\t48 ms\t|\tBinary \nZeroFormatter\t|\t153\t|\t3 ms\t|\t1 ms\t|\tBinary \n\n\n-Serialization against: ArrayTypes with big data\n\nSerializer | \tPayload Size (bytes)  | Serialization | Deserialization | Format | Note\n------------ | ------------ | ------------ | ------------ | ------------ | ------------\nSalar.Bois\t|\t**1400**\t|\t70 ms\t|\t73 ms\t|\tBinary \nSalar.Bois.LZ4\t|\t**1342**\t|\t117 ms\t|\t75 ms\t|\tBinary \nMicrosoft.Avro\t|\t1709\t|\t89 ms\t|\t119 ms\t|\tBinary \nMessagePack\t|\t1951\t|\t19 ms\t|\t28 ms\t|\tBinary \nMessagePackLZ4\t|\t1593\t|\t57 ms\t|\t41 ms\t|\tBinary \nprotobuf-net\t|\t2161\t|\t58 ms\t|\t79 ms\t|\tBinary \nBinaryFormatter\t|\t2641\t|\t52 ms\t|\t50 ms\t|\tBinary \nZeroFormatter\t|\t2336\t|\t11 ms\t|\t1 ms\t|\tBinary \n\n\n-Serialization against: PrimitiveTypes with small data\n\nSerializer | \tPayload Size (bytes)  | Serialization | Deserialization | Format | Note\n------------ | ------------ | ------------ | ------------ | ------------ | ------------\nSalar.Bois\t|\t**74**\t|\t3 ms\t|\t4 ms\t|\tBinary \nSalar.Bois.LZ4\t|\t**75**\t|\t19 ms\t|\t5 ms\t|\tBinary \nMicrosoft.Avro\t|\t77\t|\t4 ms\t|\t3 ms\t|\tBinary \nMessagePack\t|\t161\t|\t7 ms\t|\t3 ms\t|\tBinary \nMessagePackLZ4\t|\t173\t|\t22 ms\t|\t3 ms\t|\tBinary \nprotobuf-net\t|\t91\t|\t6 ms\t|\t7 ms\t|\tBinary \nBinaryFormatter\t|\t671\t|\t72 ms\t|\t79 ms\t|\tBinary \nZeroFormatter\t|\t134\t|\t7 ms\t|\t0 ms\t|\tBinary \n\n\n-Serialization against: ComplexCollections with small data\n\nSerializer | \tPayload Size (bytes)  | Serialization | Deserialization | Format | Note\n------------ | ------------ | ------------ | ------------ | ------------ | ------------\nSalar.Bois\t|\t**82**\t|\t14 ms\t|\t23 ms\t|\tBinary \nSalar.Bois.LZ4\t|\t**81**\t|\t30 ms\t|\t24 ms\t|\tBinary \nMicrosoft.Avro |\t- |\t- |\t- |\tBinary \t| Error\nMessagePack\t|\t171\t|\t27 ms\t|\t19 ms\t|\tBinary \nMessagePackLZ4\t|\t153\t|\t42 ms\t|\t21 ms\t|\tBinary \nprotobuf-net\t|\t150\t|\t17 ms\t|\t34 ms\t|\tBinary \nBinaryFormatter\t|\t10852\t|\t636 ms\t|\t612 ms\t|\tBinary \nZeroFormatter |\t- |\t- |\t- |\tBinary |    Not supported\n\n\n-Serialization against: ComplexCollections with big data\n\nSerializer | \tPayload Size (bytes)  | Serialization | Deserialization | Format | Note\n------------ | ------------ | ------------ | ------------ | ------------ | ------------\nSalar.Bois\t|\t**10414**\t|\t356 ms\t|\t411 ms\t|\tBinary \nSalar.Bois.LZ4\t|\t**7628**\t|\t837 ms\t|\t483 ms\t|\tBinary \nMicrosoft.Avro |\t- |\t- |\t- |\tBinary \t |   Error\nMessagePack\t|\t11013\t|\t796 ms\t|\t301 ms\t|\tBinary \nMessagePackLZ4\t|\t7636\t|\t28 ms\t|\t390 ms\t|\tBinary \nprotobuf-net\t|\t14865\t|\t7 ms\t|\t265 ms\t|\tBinary \nBinaryFormatter\t|\t34751\t|\t961 ms\t|\t488 ms\t|\tBinary \nZeroFormatter |\t- |\t- |\t- |\tBinary |    Not supported\n\n-Serialization against: ComplexContainer Collections\n\nSerializer | \tPayload Size (bytes)  | Serialization | Deserialization | Format | Note\n------------ | ------------ | ------------ | ------------ | ------------ | ------------\nSalar.Bois\t|\t**120**\t|\t9 ms\t|\t11 ms\t|\tBinary \nSalar.Bois.LZ4\t|\t**114**\t|\t27 ms\t|\t12 ms\t|\tBinary \nMicrosoft.Avro | - |\t- |\t- |\tBinary | Not supported\nMessagePack |\t- |\t- |\t- |\tBinary |    Not supported\nprotobuf-net\t|\t171\t|\t14 ms\t|\t24 ms\t|\tBinary \nBinaryFormatter\t|\t7396\t|\t379 ms\t|\t475 ms\t|\tBinary \nZeroFormatter | - |\t- |\t- |\tBinary |    Not supported\n\n\n-Serialization against: SpecializedCollections\n\nSerializer | \tPayload Size (bytes)  | Serialization | Deserialization | Format | Note\n------------ | ------------ | ------------ | ------------ | ------------ | ------------\nSalar.Bois\t|\t**28**\t|\t9 ms\t|\t17 ms\t|\tBinary \nSalar.Bois.LZ4\t|\t**29**\t|\t22 ms\t|\t17 ms\t|\tBinary \nMicrosoft.Avro | - | - | - | Binary | Invalid Result\nMessagePack | - | - | - | Binary | Not supported\nMessagePackLZ4 | - | - | - | Binary | Not supported\nprotobuf-net| - | - | - |\tBinary | Not supported\nBinaryFormatter\t|\t2515\t|\t763 ms\t|\t285 ms\t|\tBinary \nZeroFormatter | - | - | - |\tBinary | Not supported\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalarcode%2Fbois","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsalarcode%2Fbois","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalarcode%2Fbois/lists"}