Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(497)

Side by Side Diff: third_party/protobuf/csharp/src/Google.Protobuf.JsonDump/Program.cs

Issue 2590803003: Revert "third_party/protobuf: Update to HEAD (83d681ee2c)" (Closed)
Patch Set: Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #region Copyright notice and license 1 #region Copyright notice and license
2 // Protocol Buffers - Google's data interchange format 2 // Protocol Buffers - Google's data interchange format
3 // Copyright 2008 Google Inc. All rights reserved. 3 // Copyright 2008 Google Inc. All rights reserved.
4 // https://developers.google.com/protocol-buffers/ 4 // https://developers.google.com/protocol-buffers/
5 // 5 //
6 // Redistribution and use in source and binary forms, with or without 6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are 7 // modification, are permitted provided that the following conditions are
8 // met: 8 // met:
9 // 9 //
10 // * Redistributions of source code must retain the above copyright 10 // * Redistributions of source code must retain the above copyright
(...skipping 14 matching lines...) Expand all
25 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #endregion 31 #endregion
32 32
33 using System; 33 using System;
34 using System.IO; 34 using System.IO;
35 using System.Reflection;
36 35
37 namespace Google.Protobuf.ProtoDump 36 namespace Google.Protobuf.ProtoDump
38 { 37 {
39 /// <summary> 38 /// <summary>
40 /// Small utility to load a binary message and dump it in JSON format. 39 /// Small utility to load a binary message and dump it in JSON format.
41 /// </summary> 40 /// </summary>
42 internal class Program 41 internal class Program
43 { 42 {
44 private static int Main(string[] args) 43 private static int Main(string[] args)
45 { 44 {
46 if (args.Length != 2) 45 if (args.Length != 2)
47 { 46 {
48 Console.Error.WriteLine("Usage: Google.Protobuf.JsonDump <descri ptor type name> <input data>"); 47 Console.Error.WriteLine("Usage: Google.Protobuf.JsonDump <descri ptor type name> <input data>");
49 Console.Error.WriteLine("The descriptor type name is the fully-q ualified message name,"); 48 Console.Error.WriteLine("The descriptor type name is the fully-q ualified message name,");
50 Console.Error.WriteLine("including assembly e.g. ProjectNamespac e.Message,Company.Project"); 49 Console.Error.WriteLine("including assembly e.g. ProjectNamespac e.Message,Company.Project");
51 return 1; 50 return 1;
52 } 51 }
53 Type type = Type.GetType(args[0]); 52 Type type = Type.GetType(args[0]);
54 if (type == null) 53 if (type == null)
55 { 54 {
56 Console.Error.WriteLine("Unable to load type {0}.", args[0]); 55 Console.Error.WriteLine("Unable to load type {0}.", args[0]);
57 return 1; 56 return 1;
58 } 57 }
59 if (!typeof(IMessage).GetTypeInfo().IsAssignableFrom(type)) 58 if (!typeof(IMessage).IsAssignableFrom(type))
60 { 59 {
61 Console.Error.WriteLine("Type {0} doesn't implement IMessage.", args[0]); 60 Console.Error.WriteLine("Type {0} doesn't implement IMessage.", args[0]);
62 return 1; 61 return 1;
63 } 62 }
64 IMessage message = (IMessage) Activator.CreateInstance(type); 63 IMessage message = (IMessage) Activator.CreateInstance(type);
65 using (var input = File.OpenRead(args[1])) 64 using (var input = File.OpenRead(args[1]))
66 { 65 {
67 message.MergeFrom(input); 66 message.MergeFrom(input);
68 } 67 }
69 Console.WriteLine(message); 68 Console.WriteLine(message);
70 return 0; 69 return 0;
71 } 70 }
72 } 71 }
73 } 72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698