{"id":18498837,"url":"https://github.com/instance-id/tommy.serializer","last_synced_at":"2025-07-11T11:35:33.410Z","repository":{"id":98392539,"uuid":"319161776","full_name":"instance-id/Tommy.Serializer","owner":"instance-id","description":"Extensions for the Tommy toml library","archived":false,"fork":false,"pushed_at":"2020-12-18T00:33:54.000Z","size":164,"stargazers_count":11,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-04T17:18:14.565Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/instance-id.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":"2020-12-07T00:26:09.000Z","updated_at":"2023-01-08T16:18:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"5c50efd4-e433-43d4-8bf2-fec6735befe5","html_url":"https://github.com/instance-id/Tommy.Serializer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/instance-id/Tommy.Serializer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instance-id%2FTommy.Serializer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instance-id%2FTommy.Serializer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instance-id%2FTommy.Serializer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instance-id%2FTommy.Serializer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/instance-id","download_url":"https://codeload.github.com/instance-id/Tommy.Serializer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instance-id%2FTommy.Serializer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264795838,"owners_count":23665241,"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":[],"created_at":"2024-11-06T13:42:44.685Z","updated_at":"2025-07-11T11:35:33.397Z","avatar_url":"https://github.com/instance-id.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Tommy.Serializer\n\nThe primary goal of this library is to add automatic serialization/deserialization of a class instance to the [Tommy Toml library](https://github.com/dezhidki/Tommy).\n\n##### (De)Serialization of a class instance to/from a file has been implemented, along with the ability to work with List\u003cprimitive\u003e, Primitive[], and basic Dictionary\u003cprimitive, primitive\u003e. If more advanced usage is required, just let me know.\n\n\n## Installation\n\nCurrently, to install this extension either download the [extensions file](https://github.com/instance-id/Tommy.Serializer/blob/main/Tommy.Serializer/TommySerializer.cs)\nand add it to your project, or create a new C# script in your project and simply copy and paste the contents of the script.\nI may look into making a nuget package of it as well.\n## Components\n\n \u003cdetails open\u003e\n\u003csummary\u003eAttributes\u003c/summary\u003e\n\n\u003ctable\u003e\n\u003c!-- ---------------------------------------------- --\u003e\n\u003ctr\u003e\n\u003ctd\u003e Attribute \u003c/td\u003e \u003ctd\u003e Usage \u003c/td\u003e \u003ctd\u003e Result \u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ca name=\"tommytablename\"\u003e\u003c/a\u003e\n\u003ctd valign=\"top\" style=\"padding-top: 25px\"\u003e TommyTableName   \u003c/td\u003e\n\u003ctd valign=\"top\"\u003e\n\n```c#\n// Designates a class as a Toml Table and applies all \n// contained properties as children of that table\n[TommyTableName(\"mytablename\")]\npublic class TestData { //... }\n```\n\n\u003c/td\u003e\n\u003ctd valign=\"top\"\u003e\n\n```toml\n[mytablename]\n\n\n  \n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c!-- ---------------------------------------------- --\u003e\n\u003ctr\u003e\n\u003ca name=\"tommycomment\"\u003e\u003c/a\u003e\n\u003ctd valign=\"top\" style=\"padding-top: 25px\"\u003e TommyComment \u003c/td\u003e\n\u003ctd valign=\"top\"\u003e\n\n```c#\n// String value which will be used as a \n// comment for the property/field\n[TommyComment(\" Comment for string property\")]  \npublic string TestString {  get; set; }  = \"Test String\"\n```\n\n\u003c/td\u003e\n\u003ctd valign=\"top\"\u003e\n\n```toml\n# Comment for string property\nTestString = \"Test String\"\n  \n  \n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c!-- ---------------------------------------------- --\u003e\n\u003ctr\u003e\n\u003ca name=\"tommysortorder\"\u003e\u003c/a\u003e\n\u003ctd valign=\"top\" style=\"padding-top: 25px\"\u003e TommySortOrder \u003c/td\u003e\n\u003ctd valign=\"top\"\u003e\n\n```c#\n// Determines the order in which the \n// properties will be written to file\n[TommySortOrder(1)] \n[TommyComment(\" Sort order 1\")]\npublic float TestFloat1 { get; set; } = 234.234f;\n\n[TommySortOrder(0)] \n[TommyComment(\" Sort order 0\")]\npublic float TestFloat0 { get; set; } = 123.123f;\n```\n\n\u003c/td\u003e\n\u003ctd valign=\"top\"\u003e\n\n```toml\n# Sort order 0\nTestFloat0 = 123.123\n\n# Sort order 1\nTestFloat1 = 234.234\n\n\n  \n  \n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c!-- ---------------------------------------------- --\u003e\n\u003ctr\u003e\n\u003ca name=\"tommyinclude\"\u003e\u003c/a\u003e\n\u003ctd valign=\"top\" style=\"padding-top: 25px\"\u003e TommyInclude \u003c/td\u003e\n\u003ctd valign=\"top\"\u003e\n\n```c#\n// Designates a private field to be \n// included by the Tommy processor\n[TommyInclude]\nprivate string testIncludeField = \"I'm private, so what?\";\n```\n\n\u003c/td\u003e\n\u003ctd valign=\"top\"\u003e\n\n```toml\ntestIncludeField = \"I'm private, so what?\"\n\n  \n  \n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c!-- ---------------------------------------------- --\u003e\n\u003ctr\u003e\n\u003ca name=\"tommyignore\"\u003e\u003c/a\u003e\n\u003ctd valign=\"top\" style=\"padding-top: 25px\"\u003e TommyIgnore \u003c/td\u003e\n\u003ctd valign=\"top\"\u003e\n\n```c#\n// Designates a property to be ignored \n// by the Tommy processor\n[TommyIgnore]\npublic string TestIgnoreProperty { get; set; }\n```\n\n\u003c/td\u003e\n\u003ctd valign=\"top\"\u003e\n\n```toml\n \n\n  \n  \n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c/details\u003e\n\n## Usage\n\nWhile attributes are included for specific situations, if a property or field is public, they will be included automatically, unless the [\\[TommyIgnore\\]](#tommyignore) attribute is applied to them.\n\n### Saving to file\n\n---\n\n### Single Data Object to File\n```c#\nusing Tommy.Serializer;\n\nTestData testData = new TestData();\nstring path = \"path/to/TestData.toml\";\n\nTommySerializer.ToTomlFile(testData, path);\n```\n\n### Multiple Data Objects to Single File\n#### NOTE: When outputting multiple data objects to a single file, while not required, it is advised that each data class utilize the [\\[TommyTableName\\]](#tommytablename) attribute to encapsulate the data under the proper table (primarily so that you can choose their table name). If the attribute is omitted, the object's type name is used as the table name automatically.\n\n```c#\nvar testData = new TestData();\nvar testData2 = new TestData2();\nvar path = \"path/to/TestData.toml\";\n\nTommy.Serializer.ToTomlFile(new object[] {testData, testData2}, path);\n```\n\n### Multiple Data Objects to Multiple Files\n\n```c#\nvar testData = new TestData();\nvar path = \"path/to/TestData.toml\";\n\nvar testData2 = new TestData2();\nvar path2 = \"path/to/TestData2.toml\";\n\nTommySerializer.ToTomlFile(testData, path);\nTommySerializer.ToTomlFile(testData, path2);\n```\n\n### Data from file\n\n---\n\n```c#\nvar path = \"path/to/TestData.toml\";\n\nTestData testData  = TommySerializer.FromTomlFile\u003cTestData\u003e(path);\n```\n\n---\n\n## Included Example\n\nIf you download the complete solution from this repo and run the Demo project, it will use the following data class and produce the output file seen below that.\n\n\u003cdetails\u003e\n\u003csummary\u003eData Class\u003c/summary\u003e\n\n```c#\n[TommyTableName(\"tablename\")]\npublic class TestData\n{\n    [TommyInclude]\n    private string TestIncludeProperty { get; set; } = \"I should show up in the created file even when private\";\n\n    [TommyInclude]\n    [TommySortOrder(4)]\n    [TommyComment(@\" Comment for private field\n     This item should appear fifth as it's sort order is : 4\")]\n    private string testIncludePrivateField = \"I should be included even when private\";\n\n    [TommyInclude]\n    [TommySortOrder(3)]\n    [TommyComment(@\" Comment for public field\n     This item should appear fourth as it's sort order is : 3\")]\n    public string TestIncludePublicField = \"Public string Data\";\n\n    [TommyIgnore]\n    public string TestIgnoreProperty { get; set; } = \"I should not show up in the created file\";\n\n    [TommyComment(\" Comment for date property\")]\n    public DateTime TestDateComment { get; set; } = DateTime.Now;\n\n    [TommyComment(\" Comment for string property\\n Testing second line comment\\n\" +\n                  \"This and subsequent items should appear after the sorted properties\")]\n    public string TestStringComment { get; set; } = \"Test String\";\n\n    [TommyComment(@\" This item should be a blank string : Testing null value\")]\n    public string TestNullString { get; set; }\n\n    [TommyComment(@\" Comment testing multiline verbatim strings #1\n     Comment testing multiline verbatim strings #2\n     Comment testing multiline verbatim strings #3\")]\n    public string TestComment { get; set; } = \"Test String\";\n\n    [TommyComment(\" Comment for bool property\")]\n    public bool TestBoolComment { get; set; } = true;\n    public bool TestBool { get; set; }\n\n    [TommyComment(\" Comment for int property\")]\n    public int TestIntComment { get; set; } = 1;\n    public int TestInt { get; set; } = 1;\n\n    [TommySortOrder(1)]\n    [TommyComment(@\" Comment for ulong property  \n     This item should appear second as it's sort order is : 1\")]\n    public ulong TestUlongComment { get; set; } = 444543646457048001;\n    public ulong TestUlong { get; set; } = 444543646457048001;\n\n    [TommySortOrder(2)]\n    [TommyComment(@\" Comment for float property \n     This item should appear third as it's sort order is : 2\")]\n    public float TestFloatComment { get; set; } = 123.123f;\n    public float TestFloat { get; set; } = 123.123f;\n\n    [TommyComment(\" Comment for double property\")]\n    public double TestDoubleComment { get; set; } = 1234.123;\n    public double TestDouble { get; set; } = 1234.123;\n\n    [TommyComment(\" Comment for decimal property\")]\n    public decimal TestDecimalComment { get; set; } = new decimal(0.11);\n    public decimal TestDecimal { get; set; } = new decimal(0.11);\n\n    [TommyComment(\" Comment for IntArray property\")]\n    public int[] TestIntArrayComment { get; set; } = new[] {1, 2, 3, 4};\n\n    [TommySortOrder(0)]\n    [TommyComment(@\" This item should appear first as it's sort order is : 0\")]\n    public int[] TestIntArray { get; set; } = new[] {1, 2, 3, 4};\n\n    [TommyComment(@\" Comment for List\u003cstring\u003e property\")]\n    public List\u003cstring\u003e TestStringListComment { get; set; } = new List\u003cstring\u003e {\"string1\", \"string2\", \"string3\"};\n    public List\u003cstring\u003e TestStringList { get; set; } = new List\u003cstring\u003e {\"string1\", \"string2\", \"string3\"};\n\n    [TommyComment(@\" Comment for ulong array property\")]\n    public ulong[] TestULongArray { get; set; } = new ulong[] {448543646457048001, 448543646457048002, 448543646457048003};\n\n    [TommyComment(@\" Comment for List\u003culong\u003e property\")]\n    public List\u003culong\u003e TestULongList { get; set; } = new List\u003culong\u003e {448543646457048001, 448543646457048002, 448543646457048003};\n\n    [TommyComment(\" Comment for Dictionary\u003cK,V\u003e property\")]\n    public Dictionary\u003cstring, string\u003e TestDictionaryComment { get; set; } =\n        new Dictionary\u003cstring, string\u003e{{\"string1Key\", \"string1Value\"}, {\"string2Key\", \"string2Value\"}};\n\n}\n```\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eOutput of Above Data Class\u003c/summary\u003e\n\n```toml\n[tablename]\n# This item should appear first as it's sort order is : 0\nTestIntArray = [ 1, 2, 3, 4 ]\n\n# Comment for ulong property\n# This item should appear second as it's sort order is : 1\nTestUlongComment = 444543646457048001\n\n# Comment for float property\n# This item should appear third as it's sort order is : 2\nTestFloatComment = 123.123\n\n# Comment for public field\n# This item should appear fourth as it's sort order is : 3\nTestIncludePublicField = \"Public string Data\"\n\n# Comment for private field\n# This item should appear fifth as it's sort order is : 4\ntestIncludePrivateField = \"I should be included even when private\"\n\nTestIncludeProperty = \"I should show up in the created file even when private\"\n\n# Comment for date property\nTestDateComment = 2020-12-13 15:06:18\n\n# Comment for string property\n# Testing second line comment\n# This and subsequent items should appear after the sorted properties\nTestStringComment = \"Test String\"\n\n# This item should be a blank string : Testing null value\nTestNullString = \"\"\n\n# Comment testing multiline verbatim strings #1\n# Comment testing multiline verbatim strings #2\n# Comment testing multiline verbatim strings #3\nTestComment = \"Test String\"\n\n# Comment for bool property\nTestBoolComment = true\n\nTestBool = false\n\n# Comment for int property\nTestIntComment = 1\n\nTestInt = 1\n\nTestUlong = 444543646457048001\n\nTestFloat = 123.123\n\n# Comment for double property\nTestDoubleComment = 1234.123\n\nTestDouble = 1234.123\n\n# Comment for decimal property\nTestDecimalComment = 0.11\n\nTestDecimal = 0.11\n\n# Comment for IntArray property\nTestIntArrayComment = [ 1, 2, 3, 4 ]\n\n# Comment for List\u003cstring\u003e property\nTestStringListComment = [ \"string1\", \"string2\", \"string3\" ]\n\nTestStringList = [ \"string1\", \"string2\", \"string3\" ]\n\n# Comment for ulong array property\nTestULongArray = [ 448543646457048001, 448543646457048002, 448543646457048003 ]\n\n# Comment for List\u003culong\u003e property\nTestULongList = [ 448543646457048001, 448543646457048002, 448543646457048003 ]\n\n# Comment for Dictionary\u003cK,V\u003e property\n[tablename.TestDictionaryComment]\nDictionaryKeys = [ \"string1Key\", \"string2Key\" ]\nDictionaryValues = [ \"string1Value\", \"string2Value\" ]\n\n```\n\n\u003c/details\u003e\n\n## Contributing\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease make sure to update tests as appropriate (once there are some, of course).\n\n## License\n[MIT](https://choosealicense.com/licenses/mit/)\n\n---\n![alt text](https://i.imgur.com/cg5ow2M.png \"instance.id\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finstance-id%2Ftommy.serializer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finstance-id%2Ftommy.serializer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finstance-id%2Ftommy.serializer/lists"}