From 047575f20cbdee8fb2f88d78a317ffe6133b93e6 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Mon, 16 Jan 2017 11:23:32 +0000 Subject: Support custom options in C# This consists of: - Changing the codegen for the fixed set of options protos, to parse unknown fields instead of skipping them - Add a new CustomOptions type in the C# support library - Expose CustomOptions properties from the immutable proto wrappers in the support library Only single-value options are currently supported, and fetching options values requires getting the type right and knowing the field number. Both of these can be addressed at a later time. Fixes #2143, at least as a first pass. --- csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs') diff --git a/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs index ed15d0e1..2a3d5c7a 100644 --- a/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs +++ b/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs @@ -250,6 +250,11 @@ namespace Google.Protobuf.Reflection } } + /// + /// The (possibly empty) set of custom options for this field. + /// + public CustomOptions CustomOptions => Proto.Options?.CustomOptions ?? CustomOptions.Empty; + /// /// Look up and cross-link all field types etc. /// -- cgit v1.2.3