aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--csharp/src/Google.Protobuf.Conformance/Program.cs43
-rw-r--r--csharp/src/Google.Protobuf/Google.Protobuf.nuspec57
2 files changed, 62 insertions, 38 deletions
diff --git a/csharp/src/Google.Protobuf.Conformance/Program.cs b/csharp/src/Google.Protobuf.Conformance/Program.cs
index af92da9f..8f72c8f9 100644
--- a/csharp/src/Google.Protobuf.Conformance/Program.cs
+++ b/csharp/src/Google.Protobuf.Conformance/Program.cs
@@ -31,6 +31,7 @@
#endregion
using Conformance;
+using Google.Protobuf.Reflection;
using System;
using System.IO;
@@ -47,16 +48,17 @@ namespace Google.Protobuf.Conformance
// This way we get the binary streams instead of readers/writers.
var input = new BinaryReader(Console.OpenStandardInput());
var output = new BinaryWriter(Console.OpenStandardOutput());
+ var typeRegistry = TypeRegistry.FromMessages(TestAllTypes.Descriptor);
int count = 0;
- while (RunTest(input, output))
+ while (RunTest(input, output, typeRegistry))
{
count++;
}
Console.Error.WriteLine("Received EOF after {0} tests", count);
}
- private static bool RunTest(BinaryReader input, BinaryWriter output)
+ private static bool RunTest(BinaryReader input, BinaryWriter output, TypeRegistry typeRegistry)
{
int? size = ReadInt32(input);
if (size == null)
@@ -69,7 +71,7 @@ namespace Google.Protobuf.Conformance
throw new EndOfStreamException("Read " + inputData.Length + " bytes of data when expecting " + size);
}
ConformanceRequest request = ConformanceRequest.Parser.ParseFrom(inputData);
- ConformanceResponse response = PerformRequest(request);
+ ConformanceResponse response = PerformRequest(request, typeRegistry);
byte[] outputData = response.ToByteArray();
output.Write(outputData.Length);
output.Write(outputData);
@@ -77,30 +79,33 @@ namespace Google.Protobuf.Conformance
return true;
}
- private static ConformanceResponse PerformRequest(ConformanceRequest request)
+ private static ConformanceResponse PerformRequest(ConformanceRequest request, TypeRegistry typeRegistry)
{
TestAllTypes message;
- switch (request.PayloadCase)
+ try
{
- case ConformanceRequest.PayloadOneofCase.JsonPayload:
- return new ConformanceResponse { Skipped = "JSON parsing not implemented in C# yet" };
- case ConformanceRequest.PayloadOneofCase.ProtobufPayload:
- try
- {
+ switch (request.PayloadCase)
+ {
+ case ConformanceRequest.PayloadOneofCase.JsonPayload:
+ var parser = new JsonParser(new JsonParser.Settings(20, typeRegistry));
+ message = parser.Parse<TestAllTypes>(request.JsonPayload);
+ break;
+ case ConformanceRequest.PayloadOneofCase.ProtobufPayload:
message = TestAllTypes.Parser.ParseFrom(request.ProtobufPayload);
- }
- catch (InvalidProtocolBufferException e)
- {
- return new ConformanceResponse { ParseError = e.Message };
- }
- break;
- default:
- throw new Exception("Unsupported request payload: " + request.PayloadCase);
+ break;
+ default:
+ throw new Exception("Unsupported request payload: " + request.PayloadCase);
+ }
+ }
+ catch (InvalidProtocolBufferException e)
+ {
+ return new ConformanceResponse { ParseError = e.Message };
}
switch (request.RequestedOutputFormat)
{
case global::Conformance.WireFormat.JSON:
- return new ConformanceResponse { JsonPayload = JsonFormatter.Default.Format(message) };
+ var formatter = new JsonFormatter(new JsonFormatter.Settings(false, typeRegistry));
+ return new ConformanceResponse { JsonPayload = formatter.Format(message) };
case global::Conformance.WireFormat.PROTOBUF:
return new ConformanceResponse { ProtobufPayload = message.ToByteString() };
default:
diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.nuspec b/csharp/src/Google.Protobuf/Google.Protobuf.nuspec
index 9542138a..2f691e3c 100644
--- a/csharp/src/Google.Protobuf/Google.Protobuf.nuspec
+++ b/csharp/src/Google.Protobuf/Google.Protobuf.nuspec
@@ -1,11 +1,11 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<package>
<metadata>
<id>Google.Protobuf</id>
<title>Google Protocol Buffers C#</title>
<summary>C# runtime library for Protocol Buffers - Google's data interchange format.</summary>
<description>See project site for more info.</description>
- <version>3.0.0-alpha4</version>
+ <version>3.0.0-beta2</version>
<authors>Google Inc.</authors>
<owners>protobuf-packages</owners>
<licenseUrl>https://github.com/google/protobuf/blob/master/LICENSE</licenseUrl>
@@ -14,24 +14,43 @@
<releaseNotes>C# proto3 support</releaseNotes>
<copyright>Copyright 2015, Google Inc.</copyright>
<tags>Protocol Buffers Binary Serialization Format Google proto proto3</tags>
+ <dependencies>
+ <group targetFramework="dotnet">
+ <dependency id="System.Collections" version="4.0.0" />
+ <dependency id="System.Diagnostics.Debug" version="4.0.0" />
+ <dependency id="System.Globalization" version="4.0.0" />
+ <dependency id="System.IO" version="4.0.0" />
+ <dependency id="System.Linq" version="4.0.0" />
+ <dependency id="System.Linq.Expressions" version="4.0.0" />
+ <dependency id="System.ObjectModel" version="4.0.0" />
+ <dependency id="System.Reflection" version="4.0.0" />
+ <dependency id="System.Runtime" version="4.0.0" />
+ <dependency id="System.Runtime.Extensions" version="4.0.0" />
+ <dependency id="System.Text.Encoding" version="4.0.0" />
+ <dependency id="System.Text.RegularExpressions" version="4.0.0" />
+ </group>
+ </dependencies>
</metadata>
<files>
<file src="bin/ReleaseSigned/Google.Protobuf.dll" target="lib/portable-net45+netcore45+wpa81+wp8" />
- <file src="bin/ReleaseSigned/Google.Protobuf.pdb" target="lib/portable-net45+netcore45+wpa81+wp8" />
- <file src="bin/ReleaseSigned/Google.Protobuf.xml" target="lib/portable-net45+netcore45+wpa81+wp8" />
- <file src="**\*.cs" target="src" />
- <file src="..\..\..\cmake\Release\protoc.exe" target="tools" />
- <file src="..\..\..\src\google\protobuf\any.proto" target="tools\google\protobuf" />
- <file src="..\..\..\src\google\protobuf\api.proto" target="tools\google\protobuf" />
- <file src="..\..\..\src\google\protobuf\descriptor.proto" target="tools\google\protobuf" />
- <file src="..\..\..\src\google\protobuf\duration.proto" target="tools\google\protobuf" />
- <file src="..\..\..\src\google\protobuf\empty.proto" target="tools\google\protobuf" />
- <file src="..\..\..\src\google\protobuf\field_mask.proto" target="tools\google\protobuf" />
- <file src="..\..\..\src\google\protobuf\source_context.proto" target="tools\google\protobuf" />
- <file src="..\..\..\src\google\protobuf\struct.proto" target="tools\google\protobuf" />
- <file src="..\..\..\src\google\protobuf\timestamp.proto" target="tools\google\protobuf" />
- <file src="..\..\..\src\google\protobuf\any.proto" target="tools\google\protobuf" />
- <file src="..\..\..\src\google\protobuf\type.proto" target="tools\google\protobuf" />
- <file src="..\..\..\src\google\protobuf\wrappers.proto" target="tools\google\protobuf" />
+ <file src="bin/ReleaseSigned/Google.Protobuf.pdb" target="lib/portable-net45+netcore45+wpa81+wp8" />
+ <file src="bin/ReleaseSigned/Google.Protobuf.xml" target="lib/portable-net45+netcore45+wpa81+wp8" />
+ <file src="bin/ReleaseSigned/Google.Protobuf.dll" target="lib/dotnet" />
+ <file src="bin/ReleaseSigned/Google.Protobuf.pdb" target="lib/dotnet" />
+ <file src="bin/ReleaseSigned/Google.Protobuf.xml" target="lib/dotnet" />
+ <file src="**\*.cs" target="src" />
+ <file src="..\..\..\cmake\Release\protoc.exe" target="tools" />
+ <file src="..\..\..\src\google\protobuf\any.proto" target="tools\google\protobuf" />
+ <file src="..\..\..\src\google\protobuf\api.proto" target="tools\google\protobuf" />
+ <file src="..\..\..\src\google\protobuf\descriptor.proto" target="tools\google\protobuf" />
+ <file src="..\..\..\src\google\protobuf\duration.proto" target="tools\google\protobuf" />
+ <file src="..\..\..\src\google\protobuf\empty.proto" target="tools\google\protobuf" />
+ <file src="..\..\..\src\google\protobuf\field_mask.proto" target="tools\google\protobuf" />
+ <file src="..\..\..\src\google\protobuf\source_context.proto" target="tools\google\protobuf" />
+ <file src="..\..\..\src\google\protobuf\struct.proto" target="tools\google\protobuf" />
+ <file src="..\..\..\src\google\protobuf\timestamp.proto" target="tools\google\protobuf" />
+ <file src="..\..\..\src\google\protobuf\any.proto" target="tools\google\protobuf" />
+ <file src="..\..\..\src\google\protobuf\type.proto" target="tools\google\protobuf" />
+ <file src="..\..\..\src\google\protobuf\wrappers.proto" target="tools\google\protobuf" />
</files>
-</package>
+</package> \ No newline at end of file