aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/ProtoGen/ProtocGenCs.cs
diff options
context:
space:
mode:
authorJon Skeet <skeet@pobox.com>2015-04-29 20:59:44 +0100
committerJon Skeet <skeet@pobox.com>2015-04-29 20:59:44 +0100
commita449f66bdb50f3e898889705945fb1ac6b105469 (patch)
tree87a1bb05e7a05d5fc0b2eb5046f637e64b0b3ec2 /csharp/src/ProtoGen/ProtocGenCs.cs
parent32ead755d1f97e414f4a50edb7d9f1ebd9cab562 (diff)
parent0e916d09a3fa272399b38f09b5509e0e2445e7fb (diff)
downloadprotobuf-a449f66bdb50f3e898889705945fb1ac6b105469.tar.gz
protobuf-a449f66bdb50f3e898889705945fb1ac6b105469.tar.bz2
protobuf-a449f66bdb50f3e898889705945fb1ac6b105469.zip
Merge pull request #317 from jskeet/csharp
Tidying up the C# runtime project
Diffstat (limited to 'csharp/src/ProtoGen/ProtocGenCs.cs')
-rw-r--r--csharp/src/ProtoGen/ProtocGenCs.cs76
1 files changed, 0 insertions, 76 deletions
diff --git a/csharp/src/ProtoGen/ProtocGenCs.cs b/csharp/src/ProtoGen/ProtocGenCs.cs
deleted file mode 100644
index 29264200..00000000
--- a/csharp/src/ProtoGen/ProtocGenCs.cs
+++ /dev/null
@@ -1,76 +0,0 @@
-using Google.ProtocolBuffers.Compiler.PluginProto;
-using Google.ProtocolBuffers.DescriptorProtos;
-using System;
-using System.Collections.Generic;
-
-// Usage example:
-// protoc.exe
-// --plugin=path\to\protoc-gen-cs.exe
-// --cs_out="-generated_code_attributes=true umbrella_namespace=TutorialProto :."
-// --proto_path=.\protos\
-// protos\tutorial\addressbook.proto
-
-namespace Google.ProtocolBuffers.ProtoGen
-{
- public static class ProtocGenCs
- {
- internal static void Run(CodeGeneratorRequest request, CodeGeneratorResponse.Builder response)
- {
- var arguments = new List<string>();
- foreach (var arg in request.Parameter.Split(' '))
- {
- var timmedArg = (arg ?? "").Trim();
- if (!string.IsNullOrEmpty(timmedArg))
- {
- arguments.Add(timmedArg);
- }
- }
- // Adding fake input file to make TryValidate happy.
- arguments.Add(System.Reflection.Assembly.GetExecutingAssembly().Location);
-
- GeneratorOptions options = new GeneratorOptions
- {
- Arguments = arguments
- };
- IList<string> validationFailures;
- if (!options.TryValidate(out validationFailures))
- {
- response.Error += new InvalidOptionsException(validationFailures).Message;
- return;
- }
-
- Generator generator = Generator.CreateGenerator(options);
- generator.Generate(request, response);
- }
-
- public static int Main(string[] args)
- {
- // Hack to make sure everything's initialized
- DescriptorProtoFile.Descriptor.ToString();
- ExtensionRegistry extensionRegistry = ExtensionRegistry.CreateInstance();
- CSharpOptions.RegisterAllExtensions(extensionRegistry);
-
- CodeGeneratorRequest request;
- var response = new CodeGeneratorResponse.Builder();
- try
- {
- using (var input = Console.OpenStandardInput())
- {
- request = CodeGeneratorRequest.ParseFrom(input, extensionRegistry);
- }
- Run(request, response);
- }
- catch (Exception e)
- {
- response.Error += e.ToString();
- }
-
- using (var output = Console.OpenStandardOutput())
- {
- response.Build().WriteTo(output);
- output.Flush();
- }
- return 0;
- }
- }
-}