{"id":29622363,"url":"https://github.com/machibuse/porticle.grpc.guidmapper","last_synced_at":"2025-07-21T04:08:47.732Z","repository":{"id":303431903,"uuid":"1014785315","full_name":"Machibuse/Porticle.Grpc.GuidMapper","owner":"Machibuse","description":"User nullable String and Guid properties with GRPC in c#","archived":false,"fork":false,"pushed_at":"2025-07-15T22:07:41.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-16T21:05:29.155Z","etag":null,"topics":["csharp","grpc","guid","nullable-reference-types","protobuf"],"latest_commit_sha":null,"homepage":"","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/Machibuse.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,"zenodo":null}},"created_at":"2025-07-06T12:14:12.000Z","updated_at":"2025-07-15T22:07:44.000Z","dependencies_parsed_at":"2025-07-16T02:25:53.443Z","dependency_job_id":"972add80-9ab9-413b-b784-28b40a956846","html_url":"https://github.com/Machibuse/Porticle.Grpc.GuidMapper","commit_stats":null,"previous_names":["machibuse/porticle.grpc.guidmapper"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/Machibuse/Porticle.Grpc.GuidMapper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Machibuse%2FPorticle.Grpc.GuidMapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Machibuse%2FPorticle.Grpc.GuidMapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Machibuse%2FPorticle.Grpc.GuidMapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Machibuse%2FPorticle.Grpc.GuidMapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Machibuse","download_url":"https://codeload.github.com/Machibuse/Porticle.Grpc.GuidMapper/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Machibuse%2FPorticle.Grpc.GuidMapper/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266237007,"owners_count":23897309,"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":["csharp","grpc","guid","nullable-reference-types","protobuf"],"created_at":"2025-07-21T04:08:47.043Z","updated_at":"2025-07-21T04:08:47.726Z","avatar_url":"https://github.com/Machibuse.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Porticle.Grpc.GuidMapper\n\nA Roslyn-based post-processor for protoc-generated files that adds native Guid, Guid? and string? types in gRPC services.\n\n## Build State\n\n[![Build and Release](https://github.com/Machibuse/Porticle.Grpc.GuidMapper/actions/workflows/release.yaml/badge.svg)](https://github.com/Machibuse/Porticle.CLDR/actions/workflows/release.yaml)  \n\n## Nuget \n\n[![NuGet Latest Version](https://img.shields.io/nuget/v/Porticle.Grpc.GuidMapper.svg)](https://www.nuget.org/packages/Porticle.Grpc.GuidMapper/)  [![NuGet Downloads](https://img.shields.io/nuget/dt/Porticle.Grpc.GuidMapper.svg)](https://www.nuget.org/packages/Porticle.CLDR.Units/)\n\n## Overview\n\nThis library allows you to automatically convert PROTO string or StringValue fields to C# Guid, Guid? or string? types in protoc-generated files, enabling seamless integration of\nGUIDs in your gRPC services without manual conversion\ncode.\n\n## Installation\n\n### Install the package via NuGet:\n```powershell\ndotnet add package Porticle.Grpc.GuidMapper\n```\n\nAfter installing the Package, this Post build step ist dynamically added to your build.\n\n```msbuild\n\u003cProject\u003e\n    \u003cTarget Name=\"RunProtoPostProcessing\" AfterTargets=\"Protobuf_Compile\"\u003e\n        \u003cItemGroup\u003e\n            \u003c_FilesToPostProcess Include=\"$(MSBuildProjectDirectory)\\%(Protobuf_Compile.OutputDir)\\%(Protobuf_Compile.Filename)\" /\u003e\n        \u003c/ItemGroup\u003e\n        \u003cMessage Text=\"Proto Postprocessing\" Importance=\"high\" /\u003e\n        \u003cExec Command=\"dotnet \u0026quot;$(MSBuildThisFileDirectory)..\\tools\\$(TargetFramework)\\Porticle.Grpc.GuidMapper.dll\u0026quot; -- %(_FilesToPostProcess.Identity)\" Condition=\"'@(_FilesToPostProcess)' != ''\" /\u003e\n    \u003c/Target\u003e\n\u003c/Project\u003e\n```\n\nDont wonder ist you cant se it in your csproj file. It is dynamically added when your build is processed.  \n\n## Usage\n\nThere are three things you can do in your .proto files:\n- Add `// [GrpcGuid]` as comment to a string field - Converts the corresponding c# string property to Guid\n- Add `// [GrpcGuid]` as comment to a StringValue field - Converts the corresponding c# string property to Guid?\n- Add `// [NullableString]` as comment to a StringValue field - Converts the corresponding c# string property to string?\n\n\nFirst an Example of a default .proto file\n\n### Without GuidMapper\n```protobuf\nsyntax = \"proto3\";\n\nimport \"google/protobuf/wrappers.proto\";\n\nmessage User {\n  // Guid of the user object   \n  string id = 1;\n\n  // Optional parent UserId\n  google.protobuf.StringValue optional_parent_user_id = 2;\n\n  // Optional description\n  google.protobuf.StringValue description = 3;\n\n  // List of roles \n  repeated string role_ids = 4;\n}\n```\nWill result in generated code like this, everything is a string\n```csharp\n/// \u003csummary\u003eGuid of the user object\u003c/summary\u003e\npublic string Id {\n  get { return id_; }\n  set { id_ = pb::ProtoPreconditions.CheckNotNull(value, \"value\"); }\n}\n\n/// \u003csummary\u003eOptional Guid of the parent UserId\u003c/summary\u003e\npublic string OptionalParentUserId {\n  get { return optionalParentUserId_; }\n  set { optionalParentUserId_ = value; }\n}\n\n/// \u003csummary\u003eOptional description string\u003c/summary\u003e\npublic string Description {\n  get { return description_; }\n  set { description_ = value; }\n}\n\n/// \u003csummary\u003eList of roles\u003c/summary\u003e\npublic pbc::RepeatedField\u003cstring\u003e RoleIds {\n  get { return roleIds_; }\n}\n```\n\n### With GuidMapper\n```protobuf\nsyntax = \"proto3\";\n\nimport \"google/protobuf/wrappers.proto\";\n\nmessage User {\n  // [GrpcGuid] Guid of the user object   \n  string id = 1;\n\n  // [GrpcGuid] Optional Guid of the parent UserId\n  google.protobuf.StringValue optional_parent_user_id = 2;\n\n  // [NullableString] Optional description string\n  google.protobuf.StringValue description = 3;\n\n  // [GrpcGuid] List of roles \n  repeated string role_ids = 4;\n}\n```\nWill result in generated code like this, using string? Guid and Guid?\n```csharp\n/// \u003csummary\u003e[GrpcGuid] Guid of the user object\u003c/summary\u003e\npublic global::System.Guid Id {\n  get { return global::System.Guid.Parse(id_); }\n  set { id_ = (value).ToString(\"D\"); }\n}\n\n/// \u003csummary\u003e[GrpcGuid] Optional Guid of the parent UserId\u003c/summary\u003e\npublic global::System.Guid? OptionalParentUserId {\n  get { if(optionalParentUserId_==null) return default; return global::System.Guid.Parse(optionalParentUserId_); }\n  set { optionalParentUserId_ = (value)?.ToString(\"D\"); }\n}\n\n\n#nullable enable\n/// \u003csummary\u003e[NullableString] Optional description string\u003c/summary\u003e\npublic string? Description {\n  get { return description_; }\n  set { description_ = value; }\n}\n#nullable disable\n\n/// \u003csummary\u003e[GrpcGuid] List of roles\u003c/summary\u003e\npublic IList\u003cGuid\u003e RoleIds {\n  get {return new RepeatedFieldGuidWrapper(roleIds_); }\n}\n```\n\n## What currently is not Possible?\n\n- Mapping `repeated google.protobuf.StringValue` to `List\u003cGuid?\u003e` or `List\u003cstring?\u003e` because grpc internally uses `RepeatedField\u003cstring\u003e` instead of `RepeatedField\u003cStringValue\u003e`.\n  This may be a bug in protoc compiler, because it is also not possible to add `null` to `repeated google.protobuf.StringValue` because ther is a not null check in the Add function in `RepeatedField\u003cT\u003e`\n\n- This Tool actually don't works when protoc / Grpc.Tools is compiled with GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmachibuse%2Fporticle.grpc.guidmapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmachibuse%2Fporticle.grpc.guidmapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmachibuse%2Fporticle.grpc.guidmapper/lists"}