diff options
author | Jon Skeet <skeet@pobox.com> | 2008-11-24 11:11:28 +0000 |
---|---|---|
committer | Jon Skeet <skeet@pobox.com> | 2008-11-24 11:11:28 +0000 |
commit | 4cf9e3c619fbd00e47d5ec2503801814d3c8b4b6 (patch) | |
tree | bf193777749c47932f7ffde7e60b116d70484baa /src/ProtocolBuffers | |
parent | 1d131c98f058dc0b5e0ebef73602e09dc88fe075 (diff) | |
download | protobuf-4cf9e3c619fbd00e47d5ec2503801814d3c8b4b6.tar.gz protobuf-4cf9e3c619fbd00e47d5ec2503801814d3c8b4b6.tar.bz2 protobuf-4cf9e3c619fbd00e47d5ec2503801814d3c8b4b6.zip |
Fix property special-casing
Diffstat (limited to 'src/ProtocolBuffers')
3 files changed, 23 insertions, 20 deletions
diff --git a/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs index 4e3c6572..dcd10b8e 100644 --- a/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs +++ b/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs @@ -185,7 +185,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { = internal__static_google_protobuf_UninterpretedOption__Descriptor.NestedTypes[0]; internal static pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart.Builder> internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart.Builder>(internal__static_google_protobuf_UninterpretedOption_NamePart__Descriptor, - new string[] { "NamePart", "IsExtension", }); + new string[] { "NamePart_", "IsExtension", }); #endregion } #region Messages @@ -5517,10 +5517,10 @@ namespace Google.ProtocolBuffers.DescriptorProtos { get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable; } } - private bool hasNamePart; + private bool hasNamePart_; private string namePart_ = ""; - public bool HasNamePart { - get { return hasNamePart; } + public bool HasNamePart_ { + get { return hasNamePart_; } } public string NamePart_ { get { return namePart_; } @@ -5537,14 +5537,14 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override bool IsInitialized { get { - if (!hasNamePart) return false; + if (!hasNamePart_) return false; if (!hasIsExtension) return false; return true; } } public override void WriteTo(pb::CodedOutputStream output) { - if (HasNamePart) { + if (HasNamePart_) { output.WriteString(1, NamePart_); } if (HasIsExtension) { @@ -5560,7 +5560,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { if (size != -1) return size; size = 0; - if (HasNamePart) { + if (HasNamePart_) { size += pb::CodedOutputStream.ComputeStringSize(1, NamePart_); } if (HasIsExtension) { @@ -5648,7 +5648,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder MergeFrom(NamePart other) { if (other == NamePart.DefaultInstance) return this; - if (other.HasNamePart) { + if (other.HasNamePart_) { NamePart_ = other.NamePart_; } if (other.HasIsExtension) { @@ -5691,20 +5691,20 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } - public bool HasNamePart { - get { return result.HasNamePart; } + public bool HasNamePart_ { + get { return result.HasNamePart_; } } public string NamePart_ { get { return result.NamePart_; } - set { SetNamePart(value); } + set { SetNamePart_(value); } } - public Builder SetNamePart(string value) { - result.hasNamePart = true; + public Builder SetNamePart_(string value) { + result.hasNamePart_ = true; result.namePart_ = value; return this; } - public Builder ClearNamePart() { - result.hasNamePart = false; + public Builder ClearNamePart_() { + result.hasNamePart_ = false; result.namePart_ = ""; return this; } diff --git a/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs b/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs index 37405e60..3de0ff79 100644 --- a/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs +++ b/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs @@ -54,6 +54,11 @@ namespace Google.ProtocolBuffers.FieldAccess { /// <summary> /// Constructs a FieldAccessorTable for a particular message class. /// Only one FieldAccessorTable should be constructed per class. + /// The property names should all actually correspond with the field descriptor's + /// CSharpOptions.PropertyName property, but bootstrapping issues currently + /// prevent us from using that. This may be addressed at a future time, in which case + /// we can keep this constructor for backwards compatibility, just ignoring the parameter. + /// TODO(jonskeet): Make it so. /// </summary> /// <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> diff --git a/src/ProtocolBuffers/FieldAccess/SinglePrimitiveAccessor.cs b/src/ProtocolBuffers/FieldAccess/SinglePrimitiveAccessor.cs index 369a33d3..8b3153a1 100644 --- a/src/ProtocolBuffers/FieldAccess/SinglePrimitiveAccessor.cs +++ b/src/ProtocolBuffers/FieldAccess/SinglePrimitiveAccessor.cs @@ -55,11 +55,9 @@ namespace Google.ProtocolBuffers.FieldAccess { } internal SinglePrimitiveAccessor(string name) { - - string propertyName = name == typeof(TMessage).Name ? name + "_" : name; - PropertyInfo messageProperty = typeof(TMessage).GetProperty(propertyName); - PropertyInfo builderProperty = typeof(TBuilder).GetProperty(name); // FIXME! - if (builderProperty == null) builderProperty = typeof(TBuilder).GetProperty(propertyName); // FIXME! + PropertyInfo messageProperty = typeof(TMessage).GetProperty(name); + PropertyInfo builderProperty = typeof(TBuilder).GetProperty(name); + if (builderProperty == null) builderProperty = typeof(TBuilder).GetProperty(name); PropertyInfo hasProperty = typeof(TMessage).GetProperty("Has" + name); MethodInfo clearMethod = typeof(TBuilder).GetMethod("Clear" + name, Type.EmptyTypes); if (messageProperty == null || builderProperty == null || hasProperty == null || clearMethod == null) { |