[csharp] Way to get an ExtensionRegistry from a FileDescriptor

12 views
Skip to first unread message

Miral Mirality

unread,
Feb 19, 2020, 1:50:46 AM2/19/20
to Protocol Buffers
It appears that in the C# lib, you can't parse messages containing extensions without passing in an ExtensionRegistry that contains the corresponding Extensions.

The C# code generator helpfully creates Extension objects as static members of the [filename]Extensions class; this is good.

But is there a way to get an ExtensionRegistry containing all Extensions from a file, without listing them individually?

It does appear that the list of all extensions in the file is passed to the FileDescriptor that can be obtained from [filename]Reflection.Descriptor, but the Extensions property of this returns an ExtensionCollection, which is a different animal; and it's unclear how to turn this into a list of Extensions and/or an ExtensionRegistry.

Alternatively, maybe the code generator should make a more-accessible list of extensions, perhaps already stored as an ExtensionRegistry?
Reply all
Reply to author
Forward
0 new messages