{"id":22538405,"url":"https://github.com/shuttle/shuttle.core.serialization","last_synced_at":"2025-07-22T02:37:06.110Z","repository":{"id":46824018,"uuid":"116023512","full_name":"Shuttle/Shuttle.Core.Serialization","owner":"Shuttle","description":"Serialization adapter.","archived":false,"fork":false,"pushed_at":"2025-02-02T12:06:05.000Z","size":95,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T20:44:06.873Z","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":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Shuttle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2018-01-02T14:26:45.000Z","updated_at":"2025-02-02T12:04:08.000Z","dependencies_parsed_at":"2024-06-21T05:47:27.420Z","dependency_job_id":"da8b7084-ebc9-49c1-a7f4-36afe8b67522","html_url":"https://github.com/Shuttle/Shuttle.Core.Serialization","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/Shuttle/Shuttle.Core.Serialization","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shuttle%2FShuttle.Core.Serialization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shuttle%2FShuttle.Core.Serialization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shuttle%2FShuttle.Core.Serialization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shuttle%2FShuttle.Core.Serialization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Shuttle","download_url":"https://codeload.github.com/Shuttle/Shuttle.Core.Serialization/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shuttle%2FShuttle.Core.Serialization/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266413462,"owners_count":23924735,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-12-07T11:11:55.195Z","updated_at":"2025-07-22T02:37:06.085Z","avatar_url":"https://github.com/Shuttle.png","language":"C#","readme":"# Shuttle.Core.Serialization\n\n```\nPM\u003e Install-Package Shuttle.Core.Serialization\n```\n\nThe following implementations of the `ISerializer` interface is used to serialize objects into a `Stream`:\n\n- `XmlSerializer` makes use of the standard .NET XML serialization functionality.\n- `JsonSerializer` makes use of the `System.Test.Json` serialization functionality.\n\n## Usage\n\n### XmlSerializer\n\n``` c#\nservices.AddXmlSerializer(builder =\u003e {\n\tbuilder.Options = new XmlSerializerOptions \n\t{\n\t};\n\n\t// or\n\n\tbuidler.Options.option = value;\n});\n```\n\nThe `builder.Options` contains properties that map to [XmlWriterSettings](https://learn.microsoft.com/en-us/dotnet/api/system.xml.xmlwritersettings?view=net-8.0) as well as [XmlDictionaryReaderQuotas](https://learn.microsoft.com/en-us/dotnet/api/system.xml.xmldictionaryreaderquotas?view=net-8.0).\n\n### JsonSerializer\n\n``` c#\nservices.AddJsonSerializer(builder =\u003e {\n\tbuilder.Options = new JsonSerializerOptions \n\t{\n\t};\n\n\t// or\n\n\tbuidler.Options.option = value;\n});\n```\n\nThe `builder.Options` is of type [JsonSerializerOptions](https://docs.microsoft.com/en-us/dotnet/api/system.text.json.jsonserializeroptions?view=net-6.0).\n\n## Methods\n\n### Serialize\n\n``` c#\nTask\u003cStream\u003e SerializeAsync(object message);\n```\n\nReturns the message `object` as a `Stream`.\n\n### Deserialize\n\n``` c#\nTask\u003cobject\u003e DeserializeAsync(Type type, Stream stream);\n```\n\nDeserializes the `Stream` into an `object` of the given type.\n\n## ISerializerRootType\n\nThe `XmlSerializer` implements the `ISerializerRootType` interface which is an optional interface that serializer implementations can use that allows the developer to specify explicit object types contained within a root type.  \n\nIt is recommended that you explicitly register types with the same name, but in different namespaes, that will be serialized within the same root type to avoid any conflicts later down the line.\n\nFor instance, the following two types will cause issues when used in the root `Complex` type as they both serialize to the same name and the .Net serializer cannot seem to distinguish the difference:\n\n``` c#\nnamespace Serializer.v1\n{\n\tpublic class MovedEvent\n\t{\n\t\tpublic string Where { get; set; } \n\t}\n}\n\nnamespace Serializer.v2\n{\n\tpublic class MovedEvent\n\t{\n\t\tpublic string Where { get; set; } \n\t}\n}\n\nnamespace Serializer\n{\n\tpublic class Complex\n\t{\n\t\tpublic v1.MovedEvent { get; set; }\n\t\tpublic v2.MovedEvent { get; set; }\n\t}\n}\n```\n\nBy explicitly specifying the types the `XmlSerializer` will add a namespace that will cause the types to be correctly identified.\n\n### AddSerializerType\n\n``` c#\nvoid AddSerializerType(Type root, Type contained);\n```\n\nSpecify the `contained` type that is used within the `root` type.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshuttle%2Fshuttle.core.serialization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshuttle%2Fshuttle.core.serialization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshuttle%2Fshuttle.core.serialization/lists"}