aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/ProtocolBuffers/Descriptors
diff options
context:
space:
mode:
Diffstat (limited to 'csharp/src/ProtocolBuffers/Descriptors')
-rw-r--r--csharp/src/ProtocolBuffers/Descriptors/DescriptorBase.cs5
-rw-r--r--csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs4
-rw-r--r--csharp/src/ProtocolBuffers/Descriptors/DescriptorUtil.cs4
-rw-r--r--csharp/src/ProtocolBuffers/Descriptors/DescriptorValidationException.cs13
-rw-r--r--csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs31
-rw-r--r--csharp/src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs7
-rw-r--r--csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs223
-rw-r--r--csharp/src/ProtocolBuffers/Descriptors/FieldMappingAttribute.cs4
-rw-r--r--csharp/src/ProtocolBuffers/Descriptors/FieldType.cs2
-rw-r--r--csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs55
-rw-r--r--csharp/src/ProtocolBuffers/Descriptors/IDescriptor.cs4
-rw-r--r--csharp/src/ProtocolBuffers/Descriptors/IndexedDescriptorBase.cs4
-rw-r--r--csharp/src/ProtocolBuffers/Descriptors/MappedType.cs2
-rw-r--r--csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs30
-rw-r--r--csharp/src/ProtocolBuffers/Descriptors/MethodDescriptor.cs4
-rw-r--r--csharp/src/ProtocolBuffers/Descriptors/OneofDescriptor.cs4
-rw-r--r--csharp/src/ProtocolBuffers/Descriptors/PackageDescriptor.cs2
-rw-r--r--csharp/src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs8
18 files changed, 85 insertions, 321 deletions
diff --git a/csharp/src/ProtocolBuffers/Descriptors/DescriptorBase.cs b/csharp/src/ProtocolBuffers/Descriptors/DescriptorBase.cs
index 59006f80..39f6d843 100644
--- a/csharp/src/ProtocolBuffers/Descriptors/DescriptorBase.cs
+++ b/csharp/src/ProtocolBuffers/Descriptors/DescriptorBase.cs
@@ -29,10 +29,11 @@
// 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.
-using Google.ProtocolBuffers.DescriptorProtos;
+using Google.Protobuf.DescriptorProtos;
-namespace Google.ProtocolBuffers.Descriptors
+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>
diff --git a/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs b/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs
index 30718709..02b59d76 100644
--- a/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs
+++ b/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs
@@ -34,7 +34,7 @@ using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Contains lookup tables containing all the descriptors defined in a particular file.
@@ -85,7 +85,7 @@ namespace Google.ProtocolBuffers.Descriptors
/// <param name="fullName">Fully-qualified name to look up</param>
/// <returns>The symbol with the given name and type,
/// or null if the symbol doesn't exist or has the wrong type</returns>
- internal T FindSymbol<T>(string fullName) where T : class, IDescriptor
+ internal T FindSymbol<T>(string fullName) where T : class
{
IDescriptor result;
descriptorsByName.TryGetValue(fullName, out result);
diff --git a/csharp/src/ProtocolBuffers/Descriptors/DescriptorUtil.cs b/csharp/src/ProtocolBuffers/Descriptors/DescriptorUtil.cs
index 00efdbe8..9fc84c3e 100644
--- a/csharp/src/ProtocolBuffers/Descriptors/DescriptorUtil.cs
+++ b/csharp/src/ProtocolBuffers/Descriptors/DescriptorUtil.cs
@@ -30,9 +30,9 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System.Collections.Generic;
-using Google.ProtocolBuffers.Collections;
+using Google.Protobuf.Collections;
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Internal class containing utility methods when working with descriptors.
diff --git a/csharp/src/ProtocolBuffers/Descriptors/DescriptorValidationException.cs b/csharp/src/ProtocolBuffers/Descriptors/DescriptorValidationException.cs
index d05d60d7..08516951 100644
--- a/csharp/src/ProtocolBuffers/Descriptors/DescriptorValidationException.cs
+++ b/csharp/src/ProtocolBuffers/Descriptors/DescriptorValidationException.cs
@@ -31,7 +31,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Thrown when building descriptors fails because the source DescriptorProtos
@@ -40,7 +40,6 @@ namespace Google.ProtocolBuffers.Descriptors
public sealed class DescriptorValidationException : Exception
{
private readonly String name;
- private readonly IMessage proto;
private readonly string description;
/// <value>
@@ -52,14 +51,6 @@ namespace Google.ProtocolBuffers.Descriptors
}
/// <value>
- /// The protocol message representation of the invalid descriptor.
- /// </value>
- public IMessage ProblemProto
- {
- get { return proto; }
- }
-
- /// <value>
/// A human-readable description of the error. (The Message property
/// is made up of the descriptor's name and this description.)
/// </value>
@@ -75,7 +66,6 @@ namespace Google.ProtocolBuffers.Descriptors
// don't want to expose it directly to the user. So, we only provide
// the name and the original proto.
name = problemDescriptor.FullName;
- proto = problemDescriptor.Proto;
this.description = description;
}
@@ -83,7 +73,6 @@ namespace Google.ProtocolBuffers.Descriptors
base(problemDescriptor.FullName + ": " + description, cause)
{
name = problemDescriptor.FullName;
- proto = problemDescriptor.Proto;
this.description = description;
}
}
diff --git a/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs
index a0b81b69..3f2abcaa 100644
--- a/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs
+++ b/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs
@@ -30,15 +30,14 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System.Collections.Generic;
-using Google.ProtocolBuffers.DescriptorProtos;
+using Google.Protobuf.DescriptorProtos;
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Descriptor for an enum type in a .proto file.
/// </summary>
- public sealed class EnumDescriptor : IndexedDescriptorBase<EnumDescriptorProto, EnumOptions>,
- IEnumLiteMap<EnumValueDescriptor>
+ public sealed class EnumDescriptor : IndexedDescriptorBase<EnumDescriptorProto, EnumOptions>
{
private readonly MessageDescriptor containingType;
private readonly IList<EnumValueDescriptor> values;
@@ -48,14 +47,14 @@ namespace Google.ProtocolBuffers.Descriptors
{
containingType = parent;
- if (proto.ValueCount == 0)
+ if (proto.Value.Count == 0)
{
// We cannot allow enums with no values because this would mean there
// would be no valid default value for fields of this type.
throw new DescriptorValidationException(this, "Enums must contain at least one value.");
}
- values = DescriptorUtil.ConvertAndMakeReadOnly(proto.ValueList,
+ values = DescriptorUtil.ConvertAndMakeReadOnly(proto.Value,
(value, i) => new EnumValueDescriptor(value, file, this, i));
File.DescriptorPool.AddSymbol(this);
@@ -78,14 +77,6 @@ namespace Google.ProtocolBuffers.Descriptors
}
/// <summary>
- /// Logic moved from FieldSet to continue current behavior
- /// </summary>
- public bool IsValidValue(IEnumLite value)
- {
- return value is EnumValueDescriptor && ((EnumValueDescriptor) value).EnumDescriptor == this;
- }
-
- /// <summary>
/// Finds an enum value by number. If multiple enum values have the
/// same number, this returns the first defined value with that number.
/// </summary>
@@ -94,16 +85,6 @@ namespace Google.ProtocolBuffers.Descriptors
return File.DescriptorPool.FindEnumValueByNumber(this, number);
}
- IEnumLite IEnumLiteMap.FindValueByNumber(int number)
- {
- return FindValueByNumber(number);
- }
-
- IEnumLite IEnumLiteMap.FindValueByName(string name)
- {
- return FindValueByName(name);
- }
-
/// <summary>
/// Finds an enum value by name.
/// </summary>
@@ -119,7 +100,7 @@ namespace Google.ProtocolBuffers.Descriptors
base.ReplaceProto(newProto);
for (int i = 0; i < values.Count; i++)
{
- values[i].ReplaceProto(newProto.GetValue(i));
+ values[i].ReplaceProto(newProto.Value[i]);
}
}
}
diff --git a/csharp/src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs
index afb9cbbc..6a5eb558 100644
--- a/csharp/src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs
+++ b/csharp/src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs
@@ -29,15 +29,14 @@
// 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.
-using Google.ProtocolBuffers.DescriptorProtos;
+using Google.Protobuf.DescriptorProtos;
-namespace Google.ProtocolBuffers.Descriptors
+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>,
- IEnumLite
+ public sealed class EnumValueDescriptor : IndexedDescriptorBase<EnumValueDescriptorProto, EnumValueOptions>
{
private readonly EnumDescriptor enumDescriptor;
diff --git a/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs
index e7f5a3c1..c7d2e683 100644
--- a/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs
+++ b/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs
@@ -32,23 +32,22 @@
using System;
using System.Collections.Generic;
using System.Reflection;
-using Google.ProtocolBuffers.Collections;
-using Google.ProtocolBuffers.DescriptorProtos;
+using Google.Protobuf.Collections;
+using Google.Protobuf.DescriptorProtos;
-namespace Google.ProtocolBuffers.Descriptors
+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>, IFieldDescriptorLite
+ IComparable<FieldDescriptor>
{
private readonly MessageDescriptor extensionScope;
private EnumDescriptor enumType;
private MessageDescriptor messageType;
private MessageDescriptor containingType;
private OneofDescriptor containingOneof;
- private object defaultValue;
private FieldType fieldType;
private MappedType mappedType;
@@ -58,7 +57,7 @@ namespace Google.ProtocolBuffers.Descriptors
MessageDescriptor parent, int index, bool isExtension)
: base(proto, file, ComputeFullName(file, parent, proto.Name), index)
{
- if (proto.HasType)
+ if (proto.Type != 0)
{
fieldType = GetFieldTypeFromProtoType(proto.Type);
mappedType = FieldTypeToMappedTypeMap[fieldType];
@@ -72,7 +71,7 @@ namespace Google.ProtocolBuffers.Descriptors
if (isExtension)
{
- if (!proto.HasExtendee)
+ if (proto.Extendee != "")
{
throw new DescriptorValidationException(this,
"FieldDescriptorProto.Extendee not set for extension field.");
@@ -89,15 +88,10 @@ namespace Google.ProtocolBuffers.Descriptors
}
else
{
- if (proto.HasExtendee)
- {
- throw new DescriptorValidationException(this,
- "FieldDescriptorProto.Extendee set for non-extension field.");
- }
containingType = parent;
- if (proto.HasOneofIndex)
+ if (proto.OneofIndex != 0)
{
- if (proto.OneofIndex < 0 || proto.OneofIndex >= parent.Proto.OneofDeclCount)
+ if (proto.OneofIndex < 0 || proto.OneofIndex >= parent.Proto.OneofDecl.Count)
{
throw new DescriptorValidationException(this,
"FieldDescriptorProto.oneof_index is out of range for type " + parent.Name);
@@ -213,48 +207,15 @@ namespace Google.ProtocolBuffers.Descriptors
get { return Proto.Options.Packed; }
}
- /// <valule>
- /// Indicates whether or not the field had an explicitly-defined default value.
- /// </value>
- public bool HasDefaultValue
- {
- get { return Proto.HasDefaultValue; }
- }
-
/// <value>
- /// The field's default value. Valid for all types except messages
- /// and groups. For all other types, the object returned is of the
- /// same class that would be returned by IMessage[this].
- /// For repeated fields this will always be an empty immutable list compatible with IList[object].
- /// For message fields it will always be null. For singular values, it will depend on the descriptor.
+ /// Indicates whether or not this field is an extension. (Only relevant when parsing
+ /// the proto2 descriptor...)
/// </value>
- public object DefaultValue
+ internal bool IsExtension
{
- get
- {
- if (MappedType == MappedType.Message)
- {
- throw new InvalidOperationException(
- "FieldDescriptor.DefaultValue called on an embedded message field.");
- }
- return defaultValue;
- }
+ get { return Proto.Extendee != ""; }
}
- /// <value>
- /// Indicates whether or not this field is an extension.
- /// </value>
- public bool IsExtension
- {
- get { return Proto.HasExtendee; }
- }
-
- /*
- * Get the field's containing type. For extensions, this is the type being
- * extended, not the location where the extension was defined. See
- * {@link #getExtensionScope()}.
- */
-
/// <summary>
/// Get the field's containing type. For extensions, this is the type being
/// extended, not the location where the extension was defined. See
@@ -336,27 +297,6 @@ namespace Google.ProtocolBuffers.Descriptors
}
/// <summary>
- /// Compares this descriptor with another one, ordering in "canonical" order
- /// which simply means ascending order by field number. <paramref name="other"/>
- /// must be a field of the same type, i.e. the <see cref="ContainingType"/> of
- /// both fields must be the same.
- /// </summary>
- public int CompareTo(IFieldDescriptorLite other)
- {
- return FieldNumber - other.FieldNumber;
- }
-
- IEnumLiteMap IFieldDescriptorLite.EnumType
- {
- get { return EnumType; }
- }
-
- bool IFieldDescriptorLite.MessageSetWireFormat
- {
- get { return ContainingType.Options.MessageSetWireFormat; }
- }
-
- /// <summary>
/// For enum fields, returns the field's type.
/// </summary>
public EnumDescriptor EnumType
@@ -410,29 +350,12 @@ namespace Google.ProtocolBuffers.Descriptors
/// </summary>
internal void CrossLink()
{
- if (Proto.HasExtendee)
- {
- IDescriptor extendee = File.DescriptorPool.LookupSymbol(Proto.Extendee, this);
- if (!(extendee is MessageDescriptor))
- {
- throw new DescriptorValidationException(this, "\"" + Proto.Extendee + "\" is not a message type.");
- }
- containingType = (MessageDescriptor) extendee;
-
- if (!containingType.IsExtensionNumber(FieldNumber))
- {
- throw new DescriptorValidationException(this,
- "\"" + containingType.FullName + "\" does not declare " +
- FieldNumber + " as an extension number.");
- }
- }
-
- if (Proto.HasTypeName)
+ if (Proto.TypeName != "")
{
IDescriptor typeDescriptor =
File.DescriptorPool.LookupSymbol(Proto.TypeName, this);
- if (!Proto.HasType)
+ if (Proto.Type != 0)
{
// Choose field type based on symbol.
if (typeDescriptor is MessageDescriptor)
@@ -460,7 +383,7 @@ namespace Google.ProtocolBuffers.Descriptors
}
messageType = (MessageDescriptor) typeDescriptor;
- if (Proto.HasDefaultValue)
+ if (Proto.DefaultValue != "")
{
throw new DescriptorValidationException(this, "Messages can't have default values.");
}
@@ -486,126 +409,14 @@ namespace Google.ProtocolBuffers.Descriptors
}
}
- // We don't attempt to parse the default value until here because for
- // enums we need the enum type's descriptor.
- if (Proto.HasDefaultValue)
- {
- if (IsRepeated)
- {
- throw new DescriptorValidationException(this, "Repeated fields cannot have default values.");
- }
-
- try
- {
- switch (FieldType)
- {
- case FieldType.Int32:
- case FieldType.SInt32:
- case FieldType.SFixed32:
- defaultValue = TextFormat.ParseInt32(Proto.DefaultValue);
- break;
- case FieldType.UInt32:
- case FieldType.Fixed32:
- defaultValue = TextFormat.ParseUInt32(Proto.DefaultValue);
- break;
- case FieldType.Int64:
- case FieldType.SInt64:
- case FieldType.SFixed64:
- defaultValue = TextFormat.ParseInt64(Proto.DefaultValue);
- break;
- case FieldType.UInt64:
- case FieldType.Fixed64:
- defaultValue = TextFormat.ParseUInt64(Proto.DefaultValue);
- break;
- case FieldType.Float:
- defaultValue = TextFormat.ParseFloat(Proto.DefaultValue);
- break;
- case FieldType.Double:
- defaultValue = TextFormat.ParseDouble(Proto.DefaultValue);
- break;
- case FieldType.Bool:
- if (Proto.DefaultValue == "true")
- {
- defaultValue = true;
- }
- else if (Proto.DefaultValue == "false")
- {
- defaultValue = false;
- }
- else
- {
- throw new FormatException("Boolean values must be \"true\" or \"false\"");
- }
- break;
- case FieldType.String:
- defaultValue = Proto.DefaultValue;
- break;
- case FieldType.Bytes:
- try
- {
- defaultValue = TextFormat.UnescapeBytes(Proto.DefaultValue);
- }
- catch (FormatException e)
- {
- throw new DescriptorValidationException(this,
- "Couldn't parse default value: " + e.Message);
- }
- break;
- case FieldType.Enum:
- defaultValue = enumType.FindValueByName(Proto.DefaultValue);
- if (defaultValue == null)
- {
- throw new DescriptorValidationException(this,
- "Unknown enum default value: \"" +
- Proto.DefaultValue + "\"");
- }
- break;
- case FieldType.Message:
- case FieldType.Group:
- throw new DescriptorValidationException(this, "Message type had default value.");
- }
- }
- catch (FormatException e)
- {
- DescriptorValidationException validationException =
- new DescriptorValidationException(this,
- "Could not parse default value: \"" + Proto.DefaultValue +
- "\"", e);
- throw validationException;
- }
- }
- else
- {
- // Determine the default default for this field.
- if (IsRepeated)
- {
- defaultValue = Lists<object>.Empty;
- }
- else
- {
- switch (MappedType)
- {
- case MappedType.Enum:
- // We guarantee elsewhere that an enum type always has at least
- // one possible value.
- defaultValue = enumType.Values[0];
- break;
- case MappedType.Message:
- defaultValue = null;
- break;
- default:
- defaultValue = GetDefaultValueForMappedType(MappedType);
- break;
- }
- }
- }
+ // Note: no attempt to perform any default value parsing
if (!IsExtension)
{
File.DescriptorPool.AddFieldByNumber(this);
}
- if (containingType != null && containingType.Options.MessageSetWireFormat)
+ if (containingType != null && containingType.Options != null && containingType.Options.MessageSetWireFormat)
{
if (IsExtension)
{
diff --git a/csharp/src/ProtocolBuffers/Descriptors/FieldMappingAttribute.cs b/csharp/src/ProtocolBuffers/Descriptors/FieldMappingAttribute.cs
index 752ecf66..ab15eb01 100644
--- a/csharp/src/ProtocolBuffers/Descriptors/FieldMappingAttribute.cs
+++ b/csharp/src/ProtocolBuffers/Descriptors/FieldMappingAttribute.cs
@@ -32,9 +32,9 @@
using System;
using System.Collections.Generic;
using System.Reflection;
-using Google.ProtocolBuffers.Collections;
+using Google.Protobuf.Collections;
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Defined specifically for the <see cref="FieldType" /> enumeration,
diff --git a/csharp/src/ProtocolBuffers/Descriptors/FieldType.cs b/csharp/src/ProtocolBuffers/Descriptors/FieldType.cs
index 056d3d45..f7ec898e 100644
--- a/csharp/src/ProtocolBuffers/Descriptors/FieldType.cs
+++ b/csharp/src/ProtocolBuffers/Descriptors/FieldType.cs
@@ -30,7 +30,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Enumeration of all the possible field types. The odd formatting is to make it very clear
diff --git a/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs
index fed032bf..164406f9 100644
--- a/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs
+++ b/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs
@@ -33,10 +33,10 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
-using Google.ProtocolBuffers.DescriptorProtos;
-using FileOptions = Google.ProtocolBuffers.DescriptorProtos.FileOptions;
+using Google.Protobuf.DescriptorProtos;
+using FileOptions = Google.Protobuf.DescriptorProtos.FileOptions;
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Describes a .proto file, including everything defined within.
@@ -75,19 +75,19 @@ namespace Google.ProtocolBuffers.Descriptors
pool.AddPackage(Package, this);
- messageTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.MessageTypeList,
+ messageTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.MessageType,
(message, index) =>
new MessageDescriptor(message, this, null, index));
- enumTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.EnumTypeList,
+ enumTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.EnumType,
(enumType, index) =>
new EnumDescriptor(enumType, this, null, index));
- services = DescriptorUtil.ConvertAndMakeReadOnly(proto.ServiceList,
+ services = DescriptorUtil.ConvertAndMakeReadOnly(proto.Service,
(service, index) =>
new ServiceDescriptor(service, this, index));
- extensions = DescriptorUtil.ConvertAndMakeReadOnly(proto.ExtensionList,
+ extensions = DescriptorUtil.ConvertAndMakeReadOnly(proto.Extension,
(field, index) =>
new FieldDescriptor(field, this, null, index, true));
}
@@ -104,14 +104,14 @@ namespace Google.ProtocolBuffers.Descriptors
nameToFileMap[file.Name] = file;
}
var publicDependencies = new List<FileDescriptor>();
- for (int i = 0; i < proto.PublicDependencyCount; i++)
+ for (int i = 0; i < proto.PublicDependency.Count; i++)
{
- int index = proto.PublicDependencyList[i];
- if (index < 0 || index >= proto.DependencyCount)
+ int index = proto.PublicDependency[i];
+ if (index < 0 || index >= proto.Dependency.Count)
{
throw new DescriptorValidationException(@this, "Invalid public dependency index.");
}
- string name = proto.DependencyList[index];
+ string name = proto.Dependency[index];
FileDescriptor file = nameToFileMap[name];
if (file == null)
{
@@ -371,7 +371,7 @@ namespace Google.ProtocolBuffers.Descriptors
/// </summary>
public static FileDescriptor InternalBuildGeneratedFileFrom(byte[] descriptorData, FileDescriptor[] dependencies)
{
- return InternalBuildGeneratedFileFrom(descriptorData, dependencies, x => null);
+ return InternalBuildGeneratedFileFrom(descriptorData, dependencies, x => { });
}
/// <summary>
@@ -384,9 +384,7 @@ namespace Google.ProtocolBuffers.Descriptors
/// in descriptor.proto. The callback may also return null to indicate that
/// no extensions are used in the descriptor.
/// </summary>
- /// <param name="descriptor"></param>
- /// <returns></returns>
- public delegate ExtensionRegistry InternalDescriptorAssigner(FileDescriptor descriptor);
+ public delegate void InternalDescriptorAssigner(FileDescriptor descriptor);
public static FileDescriptor InternalBuildGeneratedFileFrom(byte[] descriptorData,
FileDescriptor[] dependencies,
@@ -395,7 +393,7 @@ namespace Google.ProtocolBuffers.Descriptors
FileDescriptorProto proto;
try
{
- proto = FileDescriptorProto.ParseFrom(descriptorData);
+ proto = FileDescriptorProto.Parser.ParseFrom(descriptorData);
}
catch (InvalidProtocolBufferException e)
{
@@ -414,22 +412,7 @@ namespace Google.ProtocolBuffers.Descriptors
throw new ArgumentException("Invalid embedded descriptor for \"" + proto.Name + "\".", e);
}
- ExtensionRegistry registry = descriptorAssigner(result);
-
- if (registry != null)
- {
- // We must re-parse the proto using the registry.
- try
- {
- proto = FileDescriptorProto.ParseFrom(descriptorData, registry);
- }
- catch (InvalidProtocolBufferException e)
- {
- throw new ArgumentException("Failed to parse protocol buffer descriptor for generated code.", e);
- }
-
- result.ReplaceProto(proto);
- }
+ descriptorAssigner(result);
return result;
}
@@ -449,22 +432,22 @@ namespace Google.ProtocolBuffers.Descriptors
for (int i = 0; i < messageTypes.Count; i++)
{
- messageTypes[i].ReplaceProto(proto.GetMessageType(i));
+ messageTypes[i].ReplaceProto(proto.MessageType[i]);
}
for (int i = 0; i < enumTypes.Count; i++)
{
- enumTypes[i].ReplaceProto(proto.GetEnumType(i));
+ enumTypes[i].ReplaceProto(proto.EnumType[i]);
}
for (int i = 0; i < services.Count; i++)
{
- services[i].ReplaceProto(proto.GetService(i));
+ services[i].ReplaceProto(proto.Service[i]);
}
for (int i = 0; i < extensions.Count; i++)
{
- extensions[i].ReplaceProto(proto.GetExtension(i));
+ extensions[i].ReplaceProto(proto.Extension[i]);
}
}
diff --git a/csharp/src/ProtocolBuffers/Descriptors/IDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/IDescriptor.cs
index 899c1560..afed09a9 100644
--- a/csharp/src/ProtocolBuffers/Descriptors/IDescriptor.cs
+++ b/csharp/src/ProtocolBuffers/Descriptors/IDescriptor.cs
@@ -30,7 +30,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// The non-generic form of the IDescriptor interface. Useful for describing a general
@@ -48,7 +48,7 @@ namespace Google.ProtocolBuffers.Descriptors
/// Strongly-typed form of the IDescriptor interface.
/// </summary>
/// <typeparam name="TProto">Protocol buffer type underlying this descriptor type</typeparam>
- public interface IDescriptor<TProto> : IDescriptor where TProto : IMessage
+ internal interface IDescriptor<TProto> : IDescriptor where TProto : IMessage
{
new TProto Proto { get; }
}
diff --git a/csharp/src/ProtocolBuffers/Descriptors/IndexedDescriptorBase.cs b/csharp/src/ProtocolBuffers/Descriptors/IndexedDescriptorBase.cs
index bdb4eb82..3bc3a911 100644
--- a/csharp/src/ProtocolBuffers/Descriptors/IndexedDescriptorBase.cs
+++ b/csharp/src/ProtocolBuffers/Descriptors/IndexedDescriptorBase.cs
@@ -29,9 +29,9 @@
// 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.
-using Google.ProtocolBuffers.DescriptorProtos;
+using Google.Protobuf.DescriptorProtos;
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Base class for descriptors which are also indexed. This is all of them other than
diff --git a/csharp/src/ProtocolBuffers/Descriptors/MappedType.cs b/csharp/src/ProtocolBuffers/Descriptors/MappedType.cs
index 0a555307..97eed683 100644
--- a/csharp/src/ProtocolBuffers/Descriptors/MappedType.cs
+++ b/csharp/src/ProtocolBuffers/Descriptors/MappedType.cs
@@ -30,7 +30,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Type as it's mapped onto a .NET type.
diff --git a/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs
index c00711b9..f0ac70ff 100644
--- a/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs
+++ b/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs
@@ -31,9 +31,9 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Collections.Generic;
-using Google.ProtocolBuffers.DescriptorProtos;
+using Google.Protobuf.DescriptorProtos;
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Describes a message type.
@@ -53,33 +53,33 @@ namespace Google.ProtocolBuffers.Descriptors
{
containingType = parent;
- oneofs = DescriptorUtil.ConvertAndMakeReadOnly(proto.OneofDeclList,
+ oneofs = DescriptorUtil.ConvertAndMakeReadOnly(proto.OneofDecl,
(oneof, index) =>
new OneofDescriptor(oneof, file, this, index));
- nestedTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.NestedTypeList,
+ nestedTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.NestedType,
(type, index) =>
new MessageDescriptor(type, file, this, index));
- enumTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.EnumTypeList,
+ enumTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.EnumType,
(type, index) =>
new EnumDescriptor(type, file, this, index));
// TODO(jonskeet): Sort fields first?
- fields = DescriptorUtil.ConvertAndMakeReadOnly(proto.FieldList,
+ fields = DescriptorUtil.ConvertAndMakeReadOnly(proto.Field,
(field, index) =>
new FieldDescriptor(field, file, this, index, false));
- extensions = DescriptorUtil.ConvertAndMakeReadOnly(proto.ExtensionList,
+ extensions = DescriptorUtil.ConvertAndMakeReadOnly(proto.Extension,
(field, index) =>
new FieldDescriptor(field, file, this, index, true));
- for (int i = 0; i < proto.OneofDeclCount; i++)
+ 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.FieldCount; i++)
+ for (int i = 0; i< proto.Field.Count; i++)
{
OneofDescriptor oneofDescriptor = fields[i].ContainingOneof;
if (oneofDescriptor != null)
@@ -151,7 +151,7 @@ namespace Google.ProtocolBuffers.Descriptors
/// </summary>
public bool IsExtensionNumber(int number)
{
- foreach (DescriptorProto.Types.ExtensionRange range in Proto.ExtensionRangeList)
+ foreach (DescriptorProto.Types.ExtensionRange range in Proto.ExtensionRange)
{
if (range.Start <= number && number < range.End)
{
@@ -244,7 +244,7 @@ namespace Google.ProtocolBuffers.Descriptors
// If the type allows extensions, an extension with message type could contain
// required fields, so we have to be conservative and assume such an
// extension exists.
- if (Proto.ExtensionRangeCount != 0)
+ if (Proto.ExtensionRange.Count != 0)
{
return true;
}
@@ -275,22 +275,22 @@ namespace Google.ProtocolBuffers.Descriptors
for (int i = 0; i < nestedTypes.Count; i++)
{
- nestedTypes[i].ReplaceProto(newProto.GetNestedType(i));
+ nestedTypes[i].ReplaceProto(newProto.NestedType[i]);
}
for (int i = 0; i < enumTypes.Count; i++)
{
- enumTypes[i].ReplaceProto(newProto.GetEnumType(i));
+ enumTypes[i].ReplaceProto(newProto.EnumType[i]);
}
for (int i = 0; i < fields.Count; i++)
{
- fields[i].ReplaceProto(newProto.GetField(i));
+ fields[i].ReplaceProto(newProto.Field[i]);
}
for (int i = 0; i < extensions.Count; i++)
{
- extensions[i].ReplaceProto(newProto.GetExtension(i));
+ extensions[i].ReplaceProto(newProto.Extension[i]);
}
}
}
diff --git a/csharp/src/ProtocolBuffers/Descriptors/MethodDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/MethodDescriptor.cs
index f9ede245..c7c5f9db 100644
--- a/csharp/src/ProtocolBuffers/Descriptors/MethodDescriptor.cs
+++ b/csharp/src/ProtocolBuffers/Descriptors/MethodDescriptor.cs
@@ -29,9 +29,9 @@
// 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.
-using Google.ProtocolBuffers.DescriptorProtos;
+using Google.Protobuf.DescriptorProtos;
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Describes a single method in a service.
diff --git a/csharp/src/ProtocolBuffers/Descriptors/OneofDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/OneofDescriptor.cs
index aa62853b..8997cb63 100644
--- a/csharp/src/ProtocolBuffers/Descriptors/OneofDescriptor.cs
+++ b/csharp/src/ProtocolBuffers/Descriptors/OneofDescriptor.cs
@@ -31,9 +31,9 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using Google.ProtocolBuffers.DescriptorProtos;
+using Google.Protobuf.DescriptorProtos;
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
public sealed class OneofDescriptor
{
diff --git a/csharp/src/ProtocolBuffers/Descriptors/PackageDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/PackageDescriptor.cs
index 02549f9c..f63b9cf4 100644
--- a/csharp/src/ProtocolBuffers/Descriptors/PackageDescriptor.cs
+++ b/csharp/src/ProtocolBuffers/Descriptors/PackageDescriptor.cs
@@ -30,7 +30,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Represents a package in the symbol table. We use PackageDescriptors
diff --git a/csharp/src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs
index 417c0838..52a5cb8f 100644
--- a/csharp/src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs
+++ b/csharp/src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs
@@ -31,9 +31,9 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Collections.Generic;
-using Google.ProtocolBuffers.DescriptorProtos;
+using Google.Protobuf.DescriptorProtos;
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Describes a service type.
@@ -45,7 +45,7 @@ namespace Google.ProtocolBuffers.Descriptors
public ServiceDescriptor(ServiceDescriptorProto proto, FileDescriptor file, int index)
: base(proto, file, ComputeFullName(file, null, proto.Name), index)
{
- methods = DescriptorUtil.ConvertAndMakeReadOnly(proto.MethodList,
+ methods = DescriptorUtil.ConvertAndMakeReadOnly(proto.Method,
(method, i) => new MethodDescriptor(method, file, this, i));
file.DescriptorPool.AddSymbol(this);
@@ -82,7 +82,7 @@ namespace Google.ProtocolBuffers.Descriptors
base.ReplaceProto(newProto);
for (int i = 0; i < methods.Count; i++)
{
- methods[i].ReplaceProto(newProto.GetMethod(i));
+ methods[i].ReplaceProto(newProto.Method[i]);
}
}
}