Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
cd1dc3f0
Commit
cd1dc3f0
authored
Jun 28, 2017
by
Yilun Chong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add csharp support
parent
36450210
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
12 deletions
+57
-12
Conformance.cs
csharp/src/Google.Protobuf.Conformance/Conformance.cs
+41
-10
Program.cs
csharp/src/Google.Protobuf.Conformance/Program.cs
+16
-2
No files found.
csharp/src/Google.Protobuf.Conformance/Conformance.cs
View file @
cd1dc3f0
...
...
@@ -22,21 +22,21 @@ namespace Conformance {
static
ConformanceReflection
()
{
byte
[]
descriptorData
=
global
::
System
.
Convert
.
FromBase64String
(
string
.
Concat
(
"ChFjb25mb3JtYW5jZS5wcm90bxILY29uZm9ybWFuY2Ui
jQ
EKEkNvbmZvcm1h"
,
"ChFjb25mb3JtYW5jZS5wcm90bxILY29uZm9ybWFuY2Ui
ow
EKEkNvbmZvcm1h"
,
"bmNlUmVxdWVzdBIaChBwcm90b2J1Zl9wYXlsb2FkGAEgASgMSAASFgoManNv"
,
"bl9wYXlsb2FkGAIgASgJSAASOAoXcmVxdWVzdGVkX291dHB1dF9mb3JtYXQY"
,
"AyABKA4yFy5jb25mb3JtYW5jZS5XaXJlRm9ybWF0
QgkKB3BheWxvYWQisQEK
"
,
"
E0NvbmZvcm1hbmNlUmVzcG9uc2USFQoLcGFyc2VfZXJyb3IYASABKAlIABIZ
"
,
"C
g9zZXJpYWxpemVfZXJyb3IYBiABKAlIABIXCg1ydW50aW1lX2Vycm9yGAIg
"
,
"
ASgJSAASGgoQcHJvdG9idWZfcGF5bG9hZBgDIAEoDEgAEhYKDGpzb25fcGF5
"
,
"
bG9hZBgEIAEoCUgAEhEKB3NraXBwZWQYBSABKAlIAEIICgZyZXN1bHQqNQoK
"
,
"
V2lyZUZvcm1hdBIPCgtVTlNQRUNJRklFRBAAEgwKCFBST1RPQlVGEAESCAoE
"
,
"
SlNPThACQiEKH2NvbS5nb29nbGUucHJvdG9idWYuY29uZm9ybWFuY2ViB
nBy"
,
"b3Rv
Mw=
="
));
"AyABKA4yFy5jb25mb3JtYW5jZS5XaXJlRm9ybWF0
EhQKDG1lc3NhZ2VfdHlw
"
,
"
ZRgEIAEoCUIJCgdwYXlsb2FkIrEBChNDb25mb3JtYW5jZVJlc3BvbnNlEhUK
"
,
"C
3BhcnNlX2Vycm9yGAEgASgJSAASGQoPc2VyaWFsaXplX2Vycm9yGAYgASgJ
"
,
"
SAASFwoNcnVudGltZV9lcnJvchgCIAEoCUgAEhoKEHByb3RvYnVmX3BheWxv
"
,
"
YWQYAyABKAxIABIWCgxqc29uX3BheWxvYWQYBCABKAlIABIRCgdza2lwcGVk
"
,
"
GAUgASgJSABCCAoGcmVzdWx0KjUKCldpcmVGb3JtYXQSDwoLVU5TUEVDSUZJ
"
,
"
RUQQABIMCghQUk9UT0JVRhABEggKBEpTT04QAkIhCh9jb20uZ29vZ2xlL
nBy"
,
"b3Rv
YnVmLmNvbmZvcm1hbmNlYgZwcm90bzM
="
));
descriptor
=
pbr
::
FileDescriptor
.
FromGeneratedCode
(
descriptorData
,
new
pbr
::
FileDescriptor
[]
{
},
new
pbr
::
GeneratedClrTypeInfo
(
new
[]
{
typeof
(
global
::
Conformance
.
WireFormat
),
},
new
pbr
::
GeneratedClrTypeInfo
[]
{
new
pbr
::
GeneratedClrTypeInfo
(
typeof
(
global
::
Conformance
.
ConformanceRequest
),
global
::
Conformance
.
ConformanceRequest
.
Parser
,
new
[]{
"ProtobufPayload"
,
"JsonPayload"
,
"RequestedOutputFormat"
},
new
[]{
"Payload"
},
null
,
null
),
new
pbr
::
GeneratedClrTypeInfo
(
typeof
(
global
::
Conformance
.
ConformanceRequest
),
global
::
Conformance
.
ConformanceRequest
.
Parser
,
new
[]{
"ProtobufPayload"
,
"JsonPayload"
,
"RequestedOutputFormat"
,
"MessageType"
},
new
[]{
"Payload"
},
null
,
null
),
new
pbr
::
GeneratedClrTypeInfo
(
typeof
(
global
::
Conformance
.
ConformanceResponse
),
global
::
Conformance
.
ConformanceResponse
.
Parser
,
new
[]{
"ParseError"
,
"SerializeError"
,
"RuntimeError"
,
"ProtobufPayload"
,
"JsonPayload"
,
"Skipped"
},
new
[]{
"Result"
},
null
,
null
)
}));
}
...
...
@@ -85,6 +85,7 @@ namespace Conformance {
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
ConformanceRequest
(
ConformanceRequest
other
)
:
this
()
{
requestedOutputFormat_
=
other
.
requestedOutputFormat_
;
messageType_
=
other
.
messageType_
;
switch
(
other
.
PayloadCase
)
{
case
PayloadOneofCase
.
ProtobufPayload
:
ProtobufPayload
=
other
.
ProtobufPayload
;
...
...
@@ -137,6 +138,20 @@ namespace Conformance {
}
}
/// <summary>Field number for the "message_type" field.</summary>
public
const
int
MessageTypeFieldNumber
=
4
;
private
string
messageType_
=
""
;
/// <summary>
/// should be set to either "proto2" or "proto3"
/// </summary>
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
string
MessageType
{
get
{
return
messageType_
;
}
set
{
messageType_
=
pb
::
ProtoPreconditions
.
CheckNotNull
(
value
,
"value"
);
}
}
private
object
payload_
;
/// <summary>Enum of possible cases for the "payload" oneof.</summary>
public
enum
PayloadOneofCase
{
...
...
@@ -172,6 +187,7 @@ namespace Conformance {
if
(
ProtobufPayload
!=
other
.
ProtobufPayload
)
return
false
;
if
(
JsonPayload
!=
other
.
JsonPayload
)
return
false
;
if
(
RequestedOutputFormat
!=
other
.
RequestedOutputFormat
)
return
false
;
if
(
MessageType
!=
other
.
MessageType
)
return
false
;
if
(
PayloadCase
!=
other
.
PayloadCase
)
return
false
;
return
true
;
}
...
...
@@ -182,6 +198,7 @@ namespace Conformance {
if
(
payloadCase_
==
PayloadOneofCase
.
ProtobufPayload
)
hash
^=
ProtobufPayload
.
GetHashCode
();
if
(
payloadCase_
==
PayloadOneofCase
.
JsonPayload
)
hash
^=
JsonPayload
.
GetHashCode
();
if
(
RequestedOutputFormat
!=
0
)
hash
^=
RequestedOutputFormat
.
GetHashCode
();
if
(
MessageType
.
Length
!=
0
)
hash
^=
MessageType
.
GetHashCode
();
hash
^=
(
int
)
payloadCase_
;
return
hash
;
}
...
...
@@ -205,6 +222,10 @@ namespace Conformance {
output
.
WriteRawTag
(
24
);
output
.
WriteEnum
((
int
)
RequestedOutputFormat
);
}
if
(
MessageType
.
Length
!=
0
)
{
output
.
WriteRawTag
(
34
);
output
.
WriteString
(
MessageType
);
}
}
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
...
...
@@ -219,6 +240,9 @@ namespace Conformance {
if
(
RequestedOutputFormat
!=
0
)
{
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeEnumSize
((
int
)
RequestedOutputFormat
);
}
if
(
MessageType
.
Length
!=
0
)
{
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
MessageType
);
}
return
size
;
}
...
...
@@ -230,6 +254,9 @@ namespace Conformance {
if
(
other
.
RequestedOutputFormat
!=
0
)
{
RequestedOutputFormat
=
other
.
RequestedOutputFormat
;
}
if
(
other
.
MessageType
.
Length
!=
0
)
{
MessageType
=
other
.
MessageType
;
}
switch
(
other
.
PayloadCase
)
{
case
PayloadOneofCase
.
ProtobufPayload
:
ProtobufPayload
=
other
.
ProtobufPayload
;
...
...
@@ -261,6 +288,10 @@ namespace Conformance {
requestedOutputFormat_
=
(
global
::
Conformance
.
WireFormat
)
input
.
ReadEnum
();
break
;
}
case
34
:
{
MessageType
=
input
.
ReadString
();
break
;
}
}
}
}
...
...
csharp/src/Google.Protobuf.Conformance/Program.cs
View file @
cd1dc3f0
...
...
@@ -90,9 +90,23 @@ namespace Google.Protobuf.Conformance
var
parser
=
new
JsonParser
(
new
JsonParser
.
Settings
(
20
,
typeRegistry
));
message
=
parser
.
Parse
<
ProtobufTestMessages
.
Proto3
.
TestAllTypes
>(
request
.
JsonPayload
);
break
;
case
ConformanceRequest
.
PayloadOneofCase
.
ProtobufPayload
:
message
=
ProtobufTestMessages
.
Proto3
.
TestAllTypes
.
Parser
.
ParseFrom
(
request
.
ProtobufPayload
);
case
ConformanceRequest
.
PayloadOneofCase
.
ProtobufPayload
:
{
if
(
request
.
MessageType
.
Equals
(
"proto3"
))
{
message
=
ProtobufTestMessages
.
Proto3
.
TestAllTypes
.
Parser
.
ParseFrom
(
request
.
ProtobufPayload
);
}
else
if
(
request
.
MessageType
.
Equals
(
"proto2"
))
{
response
.
Skipped
=
"Ruby doesn't support proto2"
;
return
response
;
}
else
{
throw
new
Exception
(
" Protobuf request doesn't have specific payload type"
);
}
break
;
}
default
:
throw
new
Exception
(
"Unsupported request payload: "
+
request
.
PayloadCase
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment