diff options
author | Jon Skeet <jonskeet@google.com> | 2015-06-25 12:25:49 +0100 |
---|---|---|
committer | Jon Skeet <jonskeet@google.com> | 2015-06-26 20:13:05 +0100 |
commit | e75a10d8ff85901021a7c133534b6b87c3c7f072 (patch) | |
tree | b17e1800d15a6a8e9bed81fe03d57bcf16187e8f /csharp/src/ProtoDump | |
parent | 286edc0fc2e52ed52ba08d5c572b4f125665d788 (diff) | |
download | protobuf-e75a10d8ff85901021a7c133534b6b87c3c7f072.tar.gz protobuf-e75a10d8ff85901021a7c133534b6b87c3c7f072.tar.bz2 protobuf-e75a10d8ff85901021a7c133534b6b87c3c7f072.zip |
Fix or delete old projects.
ProtoDump isn't currently useful, but will be when ToString emits JSON: fixed.
ProtoBench: deleted; we should reinstate when there's a common proto3 benchmark.
ProtoMunge: delete; not useful enough to merit fixing up.
Removed the [TestFixture] from ByteStringTest as Travis uses a recent enough version of NUnit.
Diffstat (limited to 'csharp/src/ProtoDump')
-rw-r--r-- | csharp/src/ProtoDump/Program.cs | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/csharp/src/ProtoDump/Program.cs b/csharp/src/ProtoDump/Program.cs index a935e780..d2eee9b7 100644 --- a/csharp/src/ProtoDump/Program.cs +++ b/csharp/src/ProtoDump/Program.cs @@ -36,6 +36,7 @@ using System;
using System.IO;
+using Google.Protobuf;
namespace Google.ProtocolBuffers.ProtoDump
{
@@ -53,36 +54,24 @@ namespace Google.ProtocolBuffers.ProtoDump Console.Error.WriteLine("including assembly e.g. ProjectNamespace.Message,Company.Project");
return 1;
}
- IMessage defaultMessage;
- try
+ Type type = Type.GetType(args[0]);
+ if (type == null)
{
- defaultMessage = MessageUtil.GetDefaultMessage(args[0]);
- }
- catch (ArgumentException e)
- {
- Console.Error.WriteLine(e.Message);
+ Console.Error.WriteLine("Unable to load type {0}.", args[0]);
return 1;
}
- try
+ if (!typeof(IMessage).IsAssignableFrom(type))
{
- IBuilder builder = defaultMessage.WeakCreateBuilderForType();
- if (builder == null)
- {
- Console.Error.WriteLine("Unable to create builder");
- return 1;
- }
- byte[] inputData = File.ReadAllBytes(args[1]);
- builder.WeakMergeFrom(ByteString.CopyFrom(inputData));
- Console.WriteLine(TextFormat.PrintToString(builder.WeakBuild()));
- return 0;
+ Console.Error.WriteLine("Type {0} doesn't implement IMessage.", args[0]);
+ return 1;
}
- catch (Exception e)
+ IMessage message = (IMessage) Activator.CreateInstance(type);
+ using (var input = File.OpenRead(args[1]))
{
- Console.Error.WriteLine("Error: {0}", e.Message);
- Console.Error.WriteLine();
- Console.Error.WriteLine("Detailed exception information: {0}", e);
- return 1;
+ message.MergeFrom(input);
}
+ Console.WriteLine(message);
+ return 0;
}
}
}
\ No newline at end of file |