diff options
author | Jon Skeet <skeet@pobox.com> | 2015-07-10 09:08:44 +0100 |
---|---|---|
committer | Jon Skeet <skeet@pobox.com> | 2015-07-10 09:08:44 +0100 |
commit | 94878b308041626794e6e39a687f174f2bf04b07 (patch) | |
tree | 439cc2d2ff26a66212f7270e7301b854c64bb238 /csharp/src/ProtocolBuffers | |
parent | db552c929719edc70bfb76a039ae83153472e50d (diff) | |
parent | 0da4a89c971b51f814f9dbe76a1dca47f5b440b4 (diff) | |
download | protobuf-94878b308041626794e6e39a687f174f2bf04b07.tar.gz protobuf-94878b308041626794e6e39a687f174f2bf04b07.tar.bz2 protobuf-94878b308041626794e6e39a687f174f2bf04b07.zip |
Merge pull request #566 from jskeet/csharp-reflection
Improve C# reflection support
Diffstat (limited to 'csharp/src/ProtocolBuffers')
27 files changed, 879 insertions, 952 deletions
diff --git a/csharp/src/ProtocolBuffers/Collections/MapField.cs b/csharp/src/ProtocolBuffers/Collections/MapField.cs index 6d1097a6..0f379eaa 100644 --- a/csharp/src/ProtocolBuffers/Collections/MapField.cs +++ b/csharp/src/ProtocolBuffers/Collections/MapField.cs @@ -48,7 +48,7 @@ namespace Google.Protobuf.Collections /// </remarks> /// <typeparam name="TKey">Key type in the map. Must be a type supported by Protocol Buffer map keys.</typeparam> /// <typeparam name="TValue">Value type in the map. Must be a type supported by Protocol Buffers.</typeparam> - public sealed class MapField<TKey, TValue> : IDeepCloneable<MapField<TKey, TValue>>, IFreezable, IDictionary<TKey, TValue>, IEquatable<MapField<TKey, TValue>> + public sealed class MapField<TKey, TValue> : IDeepCloneable<MapField<TKey, TValue>>, IFreezable, IDictionary<TKey, TValue>, IEquatable<MapField<TKey, TValue>>, IDictionary { // TODO: Don't create the map/list until we have an entry. (Assume many maps will be empty.) private bool frozen; @@ -64,7 +64,7 @@ namespace Google.Protobuf.Collections { foreach (var pair in list) { - clone.Add(pair.Key, pair.Value == null ? pair.Value : ((IDeepCloneable<TValue>) pair.Value).Clone()); + clone.Add(pair.Key, pair.Value == null ? pair.Value : ((IDeepCloneable<TValue>)pair.Value).Clone()); } } else @@ -309,7 +309,7 @@ namespace Google.Protobuf.Collections /// </remarks> /// <param name="input">Stream to read from</param> /// <param name="codec">Codec describing how the key/value pairs are encoded</param> - public void AddEntriesFrom(CodedInputStream input, Codec codec) + public void AddEntriesFrom(CodedInputStream input, Codec codec) { var adapter = new Codec.MessageAdapter(codec); do @@ -318,7 +318,7 @@ namespace Google.Protobuf.Collections input.ReadMessage(adapter); this[adapter.Key] = adapter.Value; } while (input.MaybeConsumeTag(codec.MapTag)); - } + } public void WriteTo(CodedOutputStream output, Codec codec) { @@ -350,6 +350,104 @@ namespace Google.Protobuf.Collections return size; } + #region IDictionary explicit interface implementation + void IDictionary.Add(object key, object value) + { + Add((TKey)key, (TValue)value); + } + + bool IDictionary.Contains(object key) + { + if (!(key is TKey)) + { + return false; + } + return ContainsKey((TKey)key); + } + + IDictionaryEnumerator IDictionary.GetEnumerator() + { + return new DictionaryEnumerator(GetEnumerator()); + } + + void IDictionary.Remove(object key) + { + ThrowHelper.ThrowIfNull(key, "key"); + this.CheckMutable(); + if (!(key is TKey)) + { + return; + } + Remove((TKey)key); + } + + void ICollection.CopyTo(Array array, int index) + { + // This is ugly and slow as heck, but with any luck it will never be used anyway. + ICollection temp = this.Select(pair => new DictionaryEntry(pair.Key, pair.Value)).ToList(); + temp.CopyTo(array, index); + } + + bool IDictionary.IsFixedSize { get { return IsFrozen; } } + + ICollection IDictionary.Keys { get { return (ICollection)Keys; } } + + ICollection IDictionary.Values { get { return (ICollection)Values; } } + + bool ICollection.IsSynchronized { get { return false; } } + + object ICollection.SyncRoot { get { return this; } } + + object IDictionary.this[object key] + { + get + { + ThrowHelper.ThrowIfNull(key, "key"); + if (!(key is TKey)) + { + return null; + } + TValue value; + TryGetValue((TKey)key, out value); + return value; + } + + set + { + if (frozen) + { + throw new NotSupportedException("Dictionary is frozen"); + } + this[(TKey)key] = (TValue)value; + } + } + #endregion + + private class DictionaryEnumerator : IDictionaryEnumerator + { + private readonly IEnumerator<KeyValuePair<TKey, TValue>> enumerator; + + internal DictionaryEnumerator(IEnumerator<KeyValuePair<TKey, TValue>> enumerator) + { + this.enumerator = enumerator; + } + + public bool MoveNext() + { + return enumerator.MoveNext(); + } + + public void Reset() + { + enumerator.Reset(); + } + + public object Current { get { return Entry; } } + public DictionaryEntry Entry { get { return new DictionaryEntry(Key, Value); } } + public object Key { get { return enumerator.Current.Key; } } + public object Value { get { return enumerator.Current.Value; } } + } + /// <summary> /// A codec for a specific map field. This contains all the information required to encoded and /// decode the nested messages. diff --git a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs index ed311494..b6b52cb9 100644 --- a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs +++ b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs @@ -41,7 +41,7 @@ namespace Google.Protobuf.Collections /// restrictions (no null values) and capabilities (deep cloning and freezing). /// </summary> /// <typeparam name="T">The element type of the repeated field.</typeparam> - public sealed class RepeatedField<T> : IList<T>, IDeepCloneable<RepeatedField<T>>, IEquatable<RepeatedField<T>>, IFreezable + public sealed class RepeatedField<T> : IList<T>, IList, IDeepCloneable<RepeatedField<T>>, IEquatable<RepeatedField<T>>, IFreezable { private static readonly T[] EmptyArray = new T[0]; @@ -376,6 +376,7 @@ namespace Google.Protobuf.Collections this.CheckMutable(); EnsureSize(count + 1); Array.Copy(array, index, array, index + 1, count - index); + array[index] = item; count++; } @@ -415,7 +416,60 @@ namespace Google.Protobuf.Collections array[index] = value; } } - + + #region Explicit interface implementation for IList and ICollection. + bool IList.IsFixedSize { get { return IsFrozen; } } + + void ICollection.CopyTo(Array array, int index) + { + Array.Copy(this.array, 0, array, index, count); + } + + bool ICollection.IsSynchronized { get { return false; } } + + object ICollection.SyncRoot { get { return this; } } + + object IList.this[int index] + { + get { return this[index]; } + set { this[index] = (T)value; } + } + + int IList.Add(object value) + { + Add((T) value); + return count - 1; + } + + bool IList.Contains(object value) + { + return (value is T && Contains((T)value)); + } + + int IList.IndexOf(object value) + { + if (!(value is T)) + { + return -1; + } + return IndexOf((T)value); + } + + void IList.Insert(int index, object value) + { + Insert(index, (T) value); + } + + void IList.Remove(object value) + { + if (!(value is T)) + { + return; + } + Remove((T)value); + } + #endregion + public struct Enumerator : IEnumerator<T> { private int index; @@ -431,6 +485,7 @@ namespace Google.Protobuf.Collections { if (index + 1 >= field.Count) { + index = field.Count; return false; } index++; diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs index 80166a34..c87b367a 100644 --- a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs +++ b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs @@ -10,53 +10,31 @@ using scg = global::System.Collections.Generic; namespace Google.Protobuf.DescriptorProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class DescriptorProtoFile { + internal static partial class DescriptorProtoFile { #region Static variables - internal static pbd::MessageDescriptor internal__static_google_protobuf_FileDescriptorSet__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.FileDescriptorSet> internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_FileDescriptorProto__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.FileDescriptorProto> internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_DescriptorProto__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.DescriptorProto> internal__static_google_protobuf_DescriptorProto__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_DescriptorProto_ExtensionRange__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange> internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_DescriptorProto_ReservedRange__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange> internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_FieldDescriptorProto__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_OneofDescriptorProto__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto> internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_EnumDescriptorProto__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto> internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_EnumValueDescriptorProto__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto> internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_ServiceDescriptorProto__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto> internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_MethodDescriptorProto__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto> internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_FileOptions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.FileOptions> internal__static_google_protobuf_FileOptions__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_MessageOptions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.MessageOptions> internal__static_google_protobuf_MessageOptions__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_FieldOptions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.FieldOptions> internal__static_google_protobuf_FieldOptions__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_EnumOptions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.EnumOptions> internal__static_google_protobuf_EnumOptions__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_EnumValueOptions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.EnumValueOptions> internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_ServiceOptions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.ServiceOptions> internal__static_google_protobuf_ServiceOptions__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_MethodOptions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.MethodOptions> internal__static_google_protobuf_MethodOptions__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_UninterpretedOption__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_UninterpretedOption_NamePart__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart> internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_SourceCodeInfo__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.SourceCodeInfo> internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_SourceCodeInfo_Location__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location> internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_DescriptorProto__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_FileOptions__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_MessageOptions__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_FieldOptions__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_EnumOptions__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_ServiceOptions__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_MethodOptions__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable; #endregion #region Descriptor public static pbd::FileDescriptor Descriptor { @@ -178,126 +156,105 @@ namespace Google.Protobuf.DescriptorProtos { "bWVudHMYBiADKAlCXgoTY29tLmdvb2dsZS5wcm90b2J1ZkIQRGVzY3JpcHRv", "clByb3Rvc0gBWgpkZXNjcmlwdG9yogIDR1BCqgIgR29vZ2xlLlByb3RvYnVm", "LkRlc2NyaXB0b3JQcm90b3M=")); - pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { - descriptor = root; - internal__static_google_protobuf_FileDescriptorSet__Descriptor = Descriptor.MessageTypes[0]; - internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.FileDescriptorSet>(internal__static_google_protobuf_FileDescriptorSet__Descriptor, - new string[] { "File", }); - internal__static_google_protobuf_FileDescriptorProto__Descriptor = Descriptor.MessageTypes[1]; - internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.FileDescriptorProto>(internal__static_google_protobuf_FileDescriptorProto__Descriptor, - new string[] { "Name", "Package", "Dependency", "PublicDependency", "WeakDependency", "MessageType", "EnumType", "Service", "Extension", "Options", "SourceCodeInfo", "Syntax", }); - internal__static_google_protobuf_DescriptorProto__Descriptor = Descriptor.MessageTypes[2]; - internal__static_google_protobuf_DescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.DescriptorProto>(internal__static_google_protobuf_DescriptorProto__Descriptor, - new string[] { "Name", "Field", "Extension", "NestedType", "EnumType", "ExtensionRange", "OneofDecl", "Options", "ReservedRange", "ReservedName", }); - internal__static_google_protobuf_DescriptorProto_ExtensionRange__Descriptor = internal__static_google_protobuf_DescriptorProto__Descriptor.NestedTypes[0]; - internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange>(internal__static_google_protobuf_DescriptorProto_ExtensionRange__Descriptor, - new string[] { "Start", "End", }); - internal__static_google_protobuf_DescriptorProto_ReservedRange__Descriptor = internal__static_google_protobuf_DescriptorProto__Descriptor.NestedTypes[1]; - internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange>(internal__static_google_protobuf_DescriptorProto_ReservedRange__Descriptor, - new string[] { "Start", "End", }); - internal__static_google_protobuf_FieldDescriptorProto__Descriptor = Descriptor.MessageTypes[3]; - internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto>(internal__static_google_protobuf_FieldDescriptorProto__Descriptor, - new string[] { "Name", "Number", "Label", "Type", "TypeName", "Extendee", "DefaultValue", "OneofIndex", "Options", }); - internal__static_google_protobuf_OneofDescriptorProto__Descriptor = Descriptor.MessageTypes[4]; - internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto>(internal__static_google_protobuf_OneofDescriptorProto__Descriptor, - new string[] { "Name", }); - internal__static_google_protobuf_EnumDescriptorProto__Descriptor = Descriptor.MessageTypes[5]; - internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto>(internal__static_google_protobuf_EnumDescriptorProto__Descriptor, - new string[] { "Name", "Value", "Options", }); - internal__static_google_protobuf_EnumValueDescriptorProto__Descriptor = Descriptor.MessageTypes[6]; - internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto>(internal__static_google_protobuf_EnumValueDescriptorProto__Descriptor, - new string[] { "Name", "Number", "Options", }); - internal__static_google_protobuf_ServiceDescriptorProto__Descriptor = Descriptor.MessageTypes[7]; - internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto>(internal__static_google_protobuf_ServiceDescriptorProto__Descriptor, - new string[] { "Name", "Method", "Options", }); - internal__static_google_protobuf_MethodDescriptorProto__Descriptor = Descriptor.MessageTypes[8]; - internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto>(internal__static_google_protobuf_MethodDescriptorProto__Descriptor, - new string[] { "Name", "InputType", "OutputType", "Options", "ClientStreaming", "ServerStreaming", }); - internal__static_google_protobuf_FileOptions__Descriptor = Descriptor.MessageTypes[9]; - internal__static_google_protobuf_FileOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.FileOptions>(internal__static_google_protobuf_FileOptions__Descriptor, - new string[] { "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "UninterpretedOption", }); - internal__static_google_protobuf_MessageOptions__Descriptor = Descriptor.MessageTypes[10]; - internal__static_google_protobuf_MessageOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.MessageOptions>(internal__static_google_protobuf_MessageOptions__Descriptor, - new string[] { "MessageSetWireFormat", "NoStandardDescriptorAccessor", "Deprecated", "MapEntry", "UninterpretedOption", }); - internal__static_google_protobuf_FieldOptions__Descriptor = Descriptor.MessageTypes[11]; - internal__static_google_protobuf_FieldOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.FieldOptions>(internal__static_google_protobuf_FieldOptions__Descriptor, - new string[] { "Ctype", "Packed", "Jstype", "Lazy", "Deprecated", "Weak", "UninterpretedOption", }); - internal__static_google_protobuf_EnumOptions__Descriptor = Descriptor.MessageTypes[12]; - internal__static_google_protobuf_EnumOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.EnumOptions>(internal__static_google_protobuf_EnumOptions__Descriptor, - new string[] { "AllowAlias", "Deprecated", "UninterpretedOption", }); - internal__static_google_protobuf_EnumValueOptions__Descriptor = Descriptor.MessageTypes[13]; - internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.EnumValueOptions>(internal__static_google_protobuf_EnumValueOptions__Descriptor, - new string[] { "Deprecated", "UninterpretedOption", }); - internal__static_google_protobuf_ServiceOptions__Descriptor = Descriptor.MessageTypes[14]; - internal__static_google_protobuf_ServiceOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.ServiceOptions>(internal__static_google_protobuf_ServiceOptions__Descriptor, - new string[] { "Deprecated", "UninterpretedOption", }); - internal__static_google_protobuf_MethodOptions__Descriptor = Descriptor.MessageTypes[15]; - internal__static_google_protobuf_MethodOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.MethodOptions>(internal__static_google_protobuf_MethodOptions__Descriptor, - new string[] { "Deprecated", "UninterpretedOption", }); - internal__static_google_protobuf_UninterpretedOption__Descriptor = Descriptor.MessageTypes[16]; - internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(internal__static_google_protobuf_UninterpretedOption__Descriptor, - new string[] { "Name", "IdentifierValue", "PositiveIntValue", "NegativeIntValue", "DoubleValue", "StringValue", "AggregateValue", }); - internal__static_google_protobuf_UninterpretedOption_NamePart__Descriptor = internal__static_google_protobuf_UninterpretedOption__Descriptor.NestedTypes[0]; - internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart>(internal__static_google_protobuf_UninterpretedOption_NamePart__Descriptor, - new string[] { "NamePart_", "IsExtension", }); - internal__static_google_protobuf_SourceCodeInfo__Descriptor = Descriptor.MessageTypes[17]; - internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.SourceCodeInfo>(internal__static_google_protobuf_SourceCodeInfo__Descriptor, - new string[] { "Location", }); - internal__static_google_protobuf_SourceCodeInfo_Location__Descriptor = internal__static_google_protobuf_SourceCodeInfo__Descriptor.NestedTypes[0]; - internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location>(internal__static_google_protobuf_SourceCodeInfo_Location__Descriptor, - new string[] { "Path", "Span", "LeadingComments", "TrailingComments", "LeadingDetachedComments", }); - }; - pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + descriptor = pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, new pbd::FileDescriptor[] { - }, assigner); + }); + internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.FileDescriptorSet), descriptor.MessageTypes[0], + new string[] { "File", }); + internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.FileDescriptorProto), descriptor.MessageTypes[1], + new string[] { "Name", "Package", "Dependency", "PublicDependency", "WeakDependency", "MessageType", "EnumType", "Service", "Extension", "Options", "SourceCodeInfo", "Syntax", }); + internal__static_google_protobuf_DescriptorProto__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.DescriptorProto), descriptor.MessageTypes[2], + new string[] { "Name", "Field", "Extension", "NestedType", "EnumType", "ExtensionRange", "OneofDecl", "Options", "ReservedRange", "ReservedName", }); + internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange), descriptor.MessageTypes[2].NestedTypes[0], + new string[] { "Start", "End", }); + internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange), descriptor.MessageTypes[2].NestedTypes[1], + new string[] { "Start", "End", }); + internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto), descriptor.MessageTypes[3], + new string[] { "Name", "Number", "Label", "Type", "TypeName", "Extendee", "DefaultValue", "OneofIndex", "Options", }); + internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto), descriptor.MessageTypes[4], + new string[] { "Name", }); + internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto), descriptor.MessageTypes[5], + new string[] { "Name", "Value", "Options", }); + internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto), descriptor.MessageTypes[6], + new string[] { "Name", "Number", "Options", }); + internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto), descriptor.MessageTypes[7], + new string[] { "Name", "Method", "Options", }); + internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto), descriptor.MessageTypes[8], + new string[] { "Name", "InputType", "OutputType", "Options", "ClientStreaming", "ServerStreaming", }); + internal__static_google_protobuf_FileOptions__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.FileOptions), descriptor.MessageTypes[9], + new string[] { "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "UninterpretedOption", }); + internal__static_google_protobuf_MessageOptions__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.MessageOptions), descriptor.MessageTypes[10], + new string[] { "MessageSetWireFormat", "NoStandardDescriptorAccessor", "Deprecated", "MapEntry", "UninterpretedOption", }); + internal__static_google_protobuf_FieldOptions__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.FieldOptions), descriptor.MessageTypes[11], + new string[] { "Ctype", "Packed", "Jstype", "Lazy", "Deprecated", "Weak", "UninterpretedOption", }); + internal__static_google_protobuf_EnumOptions__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.EnumOptions), descriptor.MessageTypes[12], + new string[] { "AllowAlias", "Deprecated", "UninterpretedOption", }); + internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.EnumValueOptions), descriptor.MessageTypes[13], + new string[] { "Deprecated", "UninterpretedOption", }); + internal__static_google_protobuf_ServiceOptions__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.ServiceOptions), descriptor.MessageTypes[14], + new string[] { "Deprecated", "UninterpretedOption", }); + internal__static_google_protobuf_MethodOptions__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.MethodOptions), descriptor.MessageTypes[15], + new string[] { "Deprecated", "UninterpretedOption", }); + internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.UninterpretedOption), descriptor.MessageTypes[16], + new string[] { "Name", "IdentifierValue", "PositiveIntValue", "NegativeIntValue", "DoubleValue", "StringValue", "AggregateValue", }); + internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart), descriptor.MessageTypes[16].NestedTypes[0], + new string[] { "NamePart_", "IsExtension", }); + internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.SourceCodeInfo), descriptor.MessageTypes[17], + new string[] { "Location", }); + internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location), descriptor.MessageTypes[17].NestedTypes[0], + new string[] { "Path", "Span", "LeadingComments", "TrailingComments", "LeadingDetachedComments", }); } #endregion } #region Messages [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FileDescriptorSet : pb::IMessage<FileDescriptorSet> { + internal sealed partial class FileDescriptorSet : pb::IMessage<FileDescriptorSet> { private static readonly pb::MessageParser<FileDescriptorSet> _parser = new pb::MessageParser<FileDescriptorSet>(() => new FileDescriptorSet()); public static pb::MessageParser<FileDescriptorSet> Parser { get { return _parser; } } private static readonly string[] _fieldNames = new string[] { "file" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorSet__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable<FileDescriptorSet> Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable; } } private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public FileDescriptorSet() { } + public FileDescriptorSet() { + OnConstruction(); + } + + partial void OnConstruction(); - public FileDescriptorSet(FileDescriptorSet other) { + public FileDescriptorSet(FileDescriptorSet other) : this() { file_ = other.file_.Clone(); } @@ -317,7 +274,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.FileDescriptorProto> _repeated_file_codec = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.DescriptorProtos.FileDescriptorProto.Parser); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FileDescriptorProto> file_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FileDescriptorProto>(); - public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FileDescriptorProto> File { + internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FileDescriptorProto> File { get { return file_; } } @@ -381,26 +338,30 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FileDescriptorProto : pb::IMessage<FileDescriptorProto> { + internal sealed partial class FileDescriptorProto : pb::IMessage<FileDescriptorProto> { private static readonly pb::MessageParser<FileDescriptorProto> _parser = new pb::MessageParser<FileDescriptorProto>(() => new FileDescriptorProto()); public static pb::MessageParser<FileDescriptorProto> Parser { get { return _parser; } } private static readonly string[] _fieldNames = new string[] { "dependency", "enum_type", "extension", "message_type", "name", "options", "package", "public_dependency", "service", "source_code_info", "syntax", "weak_dependency" }; private static readonly uint[] _fieldTags = new uint[] { 26, 42, 58, 34, 10, 66, 18, 80, 50, 74, 98, 88 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorProto__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[1]; } } - public pb::FieldAccess.FieldAccessorTable<FileDescriptorProto> Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable; } } private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public FileDescriptorProto() { } + public FileDescriptorProto() { + OnConstruction(); + } + + partial void OnConstruction(); - public FileDescriptorProto(FileDescriptorProto other) { + public FileDescriptorProto(FileDescriptorProto other) : this() { name_ = other.name_; package_ = other.package_; dependency_ = other.dependency_.Clone(); @@ -437,7 +398,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int NameFieldNumber = 1; private string name_ = ""; - public string Name { + internal string Name { get { return name_; } set { pb::Freezable.CheckMutable(this); @@ -447,7 +408,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int PackageFieldNumber = 2; private string package_ = ""; - public string Package { + internal string Package { get { return package_; } set { pb::Freezable.CheckMutable(this); @@ -459,7 +420,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<string> _repeated_dependency_codec = pb::FieldCodec.ForString(26); private readonly pbc::RepeatedField<string> dependency_ = new pbc::RepeatedField<string>(); - public pbc::RepeatedField<string> Dependency { + internal pbc::RepeatedField<string> Dependency { get { return dependency_; } } @@ -467,7 +428,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<int> _repeated_publicDependency_codec = pb::FieldCodec.ForInt32(80); private readonly pbc::RepeatedField<int> publicDependency_ = new pbc::RepeatedField<int>(); - public pbc::RepeatedField<int> PublicDependency { + internal pbc::RepeatedField<int> PublicDependency { get { return publicDependency_; } } @@ -475,7 +436,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<int> _repeated_weakDependency_codec = pb::FieldCodec.ForInt32(88); private readonly pbc::RepeatedField<int> weakDependency_ = new pbc::RepeatedField<int>(); - public pbc::RepeatedField<int> WeakDependency { + internal pbc::RepeatedField<int> WeakDependency { get { return weakDependency_; } } @@ -483,7 +444,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.DescriptorProto> _repeated_messageType_codec = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Parser); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto> messageType_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto>(); - public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto> MessageType { + internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto> MessageType { get { return messageType_; } } @@ -491,7 +452,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto> _repeated_enumType_codec = pb::FieldCodec.ForMessage(42, global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto.Parser); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto> enumType_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto>(); - public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto> EnumType { + internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto> EnumType { get { return enumType_; } } @@ -499,7 +460,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto> _repeated_service_codec = pb::FieldCodec.ForMessage(50, global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto.Parser); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto> service_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto>(); - public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto> Service { + internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto> Service { get { return service_; } } @@ -507,13 +468,13 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> _repeated_extension_codec = pb::FieldCodec.ForMessage(58, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> extension_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto>(); - public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> Extension { + internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> Extension { get { return extension_; } } public const int OptionsFieldNumber = 8; private global::Google.Protobuf.DescriptorProtos.FileOptions options_; - public global::Google.Protobuf.DescriptorProtos.FileOptions Options { + internal global::Google.Protobuf.DescriptorProtos.FileOptions Options { get { return options_; } set { pb::Freezable.CheckMutable(this); @@ -523,7 +484,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int SourceCodeInfoFieldNumber = 9; private global::Google.Protobuf.DescriptorProtos.SourceCodeInfo sourceCodeInfo_; - public global::Google.Protobuf.DescriptorProtos.SourceCodeInfo SourceCodeInfo { + internal global::Google.Protobuf.DescriptorProtos.SourceCodeInfo SourceCodeInfo { get { return sourceCodeInfo_; } set { pb::Freezable.CheckMutable(this); @@ -533,7 +494,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int SyntaxFieldNumber = 12; private string syntax_ = ""; - public string Syntax { + internal string Syntax { get { return syntax_; } set { pb::Freezable.CheckMutable(this); @@ -749,26 +710,30 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class DescriptorProto : pb::IMessage<DescriptorProto> { + internal sealed partial class DescriptorProto : pb::IMessage<DescriptorProto> { private static readonly pb::MessageParser<DescriptorProto> _parser = new pb::MessageParser<DescriptorProto>(() => new DescriptorProto()); public static pb::MessageParser<DescriptorProto> Parser { get { return _parser; } } private static readonly string[] _fieldNames = new string[] { "enum_type", "extension", "extension_range", "field", "name", "nested_type", "oneof_decl", "options", "reserved_name", "reserved_range" }; private static readonly uint[] _fieldTags = new uint[] { 34, 50, 42, 18, 10, 26, 66, 58, 82, 74 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[2]; } } - public pb::FieldAccess.FieldAccessorTable<DescriptorProto> Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto__FieldAccessorTable; } } private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public DescriptorProto() { } + public DescriptorProto() { + OnConstruction(); + } + + partial void OnConstruction(); - public DescriptorProto(DescriptorProto other) { + public DescriptorProto(DescriptorProto other) : this() { name_ = other.name_; field_ = other.field_.Clone(); extension_ = other.extension_.Clone(); @@ -803,7 +768,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int NameFieldNumber = 1; private string name_ = ""; - public string Name { + internal string Name { get { return name_; } set { pb::Freezable.CheckMutable(this); @@ -815,7 +780,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> _repeated_field_codec = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> field_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto>(); - public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> Field { + internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> Field { get { return field_; } } @@ -823,7 +788,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> _repeated_extension_codec = pb::FieldCodec.ForMessage(50, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> extension_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto>(); - public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> Extension { + internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> Extension { get { return extension_; } } @@ -831,7 +796,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.DescriptorProto> _repeated_nestedType_codec = pb::FieldCodec.ForMessage(26, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Parser); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto> nestedType_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto>(); - public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto> NestedType { + internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto> NestedType { get { return nestedType_; } } @@ -839,7 +804,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto> _repeated_enumType_codec = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto.Parser); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto> enumType_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto>(); - public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto> EnumType { + internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto> EnumType { get { return enumType_; } } @@ -847,7 +812,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange> _repeated_extensionRange_codec = pb::FieldCodec.ForMessage(42, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange.Parser); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange> extensionRange_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange>(); - public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange> ExtensionRange { + internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange> ExtensionRange { get { return extensionRange_; } } @@ -855,13 +820,13 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto> _repeated_oneofDecl_codec = pb::FieldCodec.ForMessage(66, global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto.Parser); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto> oneofDecl_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto>(); - public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto> OneofDecl { + internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto> OneofDecl { get { return oneofDecl_; } } public const int OptionsFieldNumber = 7; private global::Google.Protobuf.DescriptorProtos.MessageOptions options_; - public global::Google.Protobuf.DescriptorProtos.MessageOptions Options { + internal global::Google.Protobuf.DescriptorProtos.MessageOptions Options { get { return options_; } set { pb::Freezable.CheckMutable(this); @@ -873,7 +838,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange> _repeated_reservedRange_codec = pb::FieldCodec.ForMessage(74, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange.Parser); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange> reservedRange_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange>(); - public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange> ReservedRange { + internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange> ReservedRange { get { return reservedRange_; } } @@ -881,7 +846,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<string> _repeated_reservedName_codec = pb::FieldCodec.ForString(82); private readonly pbc::RepeatedField<string> reservedName_ = new pbc::RepeatedField<string>(); - public pbc::RepeatedField<string> ReservedName { + internal pbc::RepeatedField<string> ReservedName { get { return reservedName_; } } @@ -1047,26 +1012,30 @@ namespace Google.Protobuf.DescriptorProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Types { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ExtensionRange : pb::IMessage<ExtensionRange> { + internal sealed partial class ExtensionRange : pb::IMessage<ExtensionRange> { private static readonly pb::MessageParser<ExtensionRange> _parser = new pb::MessageParser<ExtensionRange>(() => new ExtensionRange()); public static pb::MessageParser<ExtensionRange> Parser { get { return _parser; } } private static readonly string[] _fieldNames = new string[] { "end", "start" }; private static readonly uint[] _fieldTags = new uint[] { 16, 8 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ExtensionRange__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProto.Descriptor.NestedTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable<ExtensionRange> Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable; } } private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public ExtensionRange() { } + public ExtensionRange() { + OnConstruction(); + } + + partial void OnConstruction(); - public ExtensionRange(ExtensionRange other) { + public ExtensionRange(ExtensionRange other) : this() { start_ = other.start_; end_ = other.end_; } @@ -1084,7 +1053,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int StartFieldNumber = 1; private int start_; - public int Start { + internal int Start { get { return start_; } set { pb::Freezable.CheckMutable(this); @@ -1094,7 +1063,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int EndFieldNumber = 2; private int end_; - public int End { + internal int End { get { return end_; } set { pb::Freezable.CheckMutable(this); @@ -1185,26 +1154,30 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ReservedRange : pb::IMessage<ReservedRange> { + internal sealed partial class ReservedRange : pb::IMessage<ReservedRange> { private static readonly pb::MessageParser<ReservedRange> _parser = new pb::MessageParser<ReservedRange>(() => new ReservedRange()); public static pb::MessageParser<ReservedRange> Parser { get { return _parser; } } private static readonly string[] _fieldNames = new string[] { "end", "start" }; private static readonly uint[] _fieldTags = new uint[] { 16, 8 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ReservedRange__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProto.Descriptor.NestedTypes[1]; } } - public pb::FieldAccess.FieldAccessorTable<ReservedRange> Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable; } } private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public ReservedRange() { } + public ReservedRange() { + OnConstruction(); + } - public ReservedRange(ReservedRange other) { + partial void OnConstruction(); + + public ReservedRange(ReservedRange other) : this() { start_ = other.start_; end_ = other.end_; } @@ -1222,7 +1195,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int StartFieldNumber = 1; private int start_; - public int Start { + internal int Start { get { return start_; } set { pb::Freezable.CheckMutable(this); @@ -1232,7 +1205,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int EndFieldNumber = 2; private int end_; - public int End { + internal int End { get { return end_; } set { pb::Freezable.CheckMutable(this); @@ -1328,26 +1301,30 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FieldDescriptorProto : pb::IMessage<FieldDescriptorProto> { + internal sealed partial class FieldDescriptorProto : pb::IMessage<FieldDescriptorProto> { private static readonly pb::MessageParser<FieldDescriptorProto> _parser = new pb::MessageParser<FieldDescriptorProto>(() => new FieldDescriptorProto()); public static pb::MessageParser<FieldDescriptorProto> Parser { get { return _parser; } } private static readonly string[] _fieldNames = new string[] { "default_value", "extendee", "label", "name", "number", "oneof_index", "options", "type", "type_name" }; private static readonly uint[] _fieldTags = new uint[] { 58, 18, 32, 10, 24, 72, 66, 40, 50 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FieldDescriptorProto__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[3]; } } - public pb::FieldAccess.FieldAccessorTable<FieldDescriptorProto> Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable; } } private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public FieldDescriptorProto() { } + public FieldDescriptorProto() { + OnConstruction(); + } + + partial void OnConstruction(); - public FieldDescriptorProto(FieldDescriptorProto other) { + public FieldDescriptorProto(FieldDescriptorProto other) : this() { name_ = other.name_; number_ = other.number_; label_ = other.label_; @@ -1373,7 +1350,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int NameFieldNumber = 1; private string name_ = ""; - public string Name { + internal string Name { get { return name_; } set { pb::Freezable.CheckMutable(this); @@ -1383,7 +1360,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int NumberFieldNumber = 3; private int number_; - public int Number { + internal int Number { get { return number_; } set { pb::Freezable.CheckMutable(this); @@ -1393,7 +1370,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int LabelFieldNumber = 4; private global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label label_ = global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL; - public global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label Label { + internal global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label Label { get { return label_; } set { pb::Freezable.CheckMutable(this); @@ -1403,7 +1380,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int TypeFieldNumber = 5; private global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type type_ = global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE; - public global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type Type { + internal global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type Type { get { return type_; } set { pb::Freezable.CheckMutable(this); @@ -1413,7 +1390,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int TypeNameFieldNumber = 6; private string typeName_ = ""; - public string TypeName { + internal string TypeName { get { return typeName_; } set { pb::Freezable.CheckMutable(this); @@ -1423,7 +1400,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int ExtendeeFieldNumber = 2; private string extendee_ = ""; - public string Extendee { + internal string Extendee { get { return extendee_; } set { pb::Freezable.CheckMutable(this); @@ -1433,7 +1410,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int DefaultValueFieldNumber = 7; private string defaultValue_ = ""; - public string DefaultValue { + internal string DefaultValue { get { return defaultValue_; } set { pb::Freezable.CheckMutable(this); @@ -1443,7 +1420,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int OneofIndexFieldNumber = 9; private int oneofIndex_; - public int OneofIndex { + internal int OneofIndex { get { return oneofIndex_; } set { pb::Freezable.CheckMutable(this); @@ -1453,7 +1430,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int OptionsFieldNumber = 8; private global::Google.Protobuf.DescriptorProtos.FieldOptions options_; - public global::Google.Protobuf.DescriptorProtos.FieldOptions Options { + internal global::Google.Protobuf.DescriptorProtos.FieldOptions Options { get { return options_; } set { pb::Freezable.CheckMutable(this); @@ -1662,7 +1639,7 @@ namespace Google.Protobuf.DescriptorProtos { #region Nested types [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Types { - public enum Type { + internal enum Type { TYPE_DOUBLE = 1, TYPE_FLOAT = 2, TYPE_INT64 = 3, @@ -1683,7 +1660,7 @@ namespace Google.Protobuf.DescriptorProtos { TYPE_SINT64 = 18, } - public enum Label { + internal enum Label { LABEL_OPTIONAL = 1, LABEL_REQUIRED = 2, LABEL_REPEATED = 3, @@ -1695,26 +1672,30 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class OneofDescriptorProto : pb::IMessage<OneofDescriptorProto> { + internal sealed partial class OneofDescriptorProto : pb::IMessage<OneofDescriptorProto> { private static readonly pb::MessageParser<OneofDescriptorProto> _parser = new pb::MessageParser<OneofDescriptorProto>(() => new OneofDescriptorProto()); public static pb::MessageParser<OneofDescriptorProto> Parser { get { return _parser; } } private static readonly string[] _fieldNames = new string[] { "name" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_OneofDescriptorProto__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[4]; } } - public pb::FieldAccess.FieldAccessorTable<OneofDescriptorProto> Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable; } } private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public OneofDescriptorProto() { } + public OneofDescriptorProto() { + OnConstruction(); + } + + partial void OnConstruction(); - public OneofDescriptorProto(OneofDescriptorProto other) { + public OneofDescriptorProto(OneofDescriptorProto other) : this() { name_ = other.name_; } @@ -1731,7 +1712,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int NameFieldNumber = 1; private string name_ = ""; - public string Name { + internal string Name { get { return name_; } set { pb::Freezable.CheckMutable(this); @@ -1806,26 +1787,30 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class EnumDescriptorProto : pb::IMessage<EnumDescriptorProto> { + internal sealed partial class EnumDescriptorProto : pb::IMessage<EnumDescriptorProto> { private static readonly pb::MessageParser<EnumDescriptorProto> _parser = new pb::MessageParser<EnumDescriptorProto>(() => new EnumDescriptorProto()); public static pb::MessageParser<EnumDescriptorProto> Parser { get { return _parser; } } private static readonly string[] _fieldNames = new string[] { "name", "options", "value" }; private static readonly uint[] _fieldTags = new uint[] { 10, 26, 18 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumDescriptorProto__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[5]; } } - public pb::FieldAccess.FieldAccessorTable<EnumDescriptorProto> Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable; } } private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public EnumDescriptorProto() { } + public EnumDescriptorProto() { + OnConstruction(); + } + + partial void OnConstruction(); - public EnumDescriptorProto(EnumDescriptorProto other) { + public EnumDescriptorProto(EnumDescriptorProto other) : this() { name_ = other.name_; value_ = other.value_.Clone(); Options = other.options_ != null ? other.Options.Clone() : null; @@ -1846,7 +1831,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int NameFieldNumber = 1; private string name_ = ""; - public string Name { + internal string Name { get { return name_; } set { pb::Freezable.CheckMutable(this); @@ -1858,13 +1843,13 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto> _repeated_value_codec = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto.Parser); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto> value_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto>(); - public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto> Value { + internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto> Value { get { return value_; } } public const int OptionsFieldNumber = 3; private global::Google.Protobuf.DescriptorProtos.EnumOptions options_; - public global::Google.Protobuf.DescriptorProtos.EnumOptions Options { + internal global::Google.Protobuf.DescriptorProtos.EnumOptions Options { get { return options_; } set { pb::Freezable.CheckMutable(this); @@ -1970,26 +1955,30 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class EnumValueDescriptorProto : pb::IMessage<EnumValueDescriptorProto> { + internal sealed partial class EnumValueDescriptorProto : pb::IMessage<EnumValueDescriptorProto> { private static readonly pb::MessageParser<EnumValueDescriptorProto> _parser = new pb::MessageParser<EnumValueDescriptorProto>(() => new EnumValueDescriptorProto()); public static pb::MessageParser<EnumValueDescriptorProto> Parser { get { return _parser; } } private static readonly string[] _fieldNames = new string[] { "name", "number", "options" }; private static readonly uint[] _fieldTags = new uint[] { 10, 16, 26 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumValueDescriptorProto__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[6]; } } - public pb::FieldAccess.FieldAccessorTable<EnumValueDescriptorProto> Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable; } } private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public EnumValueDescriptorProto() { } + public EnumValueDescriptorProto() { + OnConstruction(); + } - public EnumValueDescriptorProto(EnumValueDescriptorProto other) { + partial void OnConstruction(); + + public EnumValueDescriptorProto(EnumValueDescriptorProto other) : this() { name_ = other.name_; number_ = other.number_; Options = other.options_ != null ? other.Options.Clone() : null; @@ -2009,7 +1998,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int NameFieldNumber = 1; private string name_ = ""; - public string Name { + internal string Name { get { return name_; } set { pb::Freezable.CheckMutable(this); @@ -2019,7 +2008,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int NumberFieldNumber = 2; private int number_; - public int Number { + internal int Number { get { return number_; } set { pb::Freezable.CheckMutable(this); @@ -2029,7 +2018,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int OptionsFieldNumber = 3; private global::Google.Protobuf.DescriptorProtos.EnumValueOptions options_; - public global::Google.Protobuf.DescriptorProtos.EnumValueOptions Options { + internal global::Google.Protobuf.DescriptorProtos.EnumValueOptions Options { get { return options_; } set { pb::Freezable.CheckMutable(this); @@ -2142,26 +2131,30 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ServiceDescriptorProto : pb::IMessage<ServiceDescriptorProto> { + internal sealed partial class ServiceDescriptorProto : pb::IMessage<ServiceDescriptorProto> { private static readonly pb::MessageParser<ServiceDescriptorProto> _parser = new pb::MessageParser<ServiceDescriptorProto>(() => new ServiceDescriptorProto()); public static pb::MessageParser<ServiceDescriptorProto> Parser { get { return _parser; } } private static readonly string[] _fieldNames = new string[] { "method", "name", "options" }; private static readonly uint[] _fieldTags = new uint[] { 18, 10, 26 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_ServiceDescriptorProto__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[7]; } } - public pb::FieldAccess.FieldAccessorTable<ServiceDescriptorProto> Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable; } } private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public ServiceDescriptorProto() { } + public ServiceDescriptorProto() { + OnConstruction(); + } + + partial void OnConstruction(); - public ServiceDescriptorProto(ServiceDescriptorProto other) { + public ServiceDescriptorProto(ServiceDescriptorProto other) : this() { name_ = other.name_; method_ = other.method_.Clone(); Options = other.options_ != null ? other.Options.Clone() : null; @@ -2182,7 +2175,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int NameFieldNumber = 1; private string name_ = ""; - public string Name { + internal string Name { get { return name_; } set { pb::Freezable.CheckMutable(this); @@ -2194,13 +2187,13 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto> _repeated_method_codec = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto.Parser); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto> method_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto>(); - public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto> Method { + internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto> Method { get { return method_; } } public const int OptionsFieldNumber = 3; private global::Google.Protobuf.DescriptorProtos.ServiceOptions options_; - public global::Google.Protobuf.DescriptorProtos.ServiceOptions Options { + internal global::Google.Protobuf.DescriptorProtos.ServiceOptions Options { get { return options_; } set { pb::Freezable.CheckMutable(this); @@ -2306,26 +2299,30 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MethodDescriptorProto : pb::IMessage<MethodDescriptorProto> { + internal sealed partial class MethodDescriptorProto : pb::IMessage<MethodDescriptorProto> { private static readonly pb::MessageParser<MethodDescriptorProto> _parser = new pb::MessageParser<MethodDescriptorProto>(() => new MethodDescriptorProto()); public static pb::MessageParser<MethodDescriptorProto> Parser { get { return _parser; } } private static readonly string[] _fieldNames = new string[] { "client_streaming", "input_type", "name", "options", "output_type", "server_streaming" }; private static readonly uint[] _fieldTags = new uint[] { 40, 18, 10, 34, 26, 48 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MethodDescriptorProto__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[8]; } } - public pb::FieldAccess.FieldAccessorTable<MethodDescriptorProto> Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable; } } private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MethodDescriptorProto() { } + public MethodDescriptorProto() { + OnConstruction(); + } + + partial void OnConstruction(); - public MethodDescriptorProto(MethodDescriptorProto other) { + public MethodDescriptorProto(MethodDescriptorProto other) : this() { name_ = other.name_; inputType_ = other.inputType_; outputType_ = other.outputType_; @@ -2348,7 +2345,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int NameFieldNumber = 1; private string name_ = ""; - public string Name { + internal string Name { get { return name_; } set { pb::Freezable.CheckMutable(this); @@ -2358,7 +2355,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int InputTypeFieldNumber = 2; private string inputType_ = ""; - public string InputType { + internal string InputType { get { return inputType_; } set { pb::Freezable.CheckMutable(this); @@ -2368,7 +2365,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int OutputTypeFieldNumber = 3; private string outputType_ = ""; - public string OutputType { + internal string OutputType { get { return outputType_; } set { pb::Freezable.CheckMutable(this); @@ -2378,7 +2375,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int OptionsFieldNumber = 4; private global::Google.Protobuf.DescriptorProtos.MethodOptions options_; - public global::Google.Protobuf.DescriptorProtos.MethodOptions Options { + internal global::Google.Protobuf.DescriptorProtos.MethodOptions Options { get { return options_; } set { pb::Freezable.CheckMutable(this); @@ -2388,7 +2385,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int ClientStreamingFieldNumber = 5; private bool clientStreaming_; - public bool ClientStreaming { + internal bool ClientStreaming { get { return clientStreaming_; } set { pb::Freezable.CheckMutable(this); @@ -2398,7 +2395,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int ServerStreamingFieldNumber = 6; private bool serverStreaming_; - public bool ServerStreaming { + internal bool ServerStreaming { get { return serverStreaming_; } set { pb::Freezable.CheckMutable(this); @@ -2559,26 +2556,30 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FileOptions : pb::IMessage<FileOptions> { + internal sealed partial class FileOptions : pb::IMessage<FileOptions> { private static readonly pb::MessageParser<FileOptions> _parser = new pb::MessageParser<FileOptions>(() => new FileOptions()); public static pb::MessageParser<FileOptions> Parser { get { return _parser; } } private static readonly string[] _fieldNames = new string[] { "cc_enable_arenas", "cc_generic_services", "csharp_namespace", "deprecated", "go_package", "java_generate_equals_and_hash", "java_generic_services", "java_multiple_files", "java_outer_classname", "java_package", "java_string_check_utf8", "objc_class_prefix", "optimize_for", "py_generic_services", "uninterpreted_option" }; private static readonly uint[] _fieldTags = new uint[] { 248, 128, 298, 184, 90, 160, 136, 80, 66, 10, 216, 290, 72, 144, 7994 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileOptions__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[9]; } } - public pb::FieldAccess.FieldAccessorTable<FileOptions> Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileOptions__FieldAccessorTable; } } private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public FileOptions() { } + public FileOptions() { + OnConstruction(); + } + + partial void OnConstruction(); - public FileOptions(FileOptions other) { + public FileOptions(FileOptions other) : this() { javaPackage_ = other.javaPackage_; javaOuterClassname_ = other.javaOuterClassname_; javaMultipleFiles_ = other.javaMultipleFiles_; @@ -2610,7 +2611,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int JavaPackageFieldNumber = 1; private string javaPackage_ = ""; - public string JavaPackage { + internal string JavaPackage { get { return javaPackage_; } set { pb::Freezable.CheckMutable(this); @@ -2620,7 +2621,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int JavaOuterClassnameFieldNumber = 8; private string javaOuterClassname_ = ""; - public string JavaOuterClassname { + internal string JavaOuterClassname { get { return javaOuterClassname_; } set { pb::Freezable.CheckMutable(this); @@ -2630,7 +2631,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int JavaMultipleFilesFieldNumber = 10; private bool javaMultipleFiles_; - public bool JavaMultipleFiles { + internal bool JavaMultipleFiles { get { return javaMultipleFiles_; } set { pb::Freezable.CheckMutable(this); @@ -2640,7 +2641,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int JavaGenerateEqualsAndHashFieldNumber = 20; private bool javaGenerateEqualsAndHash_; - public bool JavaGenerateEqualsAndHash { + internal bool JavaGenerateEqualsAndHash { get { return javaGenerateEqualsAndHash_; } set { pb::Freezable.CheckMutable(this); @@ -2650,7 +2651,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int JavaStringCheckUtf8FieldNumber = 27; private bool javaStringCheckUtf8_; - public bool JavaStringCheckUtf8 { + internal bool JavaStringCheckUtf8 { get { return javaStringCheckUtf8_; } set { pb::Freezable.CheckMutable(this); @@ -2660,7 +2661,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int OptimizeForFieldNumber = 9; private global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode optimizeFor_ = global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED; - public global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode OptimizeFor { + internal global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode OptimizeFor { get { return optimizeFor_; } set { pb::Freezable.CheckMutable(this); @@ -2670,7 +2671,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int GoPackageFieldNumber = 11; private string goPackage_ = ""; - public string GoPackage { + internal string GoPackage { get { return goPackage_; } set { pb::Freezable.CheckMutable(this); @@ -2680,7 +2681,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int CcGenericServicesFieldNumber = 16; private bool ccGenericServices_; - public bool CcGenericServices { + internal bool CcGenericServices { get { return ccGenericServices_; } set { pb::Freezable.CheckMutable(this); @@ -2690,7 +2691,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int JavaGenericServicesFieldNumber = 17; private bool javaGenericServices_; - public bool JavaGenericServices { + internal bool JavaGenericServices { get { return javaGenericServices_; } set { pb::Freezable.CheckMutable(this); @@ -2700,7 +2701,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int PyGenericServicesFieldNumber = 18; private bool pyGenericServices_; - public bool PyGenericServices { + internal bool PyGenericServices { get { return pyGenericServices_; } set { pb::Freezable.CheckMutable(this); @@ -2710,7 +2711,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int DeprecatedFieldNumber = 23; private bool deprecated_; - public bool Deprecated { + internal bool Deprecated { get { return deprecated_; } set { pb::Freezable.CheckMutable(this); @@ -2720,7 +2721,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int CcEnableArenasFieldNumber = 31; private bool ccEnableArenas_; - public bool CcEnableArenas { + internal bool CcEnableArenas { get { return ccEnableArenas_; } set { pb::Freezable.CheckMutable(this); @@ -2730,7 +2731,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int ObjcClassPrefixFieldNumber = 36; private string objcClassPrefix_ = ""; - public string ObjcClassPrefix { + internal string ObjcClassPrefix { get { return objcClassPrefix_; } set { pb::Freezable.CheckMutable(this); @@ -2740,7 +2741,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int CsharpNamespaceFieldNumber = 37; private string csharpNamespace_ = ""; - public string CsharpNamespace { + internal string CsharpNamespace { get { return csharpNamespace_; } set { pb::Freezable.CheckMutable(this); @@ -2752,7 +2753,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> _repeated_uninterpretedOption_codec = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); - public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { + internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { get { return uninterpretedOption_; } } @@ -3040,7 +3041,7 @@ namespace Google.Protobuf.DescriptorProtos { #region Nested types [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Types { - public enum OptimizeMode { + internal enum OptimizeMode { SPEED = 1, CODE_SIZE = 2, LITE_RUNTIME = 3, @@ -3052,26 +3053,30 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MessageOptions : pb::IMessage<MessageOptions> { + internal sealed partial class MessageOptions : pb::IMessage<MessageOptions> { private static readonly pb::MessageParser<MessageOptions> _parser = new pb::MessageParser<MessageOptions>(() => new MessageOptions()); public static pb::MessageParser<MessageOptions> Parser { get { return _parser; } } private static readonly string[] _fieldNames = new string[] { "deprecated", "map_entry", "message_set_wire_format", "no_standard_descriptor_accessor", "uninterpreted_option" }; private static readonly uint[] _fieldTags = new uint[] { 24, 56, 8, 16, 7994 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MessageOptions__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[10]; } } - public pb::FieldAccess.FieldAccessorTable<MessageOptions> Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MessageOptions__FieldAccessorTable; } } private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MessageOptions() { } + public MessageOptions() { + OnConstruction(); + } + + partial void OnConstruction(); - public MessageOptions(MessageOptions other) { + public MessageOptions(MessageOptions other) : this() { messageSetWireFormat_ = other.messageSetWireFormat_; noStandardDescriptorAccessor_ = other.noStandardDescriptorAccessor_; deprecated_ = other.deprecated_; @@ -3093,7 +3098,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int MessageSetWireFormatFieldNumber = 1; private bool messageSetWireFormat_; - public bool MessageSetWireFormat { + internal bool MessageSetWireFormat { get { return messageSetWireFormat_; } set { pb::Freezable.CheckMutable(this); @@ -3103,7 +3108,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int NoStandardDescriptorAccessorFieldNumber = 2; private bool noStandardDescriptorAccessor_; - public bool NoStandardDescriptorAccessor { + internal bool NoStandardDescriptorAccessor { get { return noStandardDescriptorAccessor_; } set { pb::Freezable.CheckMutable(this); @@ -3113,7 +3118,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int DeprecatedFieldNumber = 3; private bool deprecated_; - public bool Deprecated { + internal bool Deprecated { get { return deprecated_; } set { pb::Freezable.CheckMutable(this); @@ -3123,7 +3128,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int MapEntryFieldNumber = 7; private bool mapEntry_; - public bool MapEntry { + internal bool MapEntry { get { return mapEntry_; } set { pb::Freezable.CheckMutable(this); @@ -3135,7 +3140,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> _repeated_uninterpretedOption_codec = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); - public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { + internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { get { return uninterpretedOption_; } } @@ -3263,26 +3268,30 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FieldOptions : pb::IMessage<FieldOptions> { + internal sealed partial class FieldOptions : pb::IMessage<FieldOptions> { private static readonly pb::MessageParser<FieldOptions> _parser = new pb::MessageParser<FieldOptions>(() => new FieldOptions()); public static pb::MessageParser<FieldOptions> Parser { get { return _parser; } } private static readonly string[] _fieldNames = new string[] { "ctype", "deprecated", "jstype", "lazy", "packed", "uninterpreted_option", "weak" }; private static readonly uint[] _fieldTags = new uint[] { 8, 24, 48, 40, 16, 7994, 80 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FieldOptions__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[11]; } } - public pb::FieldAccess.FieldAccessorTable<FieldOptions> Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FieldOptions__FieldAccessorTable; } } private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public FieldOptions() { } + public FieldOptions() { + OnConstruction(); + } + + partial void OnConstruction(); - public FieldOptions(FieldOptions other) { + public FieldOptions(FieldOptions other) : this() { ctype_ = other.ctype_; packed_ = other.packed_; jstype_ = other.jstype_; @@ -3306,7 +3315,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int CtypeFieldNumber = 1; private global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType ctype_ = global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType.STRING; - public global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType Ctype { + internal global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType Ctype { get { return ctype_; } set { pb::Freezable.CheckMutable(this); @@ -3316,7 +3325,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int PackedFieldNumber = 2; private bool packed_; - public bool Packed { + internal bool Packed { get { return packed_; } set { pb::Freezable.CheckMutable(this); @@ -3326,7 +3335,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int JstypeFieldNumber = 6; private global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType jstype_ = global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType.JS_NORMAL; - public global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType Jstype { + internal global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType Jstype { get { return jstype_; } set { pb::Freezable.CheckMutable(this); @@ -3336,7 +3345,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int LazyFieldNumber = 5; private bool lazy_; - public bool Lazy { + internal bool Lazy { get { return lazy_; } set { pb::Freezable.CheckMutable(this); @@ -3346,7 +3355,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int DeprecatedFieldNumber = 3; private bool deprecated_; - public bool Deprecated { + internal bool Deprecated { get { return deprecated_; } set { pb::Freezable.CheckMutable(this); @@ -3356,7 +3365,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int WeakFieldNumber = 10; private bool weak_; - public bool Weak { + internal bool Weak { get { return weak_; } set { pb::Freezable.CheckMutable(this); @@ -3368,7 +3377,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> _repeated_uninterpretedOption_codec = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); - public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { + internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { get { return uninterpretedOption_; } } @@ -3528,13 +3537,13 @@ namespace Google.Protobuf.DescriptorProtos { #region Nested types [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Types { - public enum CType { + internal enum CType { STRING = 0, CORD = 1, STRING_PIECE = 2, } - public enum JSType { + internal enum JSType { JS_NORMAL = 0, JS_STRING = 1, JS_NUMBER = 2, @@ -3546,26 +3555,30 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class EnumOptions : pb::IMessage<EnumOptions> { + internal sealed partial class EnumOptions : pb::IMessage<EnumOptions> { private static readonly pb::MessageParser<EnumOptions> _parser = new pb::MessageParser<EnumOptions>(() => new EnumOptions()); public static pb::MessageParser<EnumOptions> Parser { get { return _parser; } } private static readonly string[] _fieldNames = new string[] { "allow_alias", "deprecated", "uninterpreted_option" }; private static readonly uint[] _fieldTags = new uint[] { 16, 24, 7994 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumOptions__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[12]; } } - public pb::FieldAccess.FieldAccessorTable<EnumOptions> Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumOptions__FieldAccessorTable; } } private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public EnumOptions() { } + public EnumOptions() { + OnConstruction(); + } + + partial void OnConstruction(); - public EnumOptions(EnumOptions other) { + public EnumOptions(EnumOptions other) : this() { allowAlias_ = other.allowAlias_; deprecated_ = other.deprecated_; uninterpretedOption_ = other.uninterpretedOption_.Clone(); @@ -3585,7 +3598,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int AllowAliasFieldNumber = 2; private bool allowAlias_; - public bool AllowAlias { + internal bool AllowAlias { get { return allowAlias_; } set { pb::Freezable.CheckMutable(this); @@ -3595,7 +3608,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int DeprecatedFieldNumber = 3; private bool deprecated_; - public bool Deprecated { + internal bool Deprecated { get { return deprecated_; } set { pb::Freezable.CheckMutable(this); @@ -3607,7 +3620,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> _repeated_uninterpretedOption_codec = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); - public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { + internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { get { return uninterpretedOption_; } } @@ -3703,26 +3716,30 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class EnumValueOptions : pb::IMessage<EnumValueOptions> { + internal sealed partial class EnumValueOptions : pb::IMessage<EnumValueOptions> { private static readonly pb::MessageParser<EnumValueOptions> _parser = new pb::MessageParser<EnumValueOptions>(() => new EnumValueOptions()); public static pb::MessageParser<EnumValueOptions> Parser { get { return _parser; } } private static readonly string[] _fieldNames = new string[] { "deprecated", "uninterpreted_option" }; private static readonly uint[] _fieldTags = new uint[] { 8, 7994 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumValueOptions__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[13]; } } - public pb::FieldAccess.FieldAccessorTable<EnumValueOptions> Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable; } } private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public EnumValueOptions() { } + public EnumValueOptions() { + OnConstruction(); + } - public EnumValueOptions(EnumValueOptions other) { + partial void OnConstruction(); + + public EnumValueOptions(EnumValueOptions other) : this() { deprecated_ = other.deprecated_; uninterpretedOption_ = other.uninterpretedOption_.Clone(); } @@ -3741,7 +3758,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int DeprecatedFieldNumber = 1; private bool deprecated_; - public bool Deprecated { + internal bool Deprecated { get { return deprecated_; } set { pb::Freezable.CheckMutable(this); @@ -3753,7 +3770,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> _repeated_uninterpretedOption_codec = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); - public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { + internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { get { return uninterpretedOption_; } } @@ -3833,26 +3850,30 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ServiceOptions : pb::IMessage<ServiceOptions> { + internal sealed partial class ServiceOptions : pb::IMessage<ServiceOptions> { private static readonly pb::MessageParser<ServiceOptions> _parser = new pb::MessageParser<ServiceOptions>(() => new ServiceOptions()); public static pb::MessageParser<ServiceOptions> Parser { get { return _parser; } } private static readonly string[] _fieldNames = new string[] { "deprecated", "uninterpreted_option" }; private static readonly uint[] _fieldTags = new uint[] { 264, 7994 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_ServiceOptions__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[14]; } } - public pb::FieldAccess.FieldAccessorTable<ServiceOptions> Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_ServiceOptions__FieldAccessorTable; } } private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public ServiceOptions() { } + public ServiceOptions() { + OnConstruction(); + } + + partial void OnConstruction(); - public ServiceOptions(ServiceOptions other) { + public ServiceOptions(ServiceOptions other) : this() { deprecated_ = other.deprecated_; uninterpretedOption_ = other.uninterpretedOption_.Clone(); } @@ -3871,7 +3892,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int DeprecatedFieldNumber = 33; private bool deprecated_; - public bool Deprecated { + internal bool Deprecated { get { return deprecated_; } set { pb::Freezable.CheckMutable(this); @@ -3883,7 +3904,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> _repeated_uninterpretedOption_codec = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); - public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { + internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { get { return uninterpretedOption_; } } @@ -3963,26 +3984,30 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MethodOptions : pb::IMessage<MethodOptions> { + internal sealed partial class MethodOptions : pb::IMessage<MethodOptions> { private static readonly pb::MessageParser<MethodOptions> _parser = new pb::MessageParser<MethodOptions>(() => new MethodOptions()); public static pb::MessageParser<MethodOptions> Parser { get { return _parser; } } private static readonly string[] _fieldNames = new string[] { "deprecated", "uninterpreted_option" }; private static readonly uint[] _fieldTags = new uint[] { 264, 7994 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MethodOptions__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[15]; } } - public pb::FieldAccess.FieldAccessorTable<MethodOptions> Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MethodOptions__FieldAccessorTable; } } private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MethodOptions() { } + public MethodOptions() { + OnConstruction(); + } + + partial void OnConstruction(); - public MethodOptions(MethodOptions other) { + public MethodOptions(MethodOptions other) : this() { deprecated_ = other.deprecated_; uninterpretedOption_ = other.uninterpretedOption_.Clone(); } @@ -4001,7 +4026,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int DeprecatedFieldNumber = 33; private bool deprecated_; - public bool Deprecated { + internal bool Deprecated { get { return deprecated_; } set { pb::Freezable.CheckMutable(this); @@ -4013,7 +4038,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> _repeated_uninterpretedOption_codec = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); - public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { + internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { get { return uninterpretedOption_; } } @@ -4093,26 +4118,30 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class UninterpretedOption : pb::IMessage<UninterpretedOption> { + internal sealed partial class UninterpretedOption : pb::IMessage<UninterpretedOption> { private static readonly pb::MessageParser<UninterpretedOption> _parser = new pb::MessageParser<UninterpretedOption>(() => new UninterpretedOption()); public static pb::MessageParser<UninterpretedOption> Parser { get { return _parser; } } private static readonly string[] _fieldNames = new string[] { "aggregate_value", "double_value", "identifier_value", "name", "negative_int_value", "positive_int_value", "string_value" }; private static readonly uint[] _fieldTags = new uint[] { 66, 49, 26, 18, 40, 32, 58 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[16]; } } - public pb::FieldAccess.FieldAccessorTable<UninterpretedOption> Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable; } } private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public UninterpretedOption() { } + public UninterpretedOption() { + OnConstruction(); + } + + partial void OnConstruction(); - public UninterpretedOption(UninterpretedOption other) { + public UninterpretedOption(UninterpretedOption other) : this() { name_ = other.name_.Clone(); identifierValue_ = other.identifierValue_; positiveIntValue_ = other.positiveIntValue_; @@ -4138,13 +4167,13 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart> _repeated_name_codec = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart.Parser); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart> name_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart>(); - public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart> Name { + internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart> Name { get { return name_; } } public const int IdentifierValueFieldNumber = 3; private string identifierValue_ = ""; - public string IdentifierValue { + internal string IdentifierValue { get { return identifierValue_; } set { pb::Freezable.CheckMutable(this); @@ -4154,7 +4183,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int PositiveIntValueFieldNumber = 4; private ulong positiveIntValue_; - public ulong PositiveIntValue { + internal ulong PositiveIntValue { get { return positiveIntValue_; } set { pb::Freezable.CheckMutable(this); @@ -4164,7 +4193,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int NegativeIntValueFieldNumber = 5; private long negativeIntValue_; - public long NegativeIntValue { + internal long NegativeIntValue { get { return negativeIntValue_; } set { pb::Freezable.CheckMutable(this); @@ -4174,7 +4203,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int DoubleValueFieldNumber = 6; private double doubleValue_; - public double DoubleValue { + internal double DoubleValue { get { return doubleValue_; } set { pb::Freezable.CheckMutable(this); @@ -4184,7 +4213,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int StringValueFieldNumber = 7; private pb::ByteString stringValue_ = pb::ByteString.Empty; - public pb::ByteString StringValue { + internal pb::ByteString StringValue { get { return stringValue_; } set { pb::Freezable.CheckMutable(this); @@ -4194,7 +4223,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int AggregateValueFieldNumber = 8; private string aggregateValue_ = ""; - public string AggregateValue { + internal string AggregateValue { get { return aggregateValue_; } set { pb::Freezable.CheckMutable(this); @@ -4359,26 +4388,30 @@ namespace Google.Protobuf.DescriptorProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Types { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NamePart : pb::IMessage<NamePart> { + internal sealed partial class NamePart : pb::IMessage<NamePart> { private static readonly pb::MessageParser<NamePart> _parser = new pb::MessageParser<NamePart>(() => new NamePart()); public static pb::MessageParser<NamePart> Parser { get { return _parser; } } private static readonly string[] _fieldNames = new string[] { "is_extension", "name_part" }; private static readonly uint[] _fieldTags = new uint[] { 16, 10 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption_NamePart__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Descriptor.NestedTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable<NamePart> Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable; } } private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public NamePart() { } + public NamePart() { + OnConstruction(); + } - public NamePart(NamePart other) { + partial void OnConstruction(); + + public NamePart(NamePart other) : this() { namePart_ = other.namePart_; isExtension_ = other.isExtension_; } @@ -4396,7 +4429,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int NamePart_FieldNumber = 1; private string namePart_ = ""; - public string NamePart_ { + internal string NamePart_ { get { return namePart_; } set { pb::Freezable.CheckMutable(this); @@ -4406,7 +4439,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int IsExtensionFieldNumber = 2; private bool isExtension_; - public bool IsExtension { + internal bool IsExtension { get { return isExtension_; } set { pb::Freezable.CheckMutable(this); @@ -4502,26 +4535,30 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class SourceCodeInfo : pb::IMessage<SourceCodeInfo> { + internal sealed partial class SourceCodeInfo : pb::IMessage<SourceCodeInfo> { private static readonly pb::MessageParser<SourceCodeInfo> _parser = new pb::MessageParser<SourceCodeInfo>(() => new SourceCodeInfo()); public static pb::MessageParser<SourceCodeInfo> Parser { get { return _parser; } } private static readonly string[] _fieldNames = new string[] { "location" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[17]; } } - public pb::FieldAccess.FieldAccessorTable<SourceCodeInfo> Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable; } } private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public SourceCodeInfo() { } + public SourceCodeInfo() { + OnConstruction(); + } + + partial void OnConstruction(); - public SourceCodeInfo(SourceCodeInfo other) { + public SourceCodeInfo(SourceCodeInfo other) : this() { location_ = other.location_.Clone(); } @@ -4541,7 +4578,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location> _repeated_location_codec = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location.Parser); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location> location_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location>(); - public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location> Location { + internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location> Location { get { return location_; } } @@ -4606,26 +4643,30 @@ namespace Google.Protobuf.DescriptorProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Types { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Location : pb::IMessage<Location> { + internal sealed partial class Location : pb::IMessage<Location> { private static readonly pb::MessageParser<Location> _parser = new pb::MessageParser<Location>(() => new Location()); public static pb::MessageParser<Location> Parser { get { return _parser; } } private static readonly string[] _fieldNames = new string[] { "leading_comments", "leading_detached_comments", "path", "span", "trailing_comments" }; private static readonly uint[] _fieldTags = new uint[] { 26, 50, 10, 18, 34 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo_Location__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Descriptor.NestedTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable<Location> Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable; } } private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public Location() { } + public Location() { + OnConstruction(); + } + + partial void OnConstruction(); - public Location(Location other) { + public Location(Location other) : this() { path_ = other.path_.Clone(); span_ = other.span_.Clone(); leadingComments_ = other.leadingComments_; @@ -4651,7 +4692,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<int> _repeated_path_codec = pb::FieldCodec.ForInt32(10); private readonly pbc::RepeatedField<int> path_ = new pbc::RepeatedField<int>(); - public pbc::RepeatedField<int> Path { + internal pbc::RepeatedField<int> Path { get { return path_; } } @@ -4659,13 +4700,13 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<int> _repeated_span_codec = pb::FieldCodec.ForInt32(18); private readonly pbc::RepeatedField<int> span_ = new pbc::RepeatedField<int>(); - public pbc::RepeatedField<int> Span { + internal pbc::RepeatedField<int> Span { get { return span_; } } public const int LeadingCommentsFieldNumber = 3; private string leadingComments_ = ""; - public string LeadingComments { + internal string LeadingComments { get { return leadingComments_; } set { pb::Freezable.CheckMutable(this); @@ -4675,7 +4716,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int TrailingCommentsFieldNumber = 4; private string trailingComments_ = ""; - public string TrailingComments { + internal string TrailingComments { get { return trailingComments_; } set { pb::Freezable.CheckMutable(this); @@ -4687,7 +4728,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec<string> _repeated_leadingDetachedComments_codec = pb::FieldCodec.ForString(50); private readonly pbc::RepeatedField<string> leadingDetachedComments_ = new pbc::RepeatedField<string>(); - public pbc::RepeatedField<string> LeadingDetachedComments { + internal pbc::RepeatedField<string> LeadingDetachedComments { get { return leadingDetachedComments_; } } diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/PartialClasses.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/PartialClasses.cs index 15f339ba..dc19cdad 100644 --- a/csharp/src/ProtocolBuffers/DescriptorProtos/PartialClasses.cs +++ b/csharp/src/ProtocolBuffers/DescriptorProtos/PartialClasses.cs @@ -30,36 +30,18 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion
-// This file just contains partial classes for each of the
-// autogenerated classes, so that they implement
-// IDescriptorProto
+// This file just contains partial classes for any autogenerated classes that need additional support.
namespace Google.Protobuf.DescriptorProtos
{
- public partial class DescriptorProto : IDescriptorProto<MessageOptions>
- {
- }
-
- public partial class EnumDescriptorProto : IDescriptorProto<EnumOptions>
- {
- }
-
- public partial class EnumValueDescriptorProto : IDescriptorProto<EnumValueOptions>
- {
- }
-
- public partial class FieldDescriptorProto : IDescriptorProto<FieldOptions>
- {
- }
-
- public partial class FileDescriptorProto : IDescriptorProto<FileOptions>
- {
- }
-
- public partial class MethodDescriptorProto : IDescriptorProto<MethodOptions>
- {
- }
-
- public partial class ServiceDescriptorProto : IDescriptorProto<ServiceOptions>
+ internal partial class FieldDescriptorProto
{
+ // We can't tell the difference between "explicitly set to 0" and "not set"
+ // in proto3, but we need to tell the difference for OneofIndex. descriptor.proto
+ // is really a proto2 file, but the runtime doesn't know about proto2 semantics...
+ // We fake it by defaulting to -1.
+ partial void OnConstruction()
+ {
+ OneofIndex = -1;
+ }
}
}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Descriptors/DescriptorBase.cs b/csharp/src/ProtocolBuffers/Descriptors/DescriptorBase.cs index ccde34ab..0eb71215 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/DescriptorBase.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/DescriptorBase.cs @@ -34,61 +34,36 @@ using Google.Protobuf.DescriptorProtos; namespace Google.Protobuf.Descriptors
{
- // TODO(jonskeet): The descriptor type hierarchy needs changing so that we can hide the descriptor protos.
/// <summary>
/// Base class for nearly all descriptors, providing common functionality.
/// </summary>
- /// <typeparam name="TProto">Type of the protocol buffer form of this descriptor</typeparam>
- /// <typeparam name="TOptions">Type of the options protocol buffer for this descriptor</typeparam>
- public abstract class DescriptorBase<TProto, TOptions> : IDescriptor<TProto>
- where TProto : IMessage, IDescriptorProto<TOptions>
+ public abstract class DescriptorBase : IDescriptor
{
- private TProto proto;
private readonly FileDescriptor file;
private readonly string fullName;
+ private readonly int index;
- protected DescriptorBase(TProto proto, FileDescriptor file, string fullName)
+ internal DescriptorBase(FileDescriptor file, string fullName, int index)
{
- this.proto = proto;
this.file = file;
this.fullName = fullName;
+ this.index = index;
}
- internal virtual void ReplaceProto(TProto newProto)
- {
- this.proto = newProto;
- }
-
- protected static string ComputeFullName(FileDescriptor file, MessageDescriptor parent, string name)
- {
- if (parent != null)
- {
- return parent.FullName + "." + name;
- }
- if (file.Package.Length > 0)
- {
- return file.Package + "." + name;
- }
- return name;
- }
-
- IMessage IDescriptor.Proto
- {
- get { return proto; }
- }
-
- /// <summary>
- /// Returns the protocol buffer form of this descriptor.
- /// </summary>
- public TProto Proto
+ /// <value>
+ /// The index of this descriptor within its parent descriptor.
+ /// </value>
+ /// <remarks>
+ /// This returns the index of this descriptor within its parent, for
+ /// this descriptor's type. (There can be duplicate values for different
+ /// types, e.g. one enum type with index 0 and one message type with index 0.)
+ /// </remarks>
+ public int Index
{
- get { return proto; }
+ get { return index; }
}
- public TOptions Options
- {
- get { return proto.Options; }
- }
+ public abstract string Name { get; }
/// <summary>
/// The fully qualified name of the descriptor's target.
@@ -98,14 +73,6 @@ namespace Google.Protobuf.Descriptors get { return fullName; }
}
- /// <summary>
- /// The brief name of the descriptor's target.
- /// </summary>
- public string Name
- {
- get { return proto.Name; }
- }
-
/// <value>
/// The file this descriptor was declared in.
/// </value>
diff --git a/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs b/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs index 57c4ba03..b07af060 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs @@ -257,7 +257,7 @@ namespace Google.Protobuf.Descriptors /// or unqualified. C++-like name lookup semantics are used to search for the
/// matching descriptor.
/// </summary>
- public IDescriptor LookupSymbol(string name, IDescriptor relativeTo)
+ internal IDescriptor LookupSymbol(string name, IDescriptor relativeTo)
{
// TODO(jonskeet): This could be optimized in a number of ways.
diff --git a/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs index 9f10990b..a6db5268 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs @@ -38,14 +38,16 @@ namespace Google.Protobuf.Descriptors /// <summary>
/// Descriptor for an enum type in a .proto file.
/// </summary>
- public sealed class EnumDescriptor : IndexedDescriptorBase<EnumDescriptorProto, EnumOptions>
+ public sealed class EnumDescriptor : DescriptorBase
{
+ private readonly EnumDescriptorProto proto;
private readonly MessageDescriptor containingType;
private readonly IList<EnumValueDescriptor> values;
internal EnumDescriptor(EnumDescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int index)
- : base(proto, file, ComputeFullName(file, parent, proto.Name), index)
+ : base(file, file.ComputeFullName(parent, proto.Name), index)
{
+ this.proto = proto;
containingType = parent;
if (proto.Value.Count == 0)
@@ -61,6 +63,13 @@ namespace Google.Protobuf.Descriptors File.DescriptorPool.AddSymbol(this);
}
+ internal EnumDescriptorProto Proto { get { return proto; } }
+
+ /// <summary>
+ /// The brief name of the descriptor's target.
+ /// </summary>
+ public override string Name { get { return proto.Name; } }
+
/// <value>
/// If this is a nested type, get the outer descriptor, otherwise null.
/// </value>
@@ -95,14 +104,5 @@ namespace Google.Protobuf.Descriptors {
return File.DescriptorPool.FindSymbol<EnumValueDescriptor>(FullName + "." + name);
}
-
- internal override void ReplaceProto(EnumDescriptorProto newProto)
- {
- base.ReplaceProto(newProto);
- for (int i = 0; i < values.Count; i++)
- {
- values[i].ReplaceProto(newProto.Value[i]);
- }
- }
}
}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs index b553ee55..e609b1f8 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs @@ -37,27 +37,27 @@ namespace Google.Protobuf.Descriptors /// <summary>
/// Descriptor for a single enum value within an enum in a .proto file.
/// </summary>
- public sealed class EnumValueDescriptor : IndexedDescriptorBase<EnumValueDescriptorProto, EnumValueOptions>
+ public sealed class EnumValueDescriptor : DescriptorBase
{
private readonly EnumDescriptor enumDescriptor;
+ private readonly EnumValueDescriptorProto proto;
internal EnumValueDescriptor(EnumValueDescriptorProto proto, FileDescriptor file,
EnumDescriptor parent, int index)
- : base(proto, file, parent.FullName + "." + proto.Name, index)
+ : base(file, parent.FullName + "." + proto.Name, index)
{
+ this.proto = proto;
enumDescriptor = parent;
file.DescriptorPool.AddSymbol(this);
file.DescriptorPool.AddEnumValueByNumber(this);
}
- public int Number
- {
- get { return Proto.Number; }
- }
+ internal EnumValueDescriptorProto Proto { get { return proto; } }
+
+ public override string Name { get { return proto.Name; } }
- public EnumDescriptor EnumDescriptor
- {
- get { return enumDescriptor; }
- }
+ public int Number { get { return Proto.Number; } }
+
+ public EnumDescriptor EnumDescriptor { get { return enumDescriptor; } }
}
}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs index 2f2c5806..7af69bbb 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs @@ -38,21 +38,20 @@ namespace Google.Protobuf.Descriptors /// <summary>
/// Descriptor for a field or extension within a message in a .proto file.
/// </summary>
- public sealed class FieldDescriptor : IndexedDescriptorBase<FieldDescriptorProto, FieldOptions>,
- IComparable<FieldDescriptor>
+ public sealed class FieldDescriptor : DescriptorBase, IComparable<FieldDescriptor>
{
+ private readonly FieldDescriptorProto proto;
private EnumDescriptor enumType;
private MessageDescriptor messageType;
- private MessageDescriptor containingType;
- private OneofDescriptor containingOneof;
+ private readonly MessageDescriptor containingType;
+ private readonly OneofDescriptor containingOneof;
private FieldType fieldType;
- private readonly object optionsLock = new object();
-
internal FieldDescriptor(FieldDescriptorProto proto, FileDescriptor file,
MessageDescriptor parent, int index)
- : base(proto, file, ComputeFullName(file, parent, proto.Name), index)
+ : base(file, file.ComputeFullName(parent, proto.Name), index)
{
+ this.proto = proto;
if (proto.Type != 0)
{
fieldType = GetFieldTypeFromProtoType(proto.Type);
@@ -64,7 +63,8 @@ namespace Google.Protobuf.Descriptors "Field numbers must be positive integers.");
}
containingType = parent;
- if (proto.OneofIndex != 0)
+ // OneofIndex "defaults" to -1 due to a hack in FieldDescriptor.OnConstruction.
+ if (proto.OneofIndex != -1)
{
if (proto.OneofIndex < 0 || proto.OneofIndex >= parent.Proto.OneofDecl.Count)
{
@@ -72,13 +72,19 @@ namespace Google.Protobuf.Descriptors "FieldDescriptorProto.oneof_index is out of range for type " + parent.Name);
}
containingOneof = parent.Oneofs[proto.OneofIndex];
- containingOneof.fieldCount ++;
}
file.DescriptorPool.AddSymbol(this);
}
/// <summary>
+ /// The brief name of the descriptor's target.
+ /// </summary>
+ public override string Name { get { return proto.Name; } }
+
+ internal FieldDescriptorProto Proto { get { return proto; } }
+
+ /// <summary>
/// Maps a field type as included in the .proto file to a FieldType.
/// </summary>
private static FieldType GetFieldTypeFromProtoType(FieldDescriptorProto.Types.Type type)
@@ -131,9 +137,14 @@ namespace Google.Protobuf.Descriptors get { return Proto.Label == FieldDescriptorProto.Types.Label.LABEL_REPEATED; }
}
+ public bool IsMap
+ {
+ get { return fieldType == FieldType.Message && messageType.Proto.Options != null && messageType.Proto.Options.MapEntry; }
+ }
+
public bool IsPacked
{
- get { return Proto.Options.Packed; }
+ get { return Proto.Options != null && Proto.Options.Packed; }
}
/// <summary>
@@ -273,7 +284,7 @@ namespace Google.Protobuf.Descriptors File.DescriptorPool.AddFieldByNumber(this);
- if (containingType != null && containingType.Options != null && containingType.Options.MessageSetWireFormat)
+ if (containingType != null && containingType.Proto.Options != null && containingType.Proto.Options.MessageSetWireFormat)
{
throw new DescriptorValidationException(this, "MessageSet format is not supported.");
}
diff --git a/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs index 7da14a54..9d0bdfd3 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs @@ -43,7 +43,7 @@ namespace Google.Protobuf.Descriptors /// IDescriptor is implemented such that the File property returns this descriptor,
/// and the FullName is the same as the Name.
/// </summary>
- public sealed class FileDescriptor : IDescriptor<FileDescriptorProto>
+ public sealed class FileDescriptor : IDescriptor
{
private readonly FileDescriptorProto proto;
private readonly IList<MessageDescriptor> messageTypes;
@@ -88,6 +88,22 @@ namespace Google.Protobuf.Descriptors }
/// <summary>
+ /// Computes the full name of a descriptor within this file, with an optional parent message.
+ /// </summary>
+ internal string ComputeFullName(MessageDescriptor parent, string name)
+ {
+ if (parent != null)
+ {
+ return parent.FullName + "." + name;
+ }
+ if (Package.Length > 0)
+ {
+ return Package + "." + name;
+ }
+ return name;
+ }
+
+ /// <summary>
/// Extracts public dependencies from direct dependencies. This is a static method despite its
/// first parameter, as the value we're in the middle of constructing is only used for exceptions.
/// </summary>
@@ -127,20 +143,12 @@ namespace Google.Protobuf.Descriptors /// <value>
/// The descriptor in its protocol message representation.
/// </value>
- public FileDescriptorProto Proto
+ internal FileDescriptorProto Proto
{
get { return proto; }
}
/// <value>
- /// The <see cref="DescriptorProtos.FileOptions" /> defined in <c>descriptor.proto</c>.
- /// </value>
- public FileOptions Options
- {
- get { return proto.Options; }
- }
-
- /// <value>
/// The file name.
/// </value>
public string Name
@@ -214,14 +222,6 @@ namespace Google.Protobuf.Descriptors }
/// <value>
- /// Protocol buffer describing this descriptor.
- /// </value>
- IMessage IDescriptor.Proto
- {
- get { return Proto; }
- }
-
- /// <value>
/// Pool containing symbol descriptors.
/// </value>
internal DescriptorPool DescriptorPool
@@ -255,22 +255,7 @@ namespace Google.Protobuf.Descriptors }
return null;
}
-
- /// <summary>
- /// Builds a FileDescriptor from its protocol buffer representation.
- /// </summary>
- /// <param name="proto">The protocol message form of the FileDescriptor.</param>
- /// <param name="dependencies">FileDescriptors corresponding to all of the
- /// file's dependencies, in the exact order listed in the .proto file. May be null,
- /// in which case it is treated as an empty array.</param>
- /// <exception cref="DescriptorValidationException">If <paramref name="proto"/> is not
- /// a valid descriptor. This can occur for a number of reasons, such as a field
- /// having an undefined type or because two messages were defined with the same name.</exception>
- public static FileDescriptor BuildFrom(FileDescriptorProto proto, FileDescriptor[] dependencies)
- {
- return BuildFrom(proto, dependencies, false);
- }
-
+
/// <summary>
/// Builds a FileDescriptor from its protocol buffer representation.
/// </summary>
@@ -336,33 +321,8 @@ namespace Google.Protobuf.Descriptors }
}
- /// <summary>
- /// This method is to be called by generated code only. It is equivalent
- /// to BuildFrom except that the FileDescriptorProto is encoded in
- /// protocol buffer wire format. This overload is maintained for backward
- /// compatibility with source code generated before the custom options were available
- /// (and working).
- /// </summary>
- public static FileDescriptor InternalBuildGeneratedFileFrom(byte[] descriptorData, FileDescriptor[] dependencies)
- {
- return InternalBuildGeneratedFileFrom(descriptorData, dependencies, x => { });
- }
-
- /// <summary>
- /// This delegate should be used by generated code only. When calling
- /// FileDescriptor.InternalBuildGeneratedFileFrom, the caller can provide
- /// a callback which assigns the global variables defined in the generated code
- /// which point at parts of the FileDescriptor. The callback returns an
- /// Extension Registry which contains any extensions which might be used in
- /// the descriptor - that is, extensions of the various "Options" messages defined
- /// in descriptor.proto. The callback may also return null to indicate that
- /// no extensions are used in the descriptor.
- /// </summary>
- public delegate void InternalDescriptorAssigner(FileDescriptor descriptor);
-
public static FileDescriptor InternalBuildGeneratedFileFrom(byte[] descriptorData,
- FileDescriptor[] dependencies,
- InternalDescriptorAssigner descriptorAssigner)
+ FileDescriptor[] dependencies)
{
FileDescriptorProto proto;
try
@@ -374,20 +334,16 @@ namespace Google.Protobuf.Descriptors throw new ArgumentException("Failed to parse protocol buffer descriptor for generated code.", e);
}
- FileDescriptor result;
try
{
// When building descriptors for generated code, we allow unknown
// dependencies by default.
- result = BuildFrom(proto, dependencies, true);
+ return BuildFrom(proto, dependencies, true);
}
catch (DescriptorValidationException e)
{
throw new ArgumentException("Invalid embedded descriptor for \"" + proto.Name + "\".", e);
}
-
- descriptorAssigner(result);
- return result;
}
public override string ToString()
diff --git a/csharp/src/ProtocolBuffers/Descriptors/IDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/IDescriptor.cs index 2c2db127..92c6d463 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/IDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/IDescriptor.cs @@ -33,23 +33,12 @@ namespace Google.Protobuf.Descriptors
{
/// <summary>
- /// The non-generic form of the IDescriptor interface. Useful for describing a general
- /// descriptor.
+ /// Interface implemented by all descriptor types.
/// </summary>
public interface IDescriptor
{
string Name { get; }
string FullName { get; }
FileDescriptor File { get; }
- IMessage Proto { get; }
- }
-
- /// <summary>
- /// Strongly-typed form of the IDescriptor interface.
- /// </summary>
- /// <typeparam name="TProto">Protocol buffer type underlying this descriptor type</typeparam>
- internal interface IDescriptor<TProto> : IDescriptor where TProto : IMessage
- {
- new TProto Proto { get; }
- }
+ }
}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Descriptors/IndexedDescriptorBase.cs b/csharp/src/ProtocolBuffers/Descriptors/IndexedDescriptorBase.cs deleted file mode 100644 index 6c515726..00000000 --- a/csharp/src/ProtocolBuffers/Descriptors/IndexedDescriptorBase.cs +++ /dev/null @@ -1,65 +0,0 @@ -#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using Google.Protobuf.DescriptorProtos;
-
-namespace Google.Protobuf.Descriptors
-{
- /// <summary>
- /// Base class for descriptors which are also indexed. This is all of them other than
- /// <see cref="FileDescriptor" />.
- /// </summary>
- public abstract class IndexedDescriptorBase<TProto, TOptions> : DescriptorBase<TProto, TOptions>
- where TProto : IMessage<TProto>, IDescriptorProto<TOptions>
- {
- private readonly int index;
-
- protected IndexedDescriptorBase(TProto proto, FileDescriptor file, string fullName, int index)
- : base(proto, file, fullName)
- {
- this.index = index;
- }
-
- /// <value>
- /// The index of this descriptor within its parent descriptor.
- /// </value>
- /// <remarks>
- /// This returns the index of this descriptor within its parent, for
- /// this descriptor's type. (There can be duplicate values for different
- /// types, e.g. one enum type with index 0 and one message type with index 0.)
- /// </remarks>
- public int Index
- {
- get { return index; }
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs index cbf4c0f2..e65e8bb0 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs @@ -39,8 +39,9 @@ namespace Google.Protobuf.Descriptors /// <summary>
/// Describes a message type.
/// </summary>
- public sealed class MessageDescriptor : IndexedDescriptorBase<DescriptorProto, MessageOptions>
+ public sealed class MessageDescriptor : DescriptorBase
{
+ private readonly DescriptorProto proto;
private readonly MessageDescriptor containingType;
private readonly IList<MessageDescriptor> nestedTypes;
private readonly IList<EnumDescriptor> enumTypes;
@@ -48,8 +49,9 @@ namespace Google.Protobuf.Descriptors private readonly IList<OneofDescriptor> oneofs;
internal MessageDescriptor(DescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int typeIndex)
- : base(proto, file, ComputeFullName(file, parent, proto.Name), typeIndex)
+ : base(file, file.ComputeFullName(parent, proto.Name), typeIndex)
{
+ this.proto = proto;
containingType = parent;
oneofs = DescriptorUtil.ConvertAndMakeReadOnly(proto.OneofDecl,
@@ -68,23 +70,16 @@ namespace Google.Protobuf.Descriptors fields = DescriptorUtil.ConvertAndMakeReadOnly(proto.Field,
(field, index) =>
new FieldDescriptor(field, file, this, index));
-
- for (int i = 0; i < proto.OneofDecl.Count; i++)
- {
- oneofs[i].fields = new FieldDescriptor[oneofs[i].FieldCount];
- oneofs[i].fieldCount = 0;
- }
- for (int i = 0; i< proto.Field.Count; i++)
- {
- OneofDescriptor oneofDescriptor = fields[i].ContainingOneof;
- if (oneofDescriptor != null)
- {
- oneofDescriptor.fields[oneofDescriptor.fieldCount++] = fields[i];
- }
- }
file.DescriptorPool.AddSymbol(this);
}
+ /// <summary>
+ /// The brief name of the descriptor's target.
+ /// </summary>
+ public override string Name { get { return proto.Name; } }
+
+ internal DescriptorProto Proto { get { return proto; } }
+
/// <value>
/// If this is a nested type, get the outer descriptor, otherwise null.
/// </value>
@@ -144,7 +139,7 @@ namespace Google.Protobuf.Descriptors /// <summary>
/// Finds a nested descriptor by name. The is valid for fields, nested
- /// message types and enums.
+ /// message types, oneofs and enums.
/// </summary>
/// <param name="name">The unqualified name of the descriptor, e.g. "Foo"</param>
/// <returns>The descriptor, or null if not found.</returns>
@@ -171,32 +166,8 @@ namespace Google.Protobuf.Descriptors foreach (OneofDescriptor oneof in oneofs)
{
- // TODO(jonskeet): Do we need to do this?
- // oneof.C
- }
- }
-
- /// <summary>
- /// See FileDescriptor.ReplaceProto
- /// </summary>
- internal override void ReplaceProto(DescriptorProto newProto)
- {
- base.ReplaceProto(newProto);
-
- for (int i = 0; i < nestedTypes.Count; i++)
- {
- nestedTypes[i].ReplaceProto(newProto.NestedType[i]);
- }
-
- for (int i = 0; i < enumTypes.Count; i++)
- {
- enumTypes[i].ReplaceProto(newProto.EnumType[i]);
- }
-
- for (int i = 0; i < fields.Count; i++)
- {
- fields[i].ReplaceProto(newProto.Field[i]);
+ oneof.CrossLink();
}
- }
+ }
}
}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Descriptors/MethodDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/MethodDescriptor.cs index 6a4ad4ea..7d4a6f4f 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/MethodDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/MethodDescriptor.cs @@ -37,8 +37,9 @@ namespace Google.Protobuf.Descriptors /// <summary>
/// Describes a single method in a service.
/// </summary>
- public sealed class MethodDescriptor : IndexedDescriptorBase<MethodDescriptorProto, MethodOptions>
+ public sealed class MethodDescriptor : DescriptorBase
{
+ private readonly MethodDescriptorProto proto;
private readonly ServiceDescriptor service;
private MessageDescriptor inputType;
private MessageDescriptor outputType;
@@ -46,35 +47,34 @@ namespace Google.Protobuf.Descriptors /// <value>
/// The service this method belongs to.
/// </value>
- public ServiceDescriptor Service
- {
- get { return service; }
- }
+ public ServiceDescriptor Service { get { return service; } }
/// <value>
/// The method's input type.
/// </value>
- public MessageDescriptor InputType
- {
- get { return inputType; }
- }
+ public MessageDescriptor InputType { get { return inputType; } }
/// <value>
/// The method's input type.
/// </value>
- public MessageDescriptor OutputType
- {
- get { return outputType; }
- }
+ public MessageDescriptor OutputType { get { return outputType; } }
internal MethodDescriptor(MethodDescriptorProto proto, FileDescriptor file,
ServiceDescriptor parent, int index)
- : base(proto, file, parent.FullName + "." + proto.Name, index)
+ : base(file, parent.FullName + "." + proto.Name, index)
{
+ this.proto = proto;
service = parent;
file.DescriptorPool.AddSymbol(this);
}
+ internal MethodDescriptorProto Proto { get { return proto; } }
+
+ /// <summary>
+ /// The brief name of the descriptor's target.
+ /// </summary>
+ public override string Name { get { return proto.Name; } }
+
internal void CrossLink()
{
IDescriptor lookup = File.DescriptorPool.LookupSymbol(Proto.InputType, this);
diff --git a/csharp/src/ProtocolBuffers/Descriptors/OneofDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/OneofDescriptor.cs index ab3b76ec..8418948f 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/OneofDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/OneofDescriptor.cs @@ -31,48 +31,49 @@ #endregion
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using Google.Protobuf.DescriptorProtos;
namespace Google.Protobuf.Descriptors
{
- public sealed class OneofDescriptor
+ public sealed class OneofDescriptor : DescriptorBase
{
- private int index;
- private OneofDescriptorProto proto;
- private FileDescriptor file;
+ private readonly OneofDescriptorProto proto;
private MessageDescriptor containingType;
- internal int fieldCount;
- internal IList<FieldDescriptor> fields;
+ private IList<FieldDescriptor> fields;
- internal OneofDescriptor(OneofDescriptorProto proto, FileDescriptor file,
- MessageDescriptor parent, int index)
+ internal OneofDescriptor(OneofDescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int index)
+ : base(file, file.ComputeFullName(parent, proto.Name), index)
{
this.proto = proto;
- this.file = file;
- this.index = index;
-
containingType = parent;
- fieldCount = 0;
- }
- public int Index
- {
- get { return index; }
+ file.DescriptorPool.AddSymbol(this);
}
+ /// <summary>
+ /// The brief name of the descriptor's target.
+ /// </summary>
+ public override string Name { get { return proto.Name; } }
+
public MessageDescriptor ContainingType
{
get { return containingType; }
}
- public int FieldCount
- {
- get { return fieldCount; }
- }
+ public IList<FieldDescriptor> Fields { get { return fields; } }
- public FieldDescriptor Field(int index)
+ internal void CrossLink()
{
- return fields[index];
+ List<FieldDescriptor> fieldCollection = new List<FieldDescriptor>();
+ foreach (var field in ContainingType.Fields)
+ {
+ if (field.ContainingOneof == this)
+ {
+ fieldCollection.Add(field);
+ }
+ }
+ fields = new ReadOnlyCollection<FieldDescriptor>(fieldCollection);
}
}
}
diff --git a/csharp/src/ProtocolBuffers/Descriptors/PackageDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/PackageDescriptor.cs index 9af677d7..18adc9e3 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/PackageDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/PackageDescriptor.cs @@ -37,7 +37,7 @@ namespace Google.Protobuf.Descriptors /// just as placeholders so that someone cannot define, say, a message type
/// that has the same name as an existing package.
/// </summary>
- internal sealed class PackageDescriptor : IDescriptor<IMessage>
+ internal sealed class PackageDescriptor : IDescriptor
{
private readonly string name;
private readonly string fullName;
@@ -50,11 +50,6 @@ namespace Google.Protobuf.Descriptors this.name = name;
}
- public IMessage Proto
- {
- get { return file.Proto; }
- }
-
public string Name
{
get { return name; }
diff --git a/csharp/src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs index ef712b46..2556e272 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs @@ -39,19 +39,28 @@ namespace Google.Protobuf.Descriptors /// <summary>
/// Describes a service type.
/// </summary>
- public sealed class ServiceDescriptor : IndexedDescriptorBase<ServiceDescriptorProto, ServiceOptions>
+ public sealed class ServiceDescriptor : DescriptorBase
{
+ private readonly ServiceDescriptorProto proto;
private readonly IList<MethodDescriptor> methods;
- public ServiceDescriptor(ServiceDescriptorProto proto, FileDescriptor file, int index)
- : base(proto, file, ComputeFullName(file, null, proto.Name), index)
+ internal ServiceDescriptor(ServiceDescriptorProto proto, FileDescriptor file, int index)
+ : base(file, file.ComputeFullName(null, proto.Name), index)
{
+ this.proto = proto;
methods = DescriptorUtil.ConvertAndMakeReadOnly(proto.Method,
(method, i) => new MethodDescriptor(method, file, this, i));
file.DescriptorPool.AddSymbol(this);
}
+ /// <summary>
+ /// The brief name of the descriptor's target.
+ /// </summary>
+ public override string Name { get { return proto.Name; } }
+
+ internal ServiceDescriptorProto Proto { get { return proto; } }
+
/// <value>
/// An unmodifiable list of methods in this service.
/// </value>
@@ -77,14 +86,5 @@ namespace Google.Protobuf.Descriptors method.CrossLink();
}
}
-
- internal override void ReplaceProto(ServiceDescriptorProto newProto)
- {
- base.ReplaceProto(newProto);
- for (int i = 0; i < methods.Count; i++)
- {
- methods[i].ReplaceProto(newProto.Method[i]);
- }
- }
}
}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorBase.cs b/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorBase.cs index 73d777b2..2a3e5b8b 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorBase.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorBase.cs @@ -32,34 +32,37 @@ using System; using System.Reflection; +using Google.Protobuf.Descriptors; namespace Google.Protobuf.FieldAccess { /// <summary> /// Base class for field accessors. /// </summary> - /// <typeparam name="T">Type of message containing the field</typeparam> - internal abstract class FieldAccessorBase<T> : IFieldAccessor<T> where T : IMessage<T> + internal abstract class FieldAccessorBase : IFieldAccessor { - private readonly Func<T, object> getValueDelegate; + private readonly Func<object, object> getValueDelegate; + private readonly FieldDescriptor descriptor; - internal FieldAccessorBase(string name) + internal FieldAccessorBase(Type type, string propertyName, FieldDescriptor descriptor) { - PropertyInfo property = typeof(T).GetProperty(name); + PropertyInfo property = type.GetProperty(propertyName); if (property == null || !property.CanRead) { throw new ArgumentException("Not all required properties/methods available"); } - getValueDelegate = ReflectionUtil.CreateUpcastDelegate<T>(property.GetGetMethod()); + this.descriptor = descriptor; + getValueDelegate = ReflectionUtil.CreateFuncObjectObject(property.GetGetMethod()); } - public object GetValue(T message) + public FieldDescriptor Descriptor { get { return descriptor; } } + + public object GetValue(object message) { return getValueDelegate(message); } - public abstract bool HasValue(T message); - public abstract void Clear(T message); - public abstract void SetValue(T message, object value); + public abstract void Clear(object message); + public abstract void SetValue(object message, object value); } } diff --git a/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs b/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs index 6379ff25..57ea9c87 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs @@ -31,6 +31,7 @@ #endregion
using System;
+using System.Collections.ObjectModel;
using Google.Protobuf.Descriptors;
namespace Google.Protobuf.FieldAccess
@@ -38,34 +39,43 @@ namespace Google.Protobuf.FieldAccess /// <summary>
/// Provides access to fields in generated messages via reflection.
/// </summary>
- public sealed class FieldAccessorTable<T> where T : IMessage<T>
+ public sealed class FieldAccessorTable
{
- private readonly IFieldAccessor<T>[] accessors;
+ private readonly ReadOnlyCollection<IFieldAccessor> accessors;
private readonly MessageDescriptor descriptor;
/// <summary>
/// Constructs a FieldAccessorTable for a particular message class.
/// Only one FieldAccessorTable should be constructed per class.
/// </summary>
+ /// <param name="type">The CLR type for the message.</param>
/// <param name="descriptor">The type's descriptor</param>
/// <param name="propertyNames">The Pascal-case names of all the field-based properties in the message.</param>
- public FieldAccessorTable(MessageDescriptor descriptor, string[] propertyNames)
+ public FieldAccessorTable(Type type, MessageDescriptor descriptor, string[] propertyNames)
{
this.descriptor = descriptor;
- accessors = new IFieldAccessor<T>[descriptor.Fields.Count];
- bool supportFieldPresence = descriptor.File.Syntax == FileDescriptor.ProtoSyntax.Proto2;
- for (int i = 0; i < accessors.Length; i++)
+ var accessorsArray = new IFieldAccessor[descriptor.Fields.Count];
+ for (int i = 0; i < accessorsArray.Length; i++)
{
var field = descriptor.Fields[i];
var name = propertyNames[i];
- accessors[i] = field.IsRepeated
- ? (IFieldAccessor<T>) new RepeatedFieldAccessor<T>(propertyNames[i])
- : new SingleFieldAccessor<T>(field, name, supportFieldPresence);
+ accessorsArray[i] =
+ field.IsMap ? new MapFieldAccessor(type, name, field)
+ : field.IsRepeated ? new RepeatedFieldAccessor(type, name, field)
+ : (IFieldAccessor) new SingleFieldAccessor(type, name, field);
}
+ accessors = new ReadOnlyCollection<IFieldAccessor>(accessorsArray);
// TODO(jonskeet): Oneof support
}
- internal IFieldAccessor<T> this[int fieldNumber]
+ // TODO: Validate the name here... should possibly make this type a more "general reflection access" type,
+ // bearing in mind the oneof parts to come as well.
+ /// <summary>
+ /// Returns all of the field accessors for the message type.
+ /// </summary>
+ public ReadOnlyCollection<IFieldAccessor> Accessors { get { return accessors; } }
+
+ public IFieldAccessor this[int fieldNumber]
{
get
{
@@ -74,7 +84,7 @@ namespace Google.Protobuf.FieldAccess }
}
- internal IFieldAccessor<T> this[FieldDescriptor field]
+ internal IFieldAccessor this[FieldDescriptor field]
{
get
{
diff --git a/csharp/src/ProtocolBuffers/FieldAccess/IFieldAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/IFieldAccessor.cs index 61838543..77e7146d 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/IFieldAccessor.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/IFieldAccessor.cs @@ -30,39 +30,41 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion
+using Google.Protobuf.Descriptors;
+
namespace Google.Protobuf.FieldAccess
{
/// <summary>
- /// Allows fields to be reflectively accessed in a smart manner.
- /// The property descriptors for each field are created once and then cached.
- /// In addition, this interface holds knowledge of repeated fields, builders etc.
+ /// Allows fields to be reflectively accessed.
/// </summary>
- internal interface IFieldAccessor<T> where T : IMessage<T>
+ public interface IFieldAccessor
{
/// <summary>
- /// Indicates whether the specified message contains the field. For primitive fields
- /// declared in proto3-syntax messages, this simply checks whether the value is the default one.
+ /// Returns the descriptor associated with this field.
/// </summary>
- /// <exception cref="InvalidOperationException">The field is a repeated field, or a single primitive field.</exception>
- bool HasValue(T message);
+ FieldDescriptor Descriptor { get; }
/// <summary>
/// Clears the field in the specified message. (For repeated fields,
/// this clears the list.)
/// </summary>
- void Clear(T message);
+ void Clear(object message);
/// <summary>
/// Fetches the field value. For repeated values, this will be an
- /// <see cref="IList"/> implementation.
+ /// <see cref="IList"/> implementation. For map values, this will be an
+ /// <see cref="IDictionary"/> implementation.
/// </summary>
- object GetValue(T message);
+ object GetValue(object message);
/// <summary>
- /// Mutator for single fields only. (Repeated fields must be mutated
- /// by fetching the list, then mutating that.)
+ /// Mutator for single "simple" fields only.
/// </summary>
- /// <exception cref="InvalidOperationException">The field is a repeated field.</exception>
- void SetValue(T message, object value);
+ /// <remarks>
+ /// Repeated fields are mutated by fetching the value and manipulating it as a list.
+ /// Map fields are mutated by fetching the value and manipulating it as a dictionary.
+ /// </remarks>
+ /// <exception cref="InvalidOperationException">The field is not a "simple" field, or the message is frozen.</exception>
+ void SetValue(object message, object value);
}
}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/IDescriptorProto.cs b/csharp/src/ProtocolBuffers/FieldAccess/MapFieldAccessor.cs index c0f27427..100dbb37 100644 --- a/csharp/src/ProtocolBuffers/DescriptorProtos/IDescriptorProto.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/MapFieldAccessor.cs @@ -1,53 +1,59 @@ -#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-namespace Google.Protobuf.DescriptorProtos
-{
- /// <summary>
- /// Interface implemented by all DescriptorProtos. The generator doesn't
- /// emit the interface implementation claim, so PartialClasses.cs contains
- /// partial class declarations for each of them.
- /// </summary>
- /// <typeparam name="TOptions">The associated options protocol buffer type</typeparam>
- public interface IDescriptorProto<TOptions>
- {
- /// <summary>
- /// The brief name of the descriptor's target.
- /// </summary>
- string Name { get; }
-
- /// <summary>
- /// The options for this descriptor.
- /// </summary>
- TOptions Options { get; }
- }
-}
\ No newline at end of file +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Collections; +using Google.Protobuf.Descriptors; + +namespace Google.Protobuf.FieldAccess +{ + /// <summary> + /// Accessor for map fields. + /// </summary> + internal sealed class MapFieldAccessor : FieldAccessorBase + { + internal MapFieldAccessor(Type type, string propertyName, FieldDescriptor descriptor) : base(type, propertyName, descriptor) + { + } + + public override void Clear(object message) + { + IDictionary list = (IDictionary) GetValue(message); + list.Clear(); + } + + public override void SetValue(object message, object value) + { + throw new InvalidOperationException("SetValue is not implemented for map fields"); + } + } +} diff --git a/csharp/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs b/csharp/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs index 29399b0c..d3053920 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs @@ -31,6 +31,7 @@ #endregion
using System;
+using System.Linq.Expressions;
using System.Reflection;
namespace Google.Protobuf.FieldAccess
@@ -51,101 +52,42 @@ namespace Google.Protobuf.FieldAccess internal static readonly Type[] EmptyTypes = new Type[0];
/// <summary>
- /// Creates a delegate which will execute the given method and then return
- /// the result as an object.
+ /// Creates a delegate which will cast the argument to the appropriate method target type,
+ /// call the method on it, then convert the result to object.
/// </summary>
- public static Func<T, object> CreateUpcastDelegate<T>(MethodInfo method)
+ internal static Func<object, object> CreateFuncObjectObject(MethodInfo method)
{
- // The tricky bit is invoking CreateCreateUpcastDelegateImpl with the right type parameters
- MethodInfo openImpl = typeof(ReflectionUtil).GetMethod("CreateUpcastDelegateImpl");
- MethodInfo closedImpl = openImpl.MakeGenericMethod(typeof(T), method.ReturnType);
- return (Func<T, object>) closedImpl.Invoke(null, new object[] {method});
+ ParameterExpression parameter = Expression.Parameter(typeof(object), "p");
+ Expression downcast = Expression.Convert(parameter, method.DeclaringType);
+ Expression call = Expression.Call(downcast, method);
+ Expression upcast = Expression.Convert(call, typeof(object));
+ return Expression.Lambda<Func<object, object>>(upcast, parameter).Compile();
}
-
+
/// <summary>
- /// Method used solely for implementing CreateUpcastDelegate. Public to avoid trust issues
- /// in low-trust scenarios.
+ /// Creates a delegate which will execute the given method after casting the first argument to
+ /// the target type of the method, and the second argument to the first parameter type of the method.
/// </summary>
- public static Func<TSource, object> CreateUpcastDelegateImpl<TSource, TResult>(MethodInfo method)
+ internal static Action<object, object> CreateActionObjectObject(MethodInfo method)
{
- // Convert the reflection call into an open delegate, i.e. instead of calling x.Method()
- // we'll call getter(x).
- Func<TSource, TResult> getter = ReflectionUtil.CreateDelegateFunc<TSource, TResult>(method);
-
- // Implicit upcast to object (within the delegate)
- return source => getter(source);
+ ParameterExpression targetParameter = Expression.Parameter(typeof(object), "target");
+ ParameterExpression argParameter = Expression.Parameter(typeof(object), "arg");
+ Expression castTarget = Expression.Convert(targetParameter, method.DeclaringType);
+ Expression castArgument = Expression.Convert(argParameter, method.GetParameters()[0].ParameterType);
+ Expression call = Expression.Call(castTarget, method, castArgument);
+ return Expression.Lambda<Action<object, object>>(call, targetParameter, argParameter).Compile();
}
/// <summary>
- /// Creates a delegate which will execute the given method after casting the parameter
- /// down from object to the required parameter type.
+ /// Creates a delegate which will execute the given method after casting the first argument to
+ /// the target type of the method.
/// </summary>
- public static Action<T, object> CreateDowncastDelegate<T>(MethodInfo method)
- {
- MethodInfo openImpl = typeof(ReflectionUtil).GetMethod("CreateDowncastDelegateImpl");
- MethodInfo closedImpl = openImpl.MakeGenericMethod(typeof(T), method.GetParameters()[0].ParameterType);
- return (Action<T, object>) closedImpl.Invoke(null, new object[] {method});
- }
-
- public static Action<TSource, object> CreateDowncastDelegateImpl<TSource, TParam>(MethodInfo method)
- {
- // Convert the reflection call into an open delegate, i.e. instead of calling x.Method(y) we'll
- // call Method(x, y)
- Action<TSource, TParam> call = ReflectionUtil.CreateDelegateAction<TSource, TParam>(method);
-
- return (source, parameter) => call(source, (TParam) parameter);
- }
-
- /// <summary>
- /// Creates a delegate which will execute the given method after casting the parameter
- /// down from object to the required parameter type.
- /// </summary>
- public static Action<T, object> CreateDowncastDelegateIgnoringReturn<T>(MethodInfo method)
- {
- MethodInfo openImpl = typeof(ReflectionUtil).GetMethod("CreateDowncastDelegateIgnoringReturnImpl");
- MethodInfo closedImpl = openImpl.MakeGenericMethod(typeof(T), method.GetParameters()[0].ParameterType,
- method.ReturnType);
- return (Action<T, object>) closedImpl.Invoke(null, new object[] {method});
- }
-
- public static Action<TSource, object> CreateDowncastDelegateIgnoringReturnImpl<TSource, TParam, TReturn>(
- MethodInfo method)
- {
- // Convert the reflection call into an open delegate, i.e. instead of calling x.Method(y) we'll
- // call Method(x, y)
- Func<TSource, TParam, TReturn> call = ReflectionUtil.CreateDelegateFunc<TSource, TParam, TReturn>(method);
-
- return delegate(TSource source, object parameter) { call(source, (TParam) parameter); };
- }
-
- internal static Func<TResult> CreateDelegateFunc<TResult>(MethodInfo method)
- {
- object tdelegate = Delegate.CreateDelegate(typeof(Func<TResult>), null, method);
- return (Func<TResult>)tdelegate;
- }
-
- internal static Func<T, TResult> CreateDelegateFunc<T, TResult>(MethodInfo method)
- {
- object tdelegate = Delegate.CreateDelegate(typeof(Func<T, TResult>), null, method);
- return (Func<T, TResult>)tdelegate;
- }
-
- internal static Func<T1, T2, TResult> CreateDelegateFunc<T1, T2, TResult>(MethodInfo method)
- {
- object tdelegate = Delegate.CreateDelegate(typeof(Func<T1, T2, TResult>), null, method);
- return (Func<T1, T2, TResult>)tdelegate;
- }
-
- internal static Action<T> CreateDelegateAction<T>(MethodInfo method)
- {
- object tdelegate = Delegate.CreateDelegate(typeof(Action<T>), null, method);
- return (Action<T>)tdelegate;
- }
-
- internal static Action<T1, T2> CreateDelegateAction<T1, T2>(MethodInfo method)
+ internal static Action<object> CreateActionObject(MethodInfo method)
{
- object tdelegate = Delegate.CreateDelegate(typeof(Action<T1, T2>), null, method);
- return (Action<T1, T2>)tdelegate;
+ ParameterExpression targetParameter = Expression.Parameter(typeof(object), "target");
+ Expression castTarget = Expression.Convert(targetParameter, method.DeclaringType);
+ Expression call = Expression.Call(castTarget, method);
+ return Expression.Lambda<Action<object>>(call, targetParameter).Compile();
}
}
}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/FieldAccess/RepeatedFieldAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/RepeatedFieldAccessor.cs index b12278f9..8d7ecbaf 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/RepeatedFieldAccessor.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/RepeatedFieldAccessor.cs @@ -32,33 +32,28 @@ using System; using System.Collections; +using Google.Protobuf.Descriptors; namespace Google.Protobuf.FieldAccess { /// <summary> /// Accessor for repeated fields. /// </summary> - /// <typeparam name="T">The type of message containing the field.</typeparam> - internal sealed class RepeatedFieldAccessor<T> : FieldAccessorBase<T> where T : IMessage<T> + internal sealed class RepeatedFieldAccessor : FieldAccessorBase { - internal RepeatedFieldAccessor(string name) : base(name) + internal RepeatedFieldAccessor(Type type, string propertyName, FieldDescriptor descriptor) : base(type, propertyName, descriptor) { } - public override void Clear(T message) + public override void Clear(object message) { IList list = (IList) GetValue(message); list.Clear(); } - public override bool HasValue(T message) + public override void SetValue(object message, object value) { - throw new NotImplementedException("HasValue is not implemented for repeated fields"); - } - - public override void SetValue(T message, object value) - { - throw new NotImplementedException("SetValue is not implemented for repeated fields"); + throw new InvalidOperationException("SetValue is not implemented for repeated fields"); } } diff --git a/csharp/src/ProtocolBuffers/FieldAccess/SingleFieldAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/SingleFieldAccessor.cs index 7a8f726e..cdc89e8d 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/SingleFieldAccessor.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/SingleFieldAccessor.cs @@ -39,76 +39,46 @@ namespace Google.Protobuf.FieldAccess /// <summary> /// Accessor for single fields. /// </summary> - /// <typeparam name="T">The type of message containing the field.</typeparam> - internal sealed class SingleFieldAccessor<T> : FieldAccessorBase<T> where T : IMessage<T> + internal sealed class SingleFieldAccessor : FieldAccessorBase { // All the work here is actually done in the constructor - it creates the appropriate delegates. // There are various cases to consider, based on the property type (message, string/bytes, or "genuine" primitive) // and proto2 vs proto3 for non-message types, as proto3 doesn't support "full" presence detection or default // values. - private readonly Action<T, object> setValueDelegate; - private readonly Action<T> clearDelegate; - private readonly Func<T, bool> hasValueDelegate; + private readonly Action<object, object> setValueDelegate; + private readonly Action<object> clearDelegate; - internal SingleFieldAccessor(FieldDescriptor descriptor, string name, bool supportsFieldPresence) : base(name) + internal SingleFieldAccessor(Type type, string propertyName, FieldDescriptor descriptor) : base(type, propertyName, descriptor) { - PropertyInfo property = typeof(T).GetProperty(name); + PropertyInfo property = type.GetProperty(propertyName); // We know there *is* such a property, or the base class constructor would have thrown. We should be able to write // to it though. if (!property.CanWrite) { throw new ArgumentException("Not all required properties/methods available"); } - setValueDelegate = ReflectionUtil.CreateDowncastDelegate<T>(property.GetSetMethod()); + setValueDelegate = ReflectionUtil.CreateActionObjectObject(property.GetSetMethod()); var clrType = property.PropertyType; + + // TODO: What should clear on a oneof member do? Clear the oneof? - if (typeof(IMessage).IsAssignableFrom(clrType)) - { - // Message types are simple - we only need to detect nullity. - clearDelegate = message => SetValue(message, null); - hasValueDelegate = message => GetValue(message) == null; - } - - if (supportsFieldPresence) - { - // Proto2: we expect a HasFoo property and a ClearFoo method. - // For strings and byte arrays, setting the property to null would have the equivalent effect, - // but we generate the method for consistency, which makes this simpler. - PropertyInfo hasProperty = typeof(T).GetProperty("Has" + name); - MethodInfo clearMethod = typeof(T).GetMethod("Clear" + name); - if (hasProperty == null || clearMethod == null || !hasProperty.CanRead) - { - throw new ArgumentException("Not all required properties/methods available"); - } - hasValueDelegate = ReflectionUtil.CreateDelegateFunc<T, bool>(hasProperty.GetGetMethod()); - clearDelegate = ReflectionUtil.CreateDelegateAction<T>(clearMethod); - } - else - { - /* - // TODO(jonskeet): Reimplement. We need a better way of working out default values. - // Proto3: for field detection, we just need the default value of the field (0, "", byte[0] etc) - // To clear a field, we set the value to that default. - object defaultValue = descriptor.DefaultValue; - hasValueDelegate = message => GetValue(message).Equals(defaultValue); - clearDelegate = message => SetValue(message, defaultValue); - */ - } - } - - public override bool HasValue(T message) - { - return hasValueDelegate(message); + // TODO: Validate that this is a reasonable single field? (Should be a value type, a message type, or string/ByteString.) + object defaultValue = + typeof(IMessage).IsAssignableFrom(clrType) ? null + : clrType == typeof(string) ? "" + : clrType == typeof(ByteString) ? ByteString.Empty + : Activator.CreateInstance(clrType); + clearDelegate = message => SetValue(message, defaultValue); } - public override void Clear(T message) + public override void Clear(object message) { clearDelegate(message); } - public override void SetValue(T message, object value) + public override void SetValue(object message, object value) { setValueDelegate(message, value); } diff --git a/csharp/src/ProtocolBuffers/FieldCodec.cs b/csharp/src/ProtocolBuffers/FieldCodec.cs index 2cebc1bb..c72a3e7b 100644 --- a/csharp/src/ProtocolBuffers/FieldCodec.cs +++ b/csharp/src/ProtocolBuffers/FieldCodec.cs @@ -68,12 +68,12 @@ namespace Google.Protobuf public static FieldCodec<uint> ForFixed32(uint tag) { - return new FieldCodec<uint>(input => input.ReadFixed32(), (output, value) => output.WriteFixed32(value), CodedOutputStream.ComputeFixed32Size, tag); + return new FieldCodec<uint>(input => input.ReadFixed32(), (output, value) => output.WriteFixed32(value), 4, tag); } public static FieldCodec<int> ForSFixed32(uint tag) { - return new FieldCodec<int>(input => input.ReadSFixed32(), (output, value) => output.WriteSFixed32(value), CodedOutputStream.ComputeSFixed32Size, tag); + return new FieldCodec<int>(input => input.ReadSFixed32(), (output, value) => output.WriteSFixed32(value), 4, tag); } public static FieldCodec<uint> ForUInt32(uint tag) @@ -93,12 +93,12 @@ namespace Google.Protobuf public static FieldCodec<ulong> ForFixed64(uint tag) { - return new FieldCodec<ulong>(input => input.ReadFixed64(), (output, value) => output.WriteFixed64(value), CodedOutputStream.ComputeFixed64Size, tag); + return new FieldCodec<ulong>(input => input.ReadFixed64(), (output, value) => output.WriteFixed64(value), 8, tag); } public static FieldCodec<long> ForSFixed64(uint tag) { - return new FieldCodec<long>(input => input.ReadSFixed64(), (output, value) => output.WriteSFixed64(value), CodedOutputStream.ComputeSFixed64Size, tag); + return new FieldCodec<long>(input => input.ReadSFixed64(), (output, value) => output.WriteSFixed64(value), 8, tag); } public static FieldCodec<ulong> ForUInt64(uint tag) diff --git a/csharp/src/ProtocolBuffers/IMessage.cs b/csharp/src/ProtocolBuffers/IMessage.cs index 27bcc117..ad44668c 100644 --- a/csharp/src/ProtocolBuffers/IMessage.cs +++ b/csharp/src/ProtocolBuffers/IMessage.cs @@ -40,12 +40,11 @@ namespace Google.Protobuf // TODO(jonskeet): Split these interfaces into separate files when we're happy with them.
/// <summary>
- /// Reflection support for a specific message type. message
+ /// Reflection support for a specific message type.
/// </summary>
- /// <typeparam name="T">The message type being reflected.</typeparam>
- public interface IReflectedMessage<T> where T : IMessage<T>
+ public interface IReflectedMessage
{
- FieldAccessorTable<T> Fields { get; }
+ FieldAccessorTable Fields { get; }
// TODO(jonskeet): Descriptor? Or a single property which has "all you need for reflection"?
}
diff --git a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj index 1e7408ea..aa4adcc0 100644 --- a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj +++ b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj @@ -61,7 +61,6 @@ <Compile Include="Collections\ReadOnlyDictionary.cs" />
<Compile Include="Collections\RepeatedField.cs" />
<Compile Include="DescriptorProtos\DescriptorProtoFile.cs" />
- <Compile Include="DescriptorProtos\IDescriptorProto.cs" />
<Compile Include="DescriptorProtos\PartialClasses.cs" />
<Compile Include="Descriptors\DescriptorBase.cs" />
<Compile Include="Descriptors\DescriptorPool.cs" />
@@ -74,11 +73,11 @@ <Compile Include="Descriptors\FileDescriptor.cs" />
<Compile Include="Descriptors\OneofDescriptor.cs" />
<Compile Include="Descriptors\IDescriptor.cs" />
- <Compile Include="Descriptors\IndexedDescriptorBase.cs" />
<Compile Include="Descriptors\MessageDescriptor.cs" />
<Compile Include="Descriptors\MethodDescriptor.cs" />
<Compile Include="Descriptors\PackageDescriptor.cs" />
<Compile Include="Descriptors\ServiceDescriptor.cs" />
+ <Compile Include="FieldAccess\MapFieldAccessor.cs" />
<Compile Include="FieldCodec.cs" />
<Compile Include="FrameworkPortability.cs" />
<Compile Include="Freezable.cs" />
|