[protobuf] Protobuf - How to create a FileDescriptor object from a Descriptor file

2016-03-29 Thread Raghu

I created a Descriptor file from Example.proto file using the below command.

.\protoc.exe --proto_path=D:\ExampleProject\ --include_imports 
D:\ExampleProject\Example.Proto 
--descriptor_set_out=D:\ExampleProject\Example.pb

We want to read this file and create FileDescriptorSet object in C#. But 
both FileDescriptorSet and FileDescriptorProto are internal classes.

Please let me know how to create FileDescriptor object from this Example.pb 
file. 

Note: We want to use C#.

Thanks & Regards
Raghu

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


Example.proto
Description: Binary data


Example.pb
Description: Binary data


[protobuf] Protobuf - Creating the ProtoBuf object from a physical File

2016-03-29 Thread Raghu


Hi,

I have a requirement : 
1. I have converted Example.proto file to Example.cs file code using the 
protoc.exe command.
2. I want to read Example.cs file using FileStream and create the Example 
object or atleast the TypeOf.  I do not want to include it 
in my project as I want to make it generic. 

Could you please let me know how to achieve this.

Thanks & Regards
Raghu

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: Example.proto
#pragma warning disable 1591, 0612, 3021
#region Designer generated code

using pb = global::Google.Protobuf;
using pbc = global::Google.Protobuf.Collections;
using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic;
namespace ConsoleApplication1 {

  /// Holder for reflection information generated from Example.proto
  [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
  public static partial class ExampleReflection {

#region Descriptor
/// File descriptor for Example.proto
public static pbr::FileDescriptor Descriptor {
  get { return descriptor; }
}
private static pbr::FileDescriptor descriptor;

static ExampleReflection() {
  byte[] descriptorData = global::System.Convert.FromBase64String(
  string.Concat(
"Cg1FeGFtcGxlLnByb3RvEhNDb25zb2xlQXBwbGljYXRpb24xGhlnb29nbGUv",
"cHJvdG9idWYvYW55LnByb3RvIo0CCgZQZXJzb24SDAoEbmFtZRgBIAEoCRIK",
"CgJpZBgCIAEoBRINCgVlbWFpbBgDIAEoCRI2CgVwaG9uZRgEIAMoCzInLkNv",
"bnNvbGVBcHBsaWNhdGlvbjEuUGVyc29uLlBob25lTnVtYmVyEiEKA0FueRgF",
"IAEoCzIULmdvb2dsZS5wcm90b2J1Zi5BbnkaUgoLUGhvbmVOdW1iZXISDgoG",
"bnVtYmVyGAEgASgJEjMKBHR5cGUYAiABKA4yJS5Db25zb2xlQXBwbGljYXRp",
"b24xLlBlcnNvbi5QaG9uZVR5cGUiKwoJUGhvbmVUeXBlEgoKBk1PQklMRRAA",
"EggKBEhPTUUQARIICgRXT1JLEAJCFqoCE0NvbnNvbGVBcHBsaWNhdGlvbjFi",
"BnByb3RvMw=="));
  descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
  new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.AnyReflection.Descriptor, },
  new pbr::GeneratedCodeInfo(null, new pbr::GeneratedCodeInfo[] {
new pbr::GeneratedCodeInfo(typeof(global::ConsoleApplication1.Person), global::ConsoleApplication1.Person.Parser, new[]{ "Name", "Id", "Email", "Phone", "Any" }, null, new[]{ typeof(global::ConsoleApplication1.Person.Types.PhoneType) }, new pbr::GeneratedCodeInfo[] { new pbr::GeneratedCodeInfo(typeof(global::ConsoleApplication1.Person.Types.PhoneNumber), global::ConsoleApplication1.Person.Types.PhoneNumber.Parser, new[]{ "Number", "Type" }, null, null, null)})
  }));
}
#endregion

  }
  #region Messages
  [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
  public sealed partial class Person : pb::IMessage {
private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Person());
public static pb::MessageParser Parser { get { return _parser; } }

public static pbr::MessageDescriptor Descriptor {
  get { return global::ConsoleApplication1.ExampleReflection.Descriptor.MessageTypes[0]; }
}

pbr::MessageDescriptor pb::IMessage.Descriptor {
  get { return Descriptor; }
}

public Person() {
  OnConstruction();
}

partial void OnConstruction();

public Person(Person other) : this() {
  name_ = other.name_;
  id_ = other.id_;
  email_ = other.email_;
  phone_ = other.phone_.Clone();
  Any = other.any_ != null ? other.Any.Clone() : null;
}

public Person Clone() {
  return new Person(this);
}

/// Field number for the "name" field.
public const int NameFieldNumber = 1;
private string name_ = "";
public string Name {
  get { return name_; }
  set {
name_ = pb::Preconditions.CheckNotNull(value, "value");
  }
}

/// Field number for the "id" field.
public const int IdFieldNumber = 2;
private int id_;
public int Id {
  get { return id_; }
  set {
id_ = value;
  }
}

/// Field number for the "email" field.
public const int EmailFieldNumber = 3;
private string email_ = "";
public string Email {
  get { return email_; }
  set {
email_ = pb::Preconditions.CheckNotNull(value, "v