A lightweight utility that converts C# POCO classes into .proto message definitions for gRPC, automatically. Supports simple types, lists, arrays, and nullable types, with snake_case field naming. Designed to be simple, clean, and dependency-free.
$ dotnet add package Poco2ProtoConvert simple C# POCO classes into .proto message definitions for gRPC, automatically.
This library is designed to be lightweight, simple, and dependency-free and ideal for quickly generating Protobuf message contracts from your existing models.
.proto message fieldsstring, numeric types, bool, byte[]List<T> and arrays (repeated fields)int?, bool?, etc.)snake_caseDateTime to string (simple & practical)
Install-Package Poco2Proto
dotnet add package Poco2Proto
public class UserProfile
{
public string FullName { get; set; }
public int? Age { get; set; }
public bool IsActive { get; set; }
public List<string> Roles { get; set; }
public string[] Tags { get; set; }
}
.protousing Poco2Proto;
string proto = Poco2Proto.GenerateProto<UserProfile>();
Console.WriteLine(proto);
// Or save to file
File.WriteAllText("UserProfile.proto", proto);
syntax = "proto3";
package YourNamespace;
message UserProfile {
string full_name = 1;
int32 age = 2;
bool is_active = 3;
repeated string roles = 4;
repeated string tags = 5;
}
You can now place this .proto file in your gRPC project and compile it with protoc.
This package is intentionally simple and works best when:
.proto definitions as a starting point and refine manually if neededFuture enhancements may include:
Pull requests are welcome! If you'd like to extend the mapper behavior, open an issue or submit a PR.
Check the repository.