You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+42-11Lines changed: 42 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
# Porticle.Grpc.TypeMapper
2
2
3
-
A Roslyn-based post-processor for protoc-generated files that adds automatic mappings for `Guid`, `Guid?`, `string?` or nullable enums. By simply adding this package and adding
3
+
A Roslyn-based post-processor for protoc-generated files that adds automatic mappings for `Guid`, `Guid?`, `decimal`, `decimal?`, `string?` or nullable enums. By simply adding this
4
+
package and adding
4
5
comments to
5
6
your `.proto` file.
6
7
@@ -18,19 +19,21 @@ This library adds automatic conversion for:
18
19
19
20
- Protobuf string to C# Guid
20
21
- Protobuf google.Protobuf.StringValue to C# Guid?
22
+
- Protobuf string to C# decimal
23
+
- Protobuf google.Protobuf.StringValue to C# decimal?
21
24
- Protobuf google.Protobuf.StringValue to C# string?
22
25
- Protobuf optional enum to C# nullable enum
23
26
24
27
This Library adds a Roslyn Postprocessing zu the c# files generated by the protoc compiler.
25
-
Enabling seamless integration of Guid, Guid?, string?, nullable Enums and `NRT Support` in your gRPC services without manual conversion.
28
+
Enabling seamless integration of Guid, Guid?, decimal, decimal?, string?, nullable Enums and `NRT Support` in your gRPC services without manual conversion.
26
29
Code.
27
30
28
31
## TL/DR
29
32
30
33
- Add `// [GrpcGuid]` as comment to a string or StringValue proto field to get Guid/Guid? in generated c# code
34
+
- Add `// [Decimal]` as comment to a string or StringValue proto field to get decimal/decimal? in generated c# code
31
35
- Add `// [NullableString]` as comment to a string or StringValue proto field to get string? in generated c# code
32
36
- Add `// [NullableEnum]` as comment to an optional enum proto field to get MyEnum? in generated c# code
33
-
- Add `// [NullableEnum]` as comment to an optional enum proto field to get MyEnum? in generated c# code
34
37
- Add PorticleGrpcTypeMapper_WrapAllNonNullableStrings as Property to your Project to wrap all not nullable proto stings in #nullable enable/disable
35
38
- Add PorticleGrpcTypeMapper_WrapAllNullableStrings as Property to your Project to wrap all proto StringValue fields in #nullable enable/disable and change `string` to `string?`
36
39
@@ -66,6 +69,8 @@ There are three things you can do in your .proto files:
66
69
67
70
- Add `// [GrpcGuid]` as comment to a string field - Converts the corresponding c# string property to Guid
68
71
- Add `// [GrpcGuid]` as comment to a StringValue field - Converts the corresponding c# string property to Guid?
72
+
- Add `// [Decimal]` as comment to a string field - Converts the corresponding c# string property to decimal
73
+
- Add `// [Decimal]` as comment to a StringValue field - Converts the corresponding c# string property to decimal?
69
74
- Add `// [NullableString]` as comment to a StringValue field - Converts the corresponding c# string property to string?
70
75
- Add `// [NullableEnum]` as comment to a optional enum field - Converts the corresponding optional proto enum to a C# nullable Enum
71
76
@@ -96,7 +101,10 @@ message User {
96
101
// List of roles
97
102
repeated string role_ids = 4;
98
103
99
-
// Simple Enum
104
+
// Price of the item
105
+
string price = 6;
106
+
107
+
// Simple Enum
100
108
optional TestEnum foo_bar = 5;
101
109
}
102
110
```
@@ -127,12 +135,18 @@ public pbc::RepeatedField<string> RoleIds {
127
135
get { returnroleIds_; }
128
136
}
129
137
138
+
/// <summary>Price of the item</summary>
139
+
publicstringPrice {
140
+
get { returnprice_; }
141
+
set { price_=pb::ProtoPreconditions.CheckNotNull(value, "value"); }
0 commit comments