I'm not sure how soon we can expect the proto2 support in C#. Jie, do you
happen to know how close it is to being complete?

But if you're just trying to generate C# code at build time, I was thinking
you could also use for example a C++ binary to generate the C# code,
without needing SWIG or anything.

It would go something like this:
- Run "protoc --descriptor_set_out=... path/to/my.proto > descriptors.out"
- Run your C++ program which reads in the descriptors and generates C# code
- Then build the C# project as usual

On Wed, Oct 31, 2018 at 11:11 AM Michael Powell <[email protected]>
wrote:

> On Wed, Oct 31, 2018 at 1:57 PM Adam Cozzette <[email protected]>
> wrote:
> >
> > +Jie Luo who knows the most about C#
> >
> > The one thing that might be a problem is that C# does not yet have full
> support for proto2, though that work is in progress (see this most recent
> pull request). That could make it hard to parse the descriptor protos from
> C#, since descriptor.proto is a proto2 file. On the other hand, if you're
> using proto3 you could also forget about parsing the descriptors yourself
> but just use protobuf reflection to examine your messages within a C#
> program.
>
> Herein lies the rub... The proto I am dealing with is v2 at the
> moment, yes. How soon do you think the PR would be verified, accepted,
> etc?
>
> > When you say you want to generate boilerplate, do you mean that you want
> to generate C# code at build time? If so then another option is to just use
> another language like C++ or Java to output your C# code.
>
> Exactly. I am working from a .proto file and want to output some
> non-message adapter type stuff for a Google.OrTools C# adapter I'm
> working on, which uses this internally. I could churn through the
> .proto manually by hand, but I figure this is a prime candidate for a
> build-time code generation approach, particularly with adequate proto
> buffer spec comprehension.
>
> In terms of introducing another language, you mean with something like
> SWIG comprehension? If it's fairly seamless, I may consider that, as
> well. In a word diagram, something like this:
>
> Proto2 -> C++ -> SWIG -> C# -> Code Gen
>
> That's a bit of a pipeline, but it may be doable.
>
> > On Wed, Oct 31, 2018 at 10:26 AM Michael Powell <[email protected]>
> wrote:
> >>
> >> On Wed, Oct 31, 2018 at 1:17 PM Adam Cozzette <[email protected]>
> wrote:
> >> >
> >> > I think that specification has suffered a little bit of neglect
> (sorry about that), because in practice our C++ parser is really the de
> facto standard and we have not recently made an effort to go through and
> make sure the official spec matches it perfectly. My reading of that string
> (/[^\0\n\\]/) is that it's a regular expression saying "any character other
> than null, newline, or backslash." But in general I would say the best bet
> is to resolve ambiguities by looking at what the C++ parser does.
> >>
> >> Thanks for that bit of clarification.
> >>
> >> > By the way, have you considered just reusing the C++ parser that's
> included in protoc? You can call protoc with the --descriptor_set_out flag
> to have it parse your .proto file and produce a serialized
> FileDescriptorSet proto as output. Then at that point it's easy to parse
> the descriptors using just about any language we support, and that should
> give you all the information you need, without the need for a new .proto
> file parser.
> >>
> >> Good point, it's a possibility? Does it protoc to C#? It would be less
> >> difficult, I think, for me to Reflect through that and generate the
> >> boilerplate that I want, probably, than spinning up a full on parser
> >> replete with its AST.
> >>
> >> > On Wed, Oct 31, 2018 at 9:23 AM Michael Powell <[email protected]>
> wrote:
> >> >>
> >> >> On Wed, Oct 31, 2018 at 12:22 PM Michael Powell <
> [email protected]> wrote:
> >> >> >
> >> >> > Concerning Constant, literally from the v2 spec:
> >> >>
> >> >> Rather, Syntax section, excuse me...
> >> >>
> >> >> > syntax = "syntax" "=" quote "proto2" quote ";"
> >> >> >
> >> >> > Do I read that correctly you can expect either 'proto2' or
> "proto2",
> >> >> > but never 'proto2" nor "proto2' ?
> >> >> >
> >> >> > If accurate, that just seems to me to be lazy spec authorship...
> >> >> >
> >> >> > Thanks!
> >> >> > On Wed, Oct 31, 2018 at 12:07 PM Michael Powell <
> [email protected]> wrote:
> >> >> > >
> >> >> > > Hello,
> >> >> > >
> >> >> > > I am writing a parser for the Proto language specification
> starting
> >> >> > > with v2. I need a little help interpreting one of the lines if
> you
> >> >> > > please:
> >> >> > >
> >> >> > > In the "String literals" section, what does this mean:
> >> >> > >
> >> >> > > charValue = hexEscape | octEscape | charEscape | /[^\0\n\\]/
> >> >> > >
> >> >> > > Specifically, the trailing list of character soup? I want to say
> that
> >> >> > > there are escaped characters in the sequence? Or am I to take
> that
> >> >> > > string literally? Or notwithstanding the enclosing forward
> slashes?
> >> >> > >
> >> >> > > Thanks much in advance!
> >> >> > >
> >> >> > > Best regards,
> >> >> > >
> >> >> > > Michael Powell
> >> >>
> >> >> --
> >> >> 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 [email protected].
> >> >> To post to this group, send email to [email protected].
> >> >> Visit this group at https://groups.google.com/group/protobuf.
> >> >> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to