Commit cd1dc3f0 authored by Yilun Chong's avatar Yilun Chong

add csharp support

parent 36450210
...@@ -22,21 +22,21 @@ namespace Conformance { ...@@ -22,21 +22,21 @@ namespace Conformance {
static ConformanceReflection() { static ConformanceReflection() {
byte[] descriptorData = global::System.Convert.FromBase64String( byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat( string.Concat(
"ChFjb25mb3JtYW5jZS5wcm90bxILY29uZm9ybWFuY2UijQEKEkNvbmZvcm1h", "ChFjb25mb3JtYW5jZS5wcm90bxILY29uZm9ybWFuY2UiowEKEkNvbmZvcm1h",
"bmNlUmVxdWVzdBIaChBwcm90b2J1Zl9wYXlsb2FkGAEgASgMSAASFgoManNv", "bmNlUmVxdWVzdBIaChBwcm90b2J1Zl9wYXlsb2FkGAEgASgMSAASFgoManNv",
"bl9wYXlsb2FkGAIgASgJSAASOAoXcmVxdWVzdGVkX291dHB1dF9mb3JtYXQY", "bl9wYXlsb2FkGAIgASgJSAASOAoXcmVxdWVzdGVkX291dHB1dF9mb3JtYXQY",
"AyABKA4yFy5jb25mb3JtYW5jZS5XaXJlRm9ybWF0QgkKB3BheWxvYWQisQEK", "AyABKA4yFy5jb25mb3JtYW5jZS5XaXJlRm9ybWF0EhQKDG1lc3NhZ2VfdHlw",
"E0NvbmZvcm1hbmNlUmVzcG9uc2USFQoLcGFyc2VfZXJyb3IYASABKAlIABIZ", "ZRgEIAEoCUIJCgdwYXlsb2FkIrEBChNDb25mb3JtYW5jZVJlc3BvbnNlEhUK",
"Cg9zZXJpYWxpemVfZXJyb3IYBiABKAlIABIXCg1ydW50aW1lX2Vycm9yGAIg", "C3BhcnNlX2Vycm9yGAEgASgJSAASGQoPc2VyaWFsaXplX2Vycm9yGAYgASgJ",
"ASgJSAASGgoQcHJvdG9idWZfcGF5bG9hZBgDIAEoDEgAEhYKDGpzb25fcGF5", "SAASFwoNcnVudGltZV9lcnJvchgCIAEoCUgAEhoKEHByb3RvYnVmX3BheWxv",
"bG9hZBgEIAEoCUgAEhEKB3NraXBwZWQYBSABKAlIAEIICgZyZXN1bHQqNQoK", "YWQYAyABKAxIABIWCgxqc29uX3BheWxvYWQYBCABKAlIABIRCgdza2lwcGVk",
"V2lyZUZvcm1hdBIPCgtVTlNQRUNJRklFRBAAEgwKCFBST1RPQlVGEAESCAoE", "GAUgASgJSABCCAoGcmVzdWx0KjUKCldpcmVGb3JtYXQSDwoLVU5TUEVDSUZJ",
"SlNPThACQiEKH2NvbS5nb29nbGUucHJvdG9idWYuY29uZm9ybWFuY2ViBnBy", "RUQQABIMCghQUk9UT0JVRhABEggKBEpTT04QAkIhCh9jb20uZ29vZ2xlLnBy",
"b3RvMw==")); "b3RvYnVmLmNvbmZvcm1hbmNlYgZwcm90bzM="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { }, new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Conformance.WireFormat), }, new pbr::GeneratedClrTypeInfo[] { 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) 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 { ...@@ -85,6 +85,7 @@ namespace Conformance {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public ConformanceRequest(ConformanceRequest other) : this() { public ConformanceRequest(ConformanceRequest other) : this() {
requestedOutputFormat_ = other.requestedOutputFormat_; requestedOutputFormat_ = other.requestedOutputFormat_;
messageType_ = other.messageType_;
switch (other.PayloadCase) { switch (other.PayloadCase) {
case PayloadOneofCase.ProtobufPayload: case PayloadOneofCase.ProtobufPayload:
ProtobufPayload = other.ProtobufPayload; ProtobufPayload = other.ProtobufPayload;
...@@ -137,6 +138,20 @@ namespace Conformance { ...@@ -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_; private object payload_;
/// <summary>Enum of possible cases for the "payload" oneof.</summary> /// <summary>Enum of possible cases for the "payload" oneof.</summary>
public enum PayloadOneofCase { public enum PayloadOneofCase {
...@@ -172,6 +187,7 @@ namespace Conformance { ...@@ -172,6 +187,7 @@ namespace Conformance {
if (ProtobufPayload != other.ProtobufPayload) return false; if (ProtobufPayload != other.ProtobufPayload) return false;
if (JsonPayload != other.JsonPayload) return false; if (JsonPayload != other.JsonPayload) return false;
if (RequestedOutputFormat != other.RequestedOutputFormat) return false; if (RequestedOutputFormat != other.RequestedOutputFormat) return false;
if (MessageType != other.MessageType) return false;
if (PayloadCase != other.PayloadCase) return false; if (PayloadCase != other.PayloadCase) return false;
return true; return true;
} }
...@@ -182,6 +198,7 @@ namespace Conformance { ...@@ -182,6 +198,7 @@ namespace Conformance {
if (payloadCase_ == PayloadOneofCase.ProtobufPayload) hash ^= ProtobufPayload.GetHashCode(); if (payloadCase_ == PayloadOneofCase.ProtobufPayload) hash ^= ProtobufPayload.GetHashCode();
if (payloadCase_ == PayloadOneofCase.JsonPayload) hash ^= JsonPayload.GetHashCode(); if (payloadCase_ == PayloadOneofCase.JsonPayload) hash ^= JsonPayload.GetHashCode();
if (RequestedOutputFormat != 0) hash ^= RequestedOutputFormat.GetHashCode(); if (RequestedOutputFormat != 0) hash ^= RequestedOutputFormat.GetHashCode();
if (MessageType.Length != 0) hash ^= MessageType.GetHashCode();
hash ^= (int) payloadCase_; hash ^= (int) payloadCase_;
return hash; return hash;
} }
...@@ -205,6 +222,10 @@ namespace Conformance { ...@@ -205,6 +222,10 @@ namespace Conformance {
output.WriteRawTag(24); output.WriteRawTag(24);
output.WriteEnum((int) RequestedOutputFormat); output.WriteEnum((int) RequestedOutputFormat);
} }
if (MessageType.Length != 0) {
output.WriteRawTag(34);
output.WriteString(MessageType);
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -219,6 +240,9 @@ namespace Conformance { ...@@ -219,6 +240,9 @@ namespace Conformance {
if (RequestedOutputFormat != 0) { if (RequestedOutputFormat != 0) {
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) RequestedOutputFormat); size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) RequestedOutputFormat);
} }
if (MessageType.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(MessageType);
}
return size; return size;
} }
...@@ -230,6 +254,9 @@ namespace Conformance { ...@@ -230,6 +254,9 @@ namespace Conformance {
if (other.RequestedOutputFormat != 0) { if (other.RequestedOutputFormat != 0) {
RequestedOutputFormat = other.RequestedOutputFormat; RequestedOutputFormat = other.RequestedOutputFormat;
} }
if (other.MessageType.Length != 0) {
MessageType = other.MessageType;
}
switch (other.PayloadCase) { switch (other.PayloadCase) {
case PayloadOneofCase.ProtobufPayload: case PayloadOneofCase.ProtobufPayload:
ProtobufPayload = other.ProtobufPayload; ProtobufPayload = other.ProtobufPayload;
...@@ -261,6 +288,10 @@ namespace Conformance { ...@@ -261,6 +288,10 @@ namespace Conformance {
requestedOutputFormat_ = (global::Conformance.WireFormat) input.ReadEnum(); requestedOutputFormat_ = (global::Conformance.WireFormat) input.ReadEnum();
break; break;
} }
case 34: {
MessageType = input.ReadString();
break;
}
} }
} }
} }
......
...@@ -91,8 +91,22 @@ namespace Google.Protobuf.Conformance ...@@ -91,8 +91,22 @@ namespace Google.Protobuf.Conformance
message = parser.Parse<ProtobufTestMessages.Proto3.TestAllTypes>(request.JsonPayload); message = parser.Parse<ProtobufTestMessages.Proto3.TestAllTypes>(request.JsonPayload);
break; break;
case ConformanceRequest.PayloadOneofCase.ProtobufPayload: case ConformanceRequest.PayloadOneofCase.ProtobufPayload:
{
if (request.MessageType.Equals("proto3"))
{
message = ProtobufTestMessages.Proto3.TestAllTypes.Parser.ParseFrom(request.ProtobufPayload); 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; break;
}
default: default:
throw new Exception("Unsupported request payload: " + request.PayloadCase); throw new Exception("Unsupported request payload: " + request.PayloadCase);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment