diff options
author | Jon Skeet <skeet@pobox.com> | 2009-01-16 10:57:40 +0000 |
---|---|---|
committer | Jon Skeet <skeet@pobox.com> | 2009-01-16 10:57:40 +0000 |
commit | 8f8186a30b9b8d865c6211eb91a4df8aae1f40d5 (patch) | |
tree | 8448e4c52607cd39f2035a06196cfe4247942f06 /src/ProtoDump | |
parent | 0c89aa1fdba0158d8dee3aef9cfe815afe4cc494 (diff) | |
download | protobuf-8f8186a30b9b8d865c6211eb91a4df8aae1f40d5.tar.gz protobuf-8f8186a30b9b8d865c6211eb91a4df8aae1f40d5.tar.bz2 protobuf-8f8186a30b9b8d865c6211eb91a4df8aae1f40d5.zip |
Benchmarking, dumping and munging
Diffstat (limited to 'src/ProtoDump')
-rw-r--r-- | src/ProtoDump/Program.cs | 43 | ||||
-rw-r--r-- | src/ProtoDump/Properties/AssemblyInfo.cs | 36 | ||||
-rw-r--r-- | src/ProtoDump/ProtoDump.csproj | 59 | ||||
-rw-r--r-- | src/ProtoDump/app.config | 3 |
4 files changed, 141 insertions, 0 deletions
diff --git a/src/ProtoDump/Program.cs b/src/ProtoDump/Program.cs new file mode 100644 index 00000000..0c66c930 --- /dev/null +++ b/src/ProtoDump/Program.cs @@ -0,0 +1,43 @@ +using System; +using System.IO; +using System.Reflection; +using Google.ProtocolBuffers; + +namespace ProtoDump { + /// <summary> + /// Small utility to load a binary message and dump it in text form + /// </summary> + class Program { + static int Main(string[] args) { + if (args.Length != 2) { + Console.Error.WriteLine("Usage: ProtoDump <descriptor type name> <input data>"); + Console.Error.WriteLine("The descriptor type name is the fully-qualified message name,"); + Console.Error.WriteLine("including assembly e.g. ProjectNamespace.Message,Company.Project"); + return 1; + } + IMessage defaultMessage; + try { + defaultMessage = MessageUtil.GetDefaultMessage(args[0]); + } catch (ArgumentException e) { + Console.Error.WriteLine(e.Message); + return 1; + } + try { + 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; + } catch (Exception e) { + Console.Error.WriteLine("Error: {0}", e.Message); + Console.Error.WriteLine(); + Console.Error.WriteLine("Detailed exception information: {0}", e); + return 1; + } + } + } +} diff --git a/src/ProtoDump/Properties/AssemblyInfo.cs b/src/ProtoDump/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..93427f7c --- /dev/null +++ b/src/ProtoDump/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ProtoDump")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ProtoDump")] +[assembly: AssemblyCopyright("Copyright © 2009")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("fed7572b-d747-4704-a6da-6c3c61088346")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/ProtoDump/ProtoDump.csproj b/src/ProtoDump/ProtoDump.csproj new file mode 100644 index 00000000..db1ab3f4 --- /dev/null +++ b/src/ProtoDump/ProtoDump.csproj @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>9.0.30729</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{D7282E99-2DC3-405B-946F-177DB2FD2AE2}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Google.ProtocolBuffers.ProtoDump</RootNamespace> + <AssemblyName>ProtoDump</AssemblyName> + <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <TargetFrameworkSubset> + </TargetFrameworkSubset> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\ProtocolBuffers\ProtocolBuffers.csproj"> + <Project>{6908BDCE-D925-43F3-94AC-A531E6DF2591}</Project> + <Name>ProtocolBuffers</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project>
\ No newline at end of file diff --git a/src/ProtoDump/app.config b/src/ProtoDump/app.config new file mode 100644 index 00000000..df20690a --- /dev/null +++ b/src/ProtoDump/app.config @@ -0,0 +1,3 @@ +<?xml version="1.0"?> +<configuration> +<startup><supportedRuntime version="v2.0.50727"/></startup></configuration> |