{"id":13601203,"url":"https://github.com/protobuf-net/protobuf-net","last_synced_at":"2026-04-06T03:36:31.549Z","repository":{"id":17914865,"uuid":"20878802","full_name":"protobuf-net/protobuf-net","owner":"protobuf-net","description":"Protocol Buffers library for idiomatic .NET ","archived":false,"fork":false,"pushed_at":"2025-07-31T09:46:52.000Z","size":50745,"stargazers_count":4867,"open_issues_count":524,"forks_count":1078,"subscribers_count":222,"default_branch":"main","last_synced_at":"2025-09-05T19:01:36.419Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/protobuf-net.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"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,"zenodo":null},"funding":{"github":["mgravell","protobuf-net"],"custom":["https://www.buymeacoffee.com/marcgravell"]}},"created_at":"2014-06-16T09:05:30.000Z","updated_at":"2025-09-02T18:23:18.000Z","dependencies_parsed_at":"2023-01-14T13:00:43.629Z","dependency_job_id":"187f8638-2542-4245-9998-98116181016b","html_url":"https://github.com/protobuf-net/protobuf-net","commit_stats":{"total_commits":1297,"total_committers":92,"mean_commits":"14.097826086956522","dds":0.5736314572089437,"last_synced_commit":"6bcb835adfa094c04183ba587d71ec514b3749bf"},"previous_names":["mgravell/protobuf-net"],"tags_count":73,"template":false,"template_full_name":null,"purl":"pkg:github/protobuf-net/protobuf-net","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protobuf-net%2Fprotobuf-net","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protobuf-net%2Fprotobuf-net/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protobuf-net%2Fprotobuf-net/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protobuf-net%2Fprotobuf-net/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/protobuf-net","download_url":"https://codeload.github.com/protobuf-net/protobuf-net/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protobuf-net%2Fprotobuf-net/sbom","scorecard":{"id":747220,"data":{"date":"2025-08-18","repo":{"name":"github.com/protobuf-net/protobuf-net","commit":"c064560bdc9a9624fb262515595fc96bfcb8fc0b"},"scorecard":{"version":"v5.2.1-41-g40576783","commit":"40576783fda6698350fcbbeaea760ff827433034"},"score":3.5,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#packaging"}},{"name":"Code-Review","score":5,"reason":"Found 15/30 approved changesets -- score normalized to 5","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":5,"reason":"3 commit(s) and 3 issue activity found in the last 90 days -- score normalized to 5","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#fuzzing"}},{"name":"License","score":9,"reason":"license file detected","details":["Info: project has a license file: Licence.txt:0","Warn: project license file does not contain an FSF or OSI license."],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#license"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#vulnerabilities"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#branch-protection"}},{"name":"Binary-Artifacts","score":0,"reason":"binaries present in source code","details":["Warn: binary detected: assorted/Phone8_DevRig/Phone8DtoSerializer.dll:1","Warn: binary detected: assorted/protobuf-net.Enyim/.nuget/NuGet.exe:1","Warn: binary detected: assorted/protobuf-net.Enyim/packages/EnyimMemcached.2.12/lib/net35/Enyim.Caching.dll:1","Warn: binary detected: assorted/protobuf-net.Enyim/packages/NUnit.2.6.2/lib/nunit.framework.dll:1","Warn: binary detected: assorted/protobuf-net.Enyim/packages/NuGet.CommandLine.2.1.2/tools/NuGet.exe:1","Warn: binary detected: assorted/protobuf-net.Enyim/packages/protobuf-net.2.0.0.602/lib/net20-cf/protobuf-net.dll:1","Warn: binary detected: assorted/protobuf-net.Enyim/packages/protobuf-net.2.0.0.602/lib/net20/protobuf-net.dll:1","Warn: binary detected: assorted/protobuf-net.Enyim/packages/protobuf-net.2.0.0.602/lib/net30/protobuf-net.dll:1","Warn: binary detected: assorted/protobuf-net.Enyim/packages/protobuf-net.2.0.0.602/lib/net35-cf/protobuf-net.dll:1","Warn: binary detected: assorted/protobuf-net.Enyim/packages/protobuf-net.2.0.0.602/lib/net35/protobuf-net.dll:1","Warn: binary detected: assorted/protobuf-net.Enyim/packages/protobuf-net.2.0.0.602/lib/net40-cf/protobuf-net.dll:1","Warn: binary detected: assorted/protobuf-net.Enyim/packages/protobuf-net.2.0.0.602/lib/net40/protobuf-net.dll:1","Warn: binary detected: assorted/protobuf-net.Enyim/packages/protobuf-net.2.0.0.602/lib/netcore45/protobuf-net.dll:1","Warn: binary detected: assorted/protobuf-net.Enyim/packages/protobuf-net.2.0.0.602/lib/portable-sl4+wp71+windows8/protobuf-net.dll:1","Warn: binary detected: assorted/protobuf-net.Enyim/packages/protobuf-net.2.0.0.602/lib/sl3-wp/protobuf-net.dll:1","Warn: binary detected: assorted/protobuf-net.Enyim/packages/protobuf-net.2.0.0.602/lib/sl4-windowsphone71/protobuf-net.dll:1","Warn: binary detected: assorted/protobuf-net.Enyim/packages/protobuf-net.2.0.0.602/lib/sl4/protobuf-net.dll:1","Warn: binary detected: assorted/protobuf-net.Enyim/packages/protobuf-net.2.0.0.602/lib/windowsphone8/protobuf-net.dll:1","Warn: binary detected: src/Tools/Enyim.Caching.dll:1","Warn: binary detected: src/Tools/IKVM.Reflection.dll:1","Warn: binary detected: src/Tools/MiscUtil.dll:1","Warn: binary detected: src/Tools/NHibernate.dll:1","Warn: binary detected: src/Tools/ProtoSharp.Core.dll:1","Warn: binary detected: src/Tools/log4net.dll:1","Warn: binary detected: src/Tools/nunit.framework.dll:1","Warn: binary detected: src/Tools/protoc.exe:1","Warn: binary detected: src/protobuf-net.Reflection.Test/macosx/protoc:1","Warn: binary detected: src/protobuf-net.Reflection.Test/windows/protoc.exe:1","Warn: binary detected: src/protogen.site/wwwroot/protoc/protoc.exe:1"],"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 24 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-22T19:12:01.003Z","repository_id":17914865,"created_at":"2025-08-22T19:12:01.003Z","updated_at":"2025-08-22T19:12:01.003Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273847181,"owners_count":25178641,"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-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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-08-01T18:00:58.346Z","updated_at":"2026-04-06T03:36:31.541Z","avatar_url":"https://github.com/protobuf-net.png","language":"C#","funding_links":["https://github.com/sponsors/mgravell","https://github.com/sponsors/protobuf-net","https://www.buymeacoffee.com/marcgravell"],"categories":["others","C# #","Source Generators","Libraries","Libraries by Language","Serialization","序列化","🗒️ Cheatsheets","工具"],"sub_categories":["Serialization","C# \u0026 .NET","GUI - other","📦 Libraries","开发工具"],"readme":"# protobuf-net\n\n\u003cimg src=\"https://protogen.marcgravell.com/images/protobuf-net.svg\" alt=\"protobuf-net logo\" width=\"45\" height=\"45\"\u003e protobuf-net is a contract based serializer for .NET code, that happens to write data in the \"protocol buffers\" serialization format engineered by Google. The API, however, is very different to Google's, and follows typical .NET patterns (it is broadly comparable, in usage, to `XmlSerializer`, `DataContractSerializer`, etc). It should work for most .NET languages that write standard types and can use attributes.\n\n[![.NET](https://github.com/protobuf-net/protobuf-net/actions/workflows/dotnet.yml/badge.svg)](https://github.com/protobuf-net/protobuf-net/actions/workflows/dotnet.yml)\n\n## Release Notes\n\n[v3 is here!](https://protobuf-net.github.io/protobuf-net/3_0)\n\n[Change history and pending changes are here](https://protobuf-net.github.io/protobuf-net/releasenotes).\n\n---\n\n## Supported Runtimes\n- .NET 6.0+ (.NET 5 etc will use .NET Standard 2.1)\n- .NET Standard 2.0, 2.1\n- .NET Framework 4.6.2+\n\n## Build tools\n\nBuild tools to help you use protobuf-net correctly are [available via `protobuf-net.BuildTools`](https://protobuf-net.github.io/protobuf-net/build_tools)\n\n## Runtime Installation\n\nAll stable and some pre-release packages are available on NuGet. CI Builds are available via MyGet (feed URL: `https://www.myget.org/F/protobuf-net/api/v3/index.json `).\n\nYou can use the following command in the Package Manager Console:\n```ps\nInstall-Package protobuf-net\n```\n\n| Package | NuGet Stable | NuGet Pre-release | Downloads | MyGet |\n| ------- | ------------ | ----------------- | --------- | ----- |\n| [protobuf-net](https://www.nuget.org/packages/protobuf-net/) | [![protobuf-net](https://img.shields.io/nuget/v/protobuf-net.svg)](https://www.nuget.org/packages/protobuf-net/) | [![protobuf-net](https://img.shields.io/nuget/vpre/protobuf-net.svg)](https://www.nuget.org/packages/protobuf-net/) | [![protobuf-net](https://img.shields.io/nuget/dt/protobuf-net.svg)](https://www.nuget.org/packages/protobuf-net/) | [![protobuf-net MyGet](https://img.shields.io/myget/protobuf-net/vpre/protobuf-net.svg)](https://www.myget.org/feed/protobuf-net/package/nuget/protobuf-net) |\n\n## Basic usage\n\n### 1 First Decorate your classes\n```csharp\n[ProtoContract]\nclass Person {\n    [ProtoMember(1)]\n    public int Id {get;set;}\n    [ProtoMember(2)]\n    public string Name {get;set;}\n    [ProtoMember(3)]\n    public Address Address {get;set;}\n}\n[ProtoContract]\nclass Address {\n    [ProtoMember(1)]\n    public string Line1 {get;set;}\n    [ProtoMember(2)]\n    public string Line2 {get;set;}\n}\n```\nNote that unlike XmlSerializer, the member-names are not encoded in the data - instead, you must pick an integer to identify each member. Additionally, to show intent it is necessary to show that we intend this type to be serialized (i.e. that it is a data contract).\n\n### 2 Serialize your data\n\nThis writes a 32 byte file to \"person.bin\" :\n```csharp\nvar person = new Person {\n    Id = 12345, Name = \"Fred\",\n    Address = new Address {\n        Line1 = \"Flat 1\",\n        Line2 = \"The Meadows\"\n    }\n};\nusing (var file = File.Create(\"person.bin\")) {\n    Serializer.Serialize(file, person);\n}\n```\n\n### 3 Deserialize your data\n\nThis reads the data back from \"person.bin\" :\n```csharp\nPerson newPerson;\nusing (var file = File.OpenRead(\"person.bin\")) {\n    newPerson = Serializer.Deserialize\u003cPerson\u003e(file);\n}\n```\n\n### Notes \n\n#### Notes for Identifiers\n\n* they must be positive integers (for best portability, they should be `\u003c= 536870911` and not in the range `19000-19999`)\n* they must be unique within a single type but the same numbers can be re-used in sub-types if inheritance is enabled \n* the identifiers must not conflict with any inheritance identifiers (discussed later) \n* lower numbers take less space - don't start at 100,000,000 \n* the identifier is important; you can change the member-name, or shift it between a property and a field, but changing the identifier changes the data \n\n## Advanced subjects\n\n### Inheritance\n\nInheritance must be explicitly declared, in a similar way that it must for XmlSerializer and DataContractSerializer. This is done via [ProtoInclude(...)] on each type with known sub-types: \n\n```csharp\n[ProtoContract]\n[ProtoInclude(7, typeof(SomeDerivedType))]\nclass SomeBaseType {...}\n\n[ProtoContract]\nclass SomeDerivedType {...}\n```\nThere is no special significance in the 7 above; it is an integer key, just like every [ProtoMember(...)]. It must be unique in terms of SomeBaseType (no other [ProtoInclude(...)] or [ProtoMember(...)] in SomeBaseType can use 7), but does not need to be unique globally. \n\n### .proto file\n\nAs an alternative to writing your classes and decorating them, You can generate your types from a .proto schema using [`protogen`](https://protogen.marcgravell.com/);\nthe `protogen` tool is available as a zip from that location, or [as a \"global tool\"](https://www.nuget.org/packages/protobuf-net.Protogen) (multi-platform).\n\n### Alternative to attributes\n\nIn v2+, everything that can be done with attributes can also be configured at runtime via `RuntimeTypeModel`. The Serializer.* methods are basically just shortcuts to RuntimeTypeModel.Default.*, so to manipulate the behaviour of Serializer.*, you must configure RuntimeTypeModel.Default. \n\n## Support\n\nI try to be responsive to [Stack Overflow questions in the `protobuf-net` tag](https://stackoverflow.com/questions/tagged/protobuf-net), [issues logged on GitHub](https://github.com/protobuf-net/protobuf-net), [email](mailto:marc.gravell@gmail.com), etc. I don't currently offer a paid support channel. If I've helped you, feel free to [buy me a coffee](https://buymeacoff.ee/marcgravell) or see the \"Sponsor\" link [at the top of the GitHub page](https://github.com/protobuf-net/protobuf-net).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprotobuf-net%2Fprotobuf-net","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprotobuf-net%2Fprotobuf-net","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprotobuf-net%2Fprotobuf-net/lists"}