GithubHelp home page GithubHelp logo

protoc-gen-myplugincsharp's Introduction

protoc (Protocol Buffers Compiler) plugin sample in C#. protoc gives parsed input .proto to the plugin as CodeGeneratorRequest object via standard input. The plugin shall put CodeGeneratorResponse object to standard output to generate text file.

You cannot execute the plugin itself but you can attach debugger by calling System.Diagnostics.Debugger.Launch().

See https://github.com/cactuaroid/protoc-gen-opcua for further example.

Input chat.proto1
syntax = "proto3";

// well known types
import "google/protobuf/timestamp.proto";
import "google/protobuf/empty.proto";

option csharp_namespace = "GrpcChatSample.Common";

package GrpcChatSample.Common;

service Chat {
  rpc Write(ChatLog) returns (google.protobuf.Empty) {}
  rpc Subscribe(google.protobuf.Empty) returns (stream ChatLog) {}
}

message ChatLog {
	string name = 1;
	string content = 2;
	google.protobuf.Timestamp at = 3;
}
Command Line

protoc.exe --plugin=protoc-gen-myplugincsharp.exe --myplugincsharp_out=./ --proto_path=%userprofile%\.nuget\packages\google.protobuf.tools\3.21.1\tools --proto_path=./ chat.proto

Output chat.proto.txt
service Cha
   .google.protobuf.Empty Write(.GrpcChatSample.Common.ChatLog)
   .GrpcChatSample.Common.ChatLog Subscribe(.google.protobuf.Empty)
message Timestamp
    seconds
    nanos
message Empty
message ChatLog
    name
    content
   .google.protobuf.Timestamp at

Footnotes

  1. https://github.com/cactuaroid/GrpcWpfSample/blob/master/grpc-dotnet/GrpcChatSample2.Common/chat.proto โ†ฉ

protoc-gen-myplugincsharp's People

Contributors

cactuaroid avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.