Skip to content

Commit d2980e1

Browse files
authored
Add create Proto file document (#189)
* Create createProtoFile.md * Update index.md * Update createProtoFile.md
1 parent d772b6a commit d2980e1

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

docs/createProtoFile.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# protobuf-net.Reflection
2+
3+
## What is it?
4+
5+
> ProtoBuf DSL (proto2 / proto3) and descriptor tools for protobuf-net
6+
7+
It use to create .proto file for your service
8+
9+
## Install?
10+
11+
Install [`protobuf-net.Reflection`](https://www.nuget.org/packages/protobuf-net.Reflection) on your project
12+
13+
## How use it?
14+
15+
After install change your service and add these lines:
16+
17+
``` c#
18+
var generator = new SchemaGenerator
19+
{
20+
ProtoSyntax = ProtoSyntax.Proto3
21+
};
22+
23+
var schema = generator.GetSchema<ICalculator>(); // there is also a non-generic overload that takes Type
24+
25+
using (var writer = new System.IO.StreamWriter("services.proto"))
26+
{
27+
await writer.WriteAsync(schema);
28+
}
29+
```
30+
31+
Now build your project. Your .proto file is exist on your bin/Debug or bin/Realase
32+
33+
Output example:
34+
35+
```c#
36+
syntax = "proto3";
37+
package Hyper;
38+
39+
message MultiplyRequest {
40+
int32 X = 1;
41+
int32 Y = 2;
42+
}
43+
message MultiplyResult {
44+
int32 Result = 1;
45+
}
46+
service Calculator {
47+
rpc Multiply (MultiplyRequest) returns (MultiplyResult);
48+
}
49+
```

docs/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
- [Getting Started](gettingstarted)
44
- [Configuration Options](configuration)
55
- [Package Layout](projects)
6+
- [Create Proto File](createProtoFile)
67

78
Other Content
89

9-
- [My talk on gRPC at the .NET Core Summer Event, 2019](talks/gRPC.pptx)
10+
- [My talk on gRPC at the .NET Core Summer Event, 2019](talks/gRPC.pptx)

0 commit comments

Comments
 (0)