GithubHelp home page GithubHelp logo

anthrax3 / protobufgenerator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from halotron/protobufgenerator

0.0 1.0 0.0 100 KB

NOT MAINTAINED ANYMORE. A plugin to Visual Studio that will automatically transform protobuf proto-files into generated C# code, using protoc.exe or GRPC

License: MIT License

C# 98.52% PowerShell 1.48%

protobufgenerator's Introduction

ProtobufGenerator

NOTE: Currently this is not maintained anymore due to lack of time and altered priorities.

A plugin for Visual Studio that will automatically transform protobuf proto-files into generated C# code. Currently it does not support a proto file with declarations from a different file. Everything needed in the proto file needs to be in the proto file.

GRPC is supported as well. See below.

How to use it:

  1. Install the ProtobufGenerator VSIX file from here: https://marketplace.visualstudio.com/items?itemName=jonasjakobsson.ProtobufGeneratorvisualstudio
  2. Add "ProtobufGenerator" as Custom Tool for any proto file in your solution. (look in properties for the file)
  3. If everything is OK, a C# file will be created as a child of the proto file after any changes. If not, see below.

PREREQUISITE: Protoc.exe, contained in the nuget package Google.Protobuf.Tools, needs to be somewhere on your system. NOT necessarily in the project you are working with. But the easiest option might be to just install Google.Protobuf.Tools in your project.

It searches for protoc.exe in these locations in order:

  1. Is protoc.exe in your system path.
  2. Is Protoc.exe in your packages folder under your profile directory? In my case that is c:\Users\jonas\.nuget\packages\Google.Protobuf.Tools....
  3. Then it searches in the current folder of the proto-file being generated from. If it finds a packages-folder it will search for Google.Protobuf.Tools inside of that.
  4. It will search in parent directories of the generated file for the packages folder. So if your packages folder is c:\src\packages it will find the Google.Protobuf.Tools there if the file being generated is in c:\src\some\distant\folder\hello.proto

GRPC support: Use "ProtobufGeneratorGRPC" instead of "ProtobufGenerator". Same story: Grpc needs to be somewhere...

Logging: outputs logging and the complete command that is executed to the general output pane in visual studio, or to the debug pane, if for some reason output pane is not available.

Protobuf Argument Support :boom: Waring this may have unintended consequences :boom: Support for extra protoc cli arguments is provided on a per file basis by placing a comment of the form // ProtobufGenerator-Arg:arg_name:arg_value. This will generate the following input to protoc --arg_name arg_value. Arguments may be defined multiple times which may be helpful in the case of proto path (note all import paths are relative to file being transformed). Example

/// ProtobufGenerator-Arg:proto_path:../packages/Google.Protobuf.Tools.3.6.1/tools/
/// ProtobufGenerator-Arg:proto_path:../OtherLibrary/

syntax = "proto3";

import "google/protobuf/timestamp.proto";
import "SharedProtos.proto";

The above example generates the following parameters to be passed to protoc --proto_path ../packages/Google.Protobuf.Tools.3.6.1/tools/ --proto_path ../OtherLibrary

Currently supports Visual Studio 2017 and might work with 2013 and 2015 as well. Try it and report on your success.

protobufgenerator's People

Contributors

cactuaroid avatar halotron avatar piksel avatar pme-abvaden avatar

Watchers

 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.