From the course: Learning ASP.NET Core: MVC, Razor Pages, Web APIs & Other Foundations

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Creating a .proto file

Creating a .proto file

- [Instructor] Let's now see how to define a GRPC service contract with a proto file. I'm going to start with the default greet.proto file that came with the project template. I'm going to show you some of the basic syntax, but I'll also encourage you to check out the official documentation at protobuf.dev. The first line here just declares which version of the proto syntax we'll be using, proto3 in this case. Line three assigns a value to the C# namespace option. By default, the value is just the name of the project I created with the dash replaced with an underscore. When I use the available tooling to generate C# code from this file, it will be placed inside a C# namespace with this value. The package declaration on line five is optional and used to prevent name clashes between message types. This will be used and interpreted differently based on which programming language you plan on using. The service specifier on line eight declares a name for the service. Inside the curly…

Contents