Commit 4cf9e3c6 authored by Jon Skeet's avatar Jon Skeet

Fix property special-casing

parent 1d131c98
...@@ -22,9 +22,8 @@ extend FieldOptions { ...@@ -22,9 +22,8 @@ extend FieldOptions {
message CSharpFieldOptions { message CSharpFieldOptions {
// Provides the ability to override the name of the property // Provides the ability to override the name of the property
// generated for this field. This does not currently work with // generated for this field. This is applied to all properties
// messages optimised for reflection, and is only applied to the // and methods to do with this field, including HasFoo, FooCount,
// actual property rather than associated methods. (Careful // FooList etc.
// consideration needed here...)
optional string property_name = 1; optional string property_name = 1;
} }
...@@ -10,10 +10,10 @@ namespace Google.ProtocolBuffers.ProtoGen { ...@@ -10,10 +10,10 @@ namespace Google.ProtocolBuffers.ProtoGen {
} }
public void GenerateMembers(TextGenerator writer) { public void GenerateMembers(TextGenerator writer) {
writer.WriteLine("private bool has{0};", CapitalizedName); writer.WriteLine("private bool has{0};", PropertyName);
writer.WriteLine("private {0} {1}_ = {2};", TypeName, Name, DefaultValue); writer.WriteLine("private {0} {1}_ = {2};", TypeName, Name, DefaultValue);
writer.WriteLine("public bool Has{0} {{", CapitalizedName); writer.WriteLine("public bool Has{0} {{", PropertyName);
writer.WriteLine(" get {{ return has{0}; }}", CapitalizedName); writer.WriteLine(" get {{ return has{0}; }}", PropertyName);
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public {0} {1} {{", TypeName, PropertyName); writer.WriteLine("public {0} {1} {{", TypeName, PropertyName);
writer.WriteLine(" get {{ return {0}_; }}", Name); writer.WriteLine(" get {{ return {0}_; }}", Name);
...@@ -21,27 +21,27 @@ namespace Google.ProtocolBuffers.ProtoGen { ...@@ -21,27 +21,27 @@ namespace Google.ProtocolBuffers.ProtoGen {
} }
public void GenerateBuilderMembers(TextGenerator writer) { public void GenerateBuilderMembers(TextGenerator writer) {
writer.WriteLine("public bool Has{0} {{", CapitalizedName); writer.WriteLine("public bool Has{0} {{", PropertyName);
writer.WriteLine(" get {{ return result.Has{0}; }}", CapitalizedName); writer.WriteLine(" get {{ return result.Has{0}; }}", PropertyName);
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public {0} {1} {{", TypeName, PropertyName); writer.WriteLine("public {0} {1} {{", TypeName, PropertyName);
writer.WriteLine(" get {{ return result.{0}; }}", PropertyName); writer.WriteLine(" get {{ return result.{0}; }}", PropertyName);
writer.WriteLine(" set {{ Set{0}(value); }}", CapitalizedName); writer.WriteLine(" set {{ Set{0}(value); }}", PropertyName);
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public Builder Set{0}({1} value) {{", CapitalizedName, TypeName); writer.WriteLine("public Builder Set{0}({1} value) {{", PropertyName, TypeName);
writer.WriteLine(" result.has{0} = true;", CapitalizedName); writer.WriteLine(" result.has{0} = true;", PropertyName);
writer.WriteLine(" result.{0}_ = value;", Name); writer.WriteLine(" result.{0}_ = value;", Name);
writer.WriteLine(" return this;"); writer.WriteLine(" return this;");
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public Builder Clear{0}() {{", CapitalizedName); writer.WriteLine("public Builder Clear{0}() {{", PropertyName);
writer.WriteLine(" result.has{0} = false;", CapitalizedName); writer.WriteLine(" result.has{0} = false;", PropertyName);
writer.WriteLine(" result.{0}_ = {1};", Name, DefaultValue); writer.WriteLine(" result.{0}_ = {1};", Name, DefaultValue);
writer.WriteLine(" return this;"); writer.WriteLine(" return this;");
writer.WriteLine("}"); writer.WriteLine("}");
} }
public void GenerateMergingCode(TextGenerator writer) { public void GenerateMergingCode(TextGenerator writer) {
writer.WriteLine("if (other.Has{0}) {{", CapitalizedName); writer.WriteLine("if (other.Has{0}) {{", PropertyName);
writer.WriteLine(" {0} = other.{0};", PropertyName); writer.WriteLine(" {0} = other.{0};", PropertyName);
writer.WriteLine("}"); writer.WriteLine("}");
} }
...@@ -61,13 +61,13 @@ namespace Google.ProtocolBuffers.ProtoGen { ...@@ -61,13 +61,13 @@ namespace Google.ProtocolBuffers.ProtoGen {
} }
public void GenerateSerializationCode(TextGenerator writer) { public void GenerateSerializationCode(TextGenerator writer) {
writer.WriteLine("if (Has{0}) {{", CapitalizedName); writer.WriteLine("if (Has{0}) {{", PropertyName);
writer.WriteLine(" output.WriteEnum({0}, (int) {1});", Number, PropertyName); writer.WriteLine(" output.WriteEnum({0}, (int) {1});", Number, PropertyName);
writer.WriteLine("}"); writer.WriteLine("}");
} }
public void GenerateSerializedSizeCode(TextGenerator writer) { public void GenerateSerializedSizeCode(TextGenerator writer) {
writer.WriteLine("if (Has{0}) {{", CapitalizedName); writer.WriteLine("if (Has{0}) {{", PropertyName);
writer.WriteLine(" size += pb::CodedOutputStream.ComputeEnumSize({0}, (int) {1});", Number, PropertyName); writer.WriteLine(" size += pb::CodedOutputStream.ComputeEnumSize({0}, (int) {1});", Number, PropertyName);
writer.WriteLine("}"); writer.WriteLine("}");
} }
......
...@@ -79,10 +79,6 @@ namespace Google.ProtocolBuffers.ProtoGen { ...@@ -79,10 +79,6 @@ namespace Google.ProtocolBuffers.ProtoGen {
} }
} }
protected string CapitalizedName {
get { return NameHelpers.UnderscoresToPascalCase(GetFieldName(Descriptor)); }
}
protected string Name { protected string Name {
get { return NameHelpers.UnderscoresToCamelCase(GetFieldName(Descriptor)); } get { return NameHelpers.UnderscoresToCamelCase(GetFieldName(Descriptor)); }
} }
......
...@@ -8,54 +8,54 @@ namespace Google.ProtocolBuffers.ProtoGen { ...@@ -8,54 +8,54 @@ namespace Google.ProtocolBuffers.ProtoGen {
} }
public void GenerateMembers(TextGenerator writer) { public void GenerateMembers(TextGenerator writer) {
writer.WriteLine("private bool has{0};", CapitalizedName); writer.WriteLine("private bool has{0};", PropertyName);
writer.WriteLine("private {0} {1}_ = {2};", TypeName, Name, DefaultValue); writer.WriteLine("private {0} {1}_ = {2};", TypeName, Name, DefaultValue);
writer.WriteLine("public bool Has{0} {{", CapitalizedName); writer.WriteLine("public bool Has{0} {{", PropertyName);
writer.WriteLine(" get {{ return has{0}; }}", CapitalizedName); writer.WriteLine(" get {{ return has{0}; }}", PropertyName);
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public {0} {1} {{", TypeName, CapitalizedName); writer.WriteLine("public {0} {1} {{", TypeName, PropertyName);
writer.WriteLine(" get {{ return {0}_; }}", Name); writer.WriteLine(" get {{ return {0}_; }}", Name);
writer.WriteLine("}"); writer.WriteLine("}");
} }
public void GenerateBuilderMembers(TextGenerator writer) { public void GenerateBuilderMembers(TextGenerator writer) {
writer.WriteLine("public bool Has{0} {{", CapitalizedName); writer.WriteLine("public bool Has{0} {{", PropertyName);
writer.WriteLine(" get {{ return result.Has{0}; }}", CapitalizedName); writer.WriteLine(" get {{ return result.Has{0}; }}", PropertyName);
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public {0} {1} {{", TypeName, CapitalizedName); writer.WriteLine("public {0} {1} {{", TypeName, PropertyName);
writer.WriteLine(" get {{ return result.{0}; }}", CapitalizedName); writer.WriteLine(" get {{ return result.{0}; }}", PropertyName);
writer.WriteLine(" set {{ Set{0}(value); }}", CapitalizedName); writer.WriteLine(" set {{ Set{0}(value); }}", PropertyName);
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public Builder Set{0}({1} value) {{", CapitalizedName, TypeName); writer.WriteLine("public Builder Set{0}({1} value) {{", PropertyName, TypeName);
writer.WriteLine(" result.has{0} = true;", CapitalizedName); writer.WriteLine(" result.has{0} = true;", PropertyName);
writer.WriteLine(" result.{0}_ = value;", Name); writer.WriteLine(" result.{0}_ = value;", Name);
writer.WriteLine(" return this;"); writer.WriteLine(" return this;");
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public Builder Set{0}({1}.Builder builderForValue) {{", CapitalizedName, TypeName); writer.WriteLine("public Builder Set{0}({1}.Builder builderForValue) {{", PropertyName, TypeName);
writer.WriteLine(" result.has{0} = true;", CapitalizedName); writer.WriteLine(" result.has{0} = true;", PropertyName);
writer.WriteLine(" result.{0}_ = builderForValue.Build();", Name); writer.WriteLine(" result.{0}_ = builderForValue.Build();", Name);
writer.WriteLine(" return this;"); writer.WriteLine(" return this;");
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public Builder Merge{0}({1} value) {{", CapitalizedName, TypeName); writer.WriteLine("public Builder Merge{0}({1} value) {{", PropertyName, TypeName);
writer.WriteLine(" if (result.Has{0} &&", CapitalizedName); writer.WriteLine(" if (result.Has{0} &&", PropertyName);
writer.WriteLine(" result.{0}_ != {1}) {{", Name, DefaultValue); writer.WriteLine(" result.{0}_ != {1}) {{", Name, DefaultValue);
writer.WriteLine(" result.{0}_ = {1}.CreateBuilder(result.{0}_).MergeFrom(value).BuildPartial();", Name, TypeName); writer.WriteLine(" result.{0}_ = {1}.CreateBuilder(result.{0}_).MergeFrom(value).BuildPartial();", Name, TypeName);
writer.WriteLine(" } else {"); writer.WriteLine(" } else {");
writer.WriteLine(" result.{0}_ = value;", Name); writer.WriteLine(" result.{0}_ = value;", Name);
writer.WriteLine(" }"); writer.WriteLine(" }");
writer.WriteLine(" result.has{0} = true;", CapitalizedName); writer.WriteLine(" result.has{0} = true;", PropertyName);
writer.WriteLine(" return this;"); writer.WriteLine(" return this;");
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public Builder Clear{0}() {{", CapitalizedName); writer.WriteLine("public Builder Clear{0}() {{", PropertyName);
writer.WriteLine(" result.has{0} = false;", CapitalizedName); writer.WriteLine(" result.has{0} = false;", PropertyName);
writer.WriteLine(" result.{0}_ = {1};", Name, DefaultValue); writer.WriteLine(" result.{0}_ = {1};", Name, DefaultValue);
writer.WriteLine(" return this;"); writer.WriteLine(" return this;");
writer.WriteLine("}"); writer.WriteLine("}");
} }
public void GenerateMergingCode(TextGenerator writer) { public void GenerateMergingCode(TextGenerator writer) {
writer.WriteLine("if (other.Has{0}) {{", CapitalizedName); writer.WriteLine("if (other.Has{0}) {{", PropertyName);
writer.WriteLine(" Merge{0}(other.{0});", CapitalizedName); writer.WriteLine(" Merge{0}(other.{0});", PropertyName);
writer.WriteLine("}"); writer.WriteLine("}");
} }
...@@ -65,27 +65,27 @@ namespace Google.ProtocolBuffers.ProtoGen { ...@@ -65,27 +65,27 @@ namespace Google.ProtocolBuffers.ProtoGen {
public void GenerateParsingCode(TextGenerator writer) { public void GenerateParsingCode(TextGenerator writer) {
writer.WriteLine("{0}.Builder subBuilder = {0}.CreateBuilder();", TypeName); writer.WriteLine("{0}.Builder subBuilder = {0}.CreateBuilder();", TypeName);
writer.WriteLine("if (Has{0}) {{", CapitalizedName); writer.WriteLine("if (Has{0}) {{", PropertyName);
writer.WriteLine(" subBuilder.MergeFrom({0});", CapitalizedName); writer.WriteLine(" subBuilder.MergeFrom({0});", PropertyName);
writer.WriteLine("}"); writer.WriteLine("}");
if (Descriptor.FieldType == FieldType.Group) { if (Descriptor.FieldType == FieldType.Group) {
writer.WriteLine("input.ReadGroup({0}, subBuilder, extensionRegistry);", Number); writer.WriteLine("input.ReadGroup({0}, subBuilder, extensionRegistry);", Number);
} else { } else {
writer.WriteLine("input.ReadMessage(subBuilder, extensionRegistry);"); writer.WriteLine("input.ReadMessage(subBuilder, extensionRegistry);");
} }
writer.WriteLine("{0} = subBuilder.BuildPartial();", CapitalizedName); writer.WriteLine("{0} = subBuilder.BuildPartial();", PropertyName);
} }
public void GenerateSerializationCode(TextGenerator writer) { public void GenerateSerializationCode(TextGenerator writer) {
writer.WriteLine("if (Has{0}) {{", CapitalizedName); writer.WriteLine("if (Has{0}) {{", PropertyName);
writer.WriteLine(" output.Write{0}({1}, {2});", MessageOrGroup, Number, CapitalizedName); writer.WriteLine(" output.Write{0}({1}, {2});", MessageOrGroup, Number, PropertyName);
writer.WriteLine("}"); writer.WriteLine("}");
} }
public void GenerateSerializedSizeCode(TextGenerator writer) { public void GenerateSerializedSizeCode(TextGenerator writer) {
writer.WriteLine("if (Has{0}) {{", CapitalizedName); writer.WriteLine("if (Has{0}) {{", PropertyName);
writer.WriteLine(" size += pb::CodedOutputStream.Compute{0}Size({1}, {2});", writer.WriteLine(" size += pb::CodedOutputStream.Compute{0}Size({1}, {2});",
MessageOrGroup, Number, CapitalizedName); MessageOrGroup, Number, PropertyName);
writer.WriteLine("}"); writer.WriteLine("}");
} }
} }
......
...@@ -51,7 +51,7 @@ namespace Google.ProtocolBuffers.ProtoGen { ...@@ -51,7 +51,7 @@ namespace Google.ProtocolBuffers.ProtoGen {
FullClassName, identifier); FullClassName, identifier);
writer.Print(" new string[] { "); writer.Print(" new string[] { ");
foreach (FieldDescriptor field in Descriptor.Fields) { foreach (FieldDescriptor field in Descriptor.Fields) {
writer.Write("\"{0}\", ", NameHelpers.UnderscoresToPascalCase(GetFieldName(field))); writer.Write("\"{0}\", ", field.CSharpOptions.PropertyName);
} }
writer.WriteLine("});"); writer.WriteLine("});");
...@@ -415,7 +415,7 @@ namespace Google.ProtocolBuffers.ProtoGen { ...@@ -415,7 +415,7 @@ namespace Google.ProtocolBuffers.ProtoGen {
// "has" fields into a single bitfield. // "has" fields into a single bitfield.
foreach (FieldDescriptor field in Descriptor.Fields) { foreach (FieldDescriptor field in Descriptor.Fields) {
if (field.IsRequired) { if (field.IsRequired) {
writer.WriteLine("if (!has{0}) return false;", NameHelpers.UnderscoresToPascalCase(field.Name)); writer.WriteLine("if (!has{0}) return false;", field.CSharpOptions.PropertyName);
} }
} }
......
...@@ -10,10 +10,10 @@ namespace Google.ProtocolBuffers.ProtoGen { ...@@ -10,10 +10,10 @@ namespace Google.ProtocolBuffers.ProtoGen {
} }
public void GenerateMembers(TextGenerator writer) { public void GenerateMembers(TextGenerator writer) {
writer.WriteLine("private bool has{0};", CapitalizedName); writer.WriteLine("private bool has{0};", PropertyName);
writer.WriteLine("private {0} {1}_ = {2};", TypeName, Name, DefaultValue); writer.WriteLine("private {0} {1}_ = {2};", TypeName, Name, DefaultValue);
writer.WriteLine("public bool Has{0} {{", CapitalizedName); writer.WriteLine("public bool Has{0} {{", PropertyName);
writer.WriteLine(" get {{ return has{0}; }}", CapitalizedName); writer.WriteLine(" get {{ return has{0}; }}", PropertyName);
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public {0} {1} {{", TypeName, PropertyName); writer.WriteLine("public {0} {1} {{", TypeName, PropertyName);
writer.WriteLine(" get {{ return {0}_; }}", Name); writer.WriteLine(" get {{ return {0}_; }}", Name);
...@@ -21,27 +21,27 @@ namespace Google.ProtocolBuffers.ProtoGen { ...@@ -21,27 +21,27 @@ namespace Google.ProtocolBuffers.ProtoGen {
} }
public void GenerateBuilderMembers(TextGenerator writer) { public void GenerateBuilderMembers(TextGenerator writer) {
writer.WriteLine("public bool Has{0} {{", CapitalizedName); writer.WriteLine("public bool Has{0} {{", PropertyName);
writer.WriteLine(" get {{ return result.Has{0}; }}", CapitalizedName); writer.WriteLine(" get {{ return result.Has{0}; }}", PropertyName);
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public {0} {1} {{", TypeName, PropertyName); writer.WriteLine("public {0} {1} {{", TypeName, PropertyName);
writer.WriteLine(" get {{ return result.{0}; }}", PropertyName); writer.WriteLine(" get {{ return result.{0}; }}", PropertyName);
writer.WriteLine(" set {{ Set{0}(value); }}", CapitalizedName); writer.WriteLine(" set {{ Set{0}(value); }}", PropertyName);
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public Builder Set{0}({1} value) {{", CapitalizedName, TypeName); writer.WriteLine("public Builder Set{0}({1} value) {{", PropertyName, TypeName);
writer.WriteLine(" result.has{0} = true;", CapitalizedName); writer.WriteLine(" result.has{0} = true;", PropertyName);
writer.WriteLine(" result.{0}_ = value;", Name); writer.WriteLine(" result.{0}_ = value;", Name);
writer.WriteLine(" return this;"); writer.WriteLine(" return this;");
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public Builder Clear{0}() {{", CapitalizedName); writer.WriteLine("public Builder Clear{0}() {{", PropertyName);
writer.WriteLine(" result.has{0} = false;", CapitalizedName); writer.WriteLine(" result.has{0} = false;", PropertyName);
writer.WriteLine(" result.{0}_ = {1};", Name, DefaultValue); writer.WriteLine(" result.{0}_ = {1};", Name, DefaultValue);
writer.WriteLine(" return this;"); writer.WriteLine(" return this;");
writer.WriteLine("}"); writer.WriteLine("}");
} }
public void GenerateMergingCode(TextGenerator writer) { public void GenerateMergingCode(TextGenerator writer) {
writer.WriteLine("if (other.Has{0}) {{", CapitalizedName); writer.WriteLine("if (other.Has{0}) {{", PropertyName);
writer.WriteLine(" {0} = other.{0};", PropertyName); writer.WriteLine(" {0} = other.{0};", PropertyName);
writer.WriteLine("}"); writer.WriteLine("}");
} }
...@@ -55,13 +55,13 @@ namespace Google.ProtocolBuffers.ProtoGen { ...@@ -55,13 +55,13 @@ namespace Google.ProtocolBuffers.ProtoGen {
} }
public void GenerateSerializationCode(TextGenerator writer) { public void GenerateSerializationCode(TextGenerator writer) {
writer.WriteLine("if (Has{0}) {{", CapitalizedName); writer.WriteLine("if (Has{0}) {{", PropertyName);
writer.WriteLine(" output.Write{0}({1}, {2});", CapitalizedTypeName, Number, PropertyName); writer.WriteLine(" output.Write{0}({1}, {2});", CapitalizedTypeName, Number, PropertyName);
writer.WriteLine("}"); writer.WriteLine("}");
} }
public void GenerateSerializedSizeCode(TextGenerator writer) { public void GenerateSerializedSizeCode(TextGenerator writer) {
writer.WriteLine("if (Has{0}) {{", CapitalizedName); writer.WriteLine("if (Has{0}) {{", PropertyName);
writer.WriteLine(" size += pb::CodedOutputStream.Compute{0}Size({1}, {2});", writer.WriteLine(" size += pb::CodedOutputStream.Compute{0}Size({1}, {2});",
CapitalizedTypeName, Number, PropertyName); CapitalizedTypeName, Number, PropertyName);
writer.WriteLine("}"); writer.WriteLine("}");
......
...@@ -12,44 +12,44 @@ namespace Google.ProtocolBuffers.ProtoGen { ...@@ -12,44 +12,44 @@ namespace Google.ProtocolBuffers.ProtoGen {
public void GenerateMembers(TextGenerator writer) { public void GenerateMembers(TextGenerator writer) {
writer.WriteLine("private pbc::PopsicleList<{0}> {1}_ = new pbc::PopsicleList<{0}>();", TypeName, Name); writer.WriteLine("private pbc::PopsicleList<{0}> {1}_ = new pbc::PopsicleList<{0}>();", TypeName, Name);
writer.WriteLine("public scg::IList<{0}> {1}List {{", TypeName, CapitalizedName); writer.WriteLine("public scg::IList<{0}> {1}List {{", TypeName, PropertyName);
writer.WriteLine(" get {{ return pbc::Lists.AsReadOnly({0}_); }}", Name); writer.WriteLine(" get {{ return pbc::Lists.AsReadOnly({0}_); }}", Name);
writer.WriteLine("}"); writer.WriteLine("}");
// TODO(jonskeet): Redundant API calls? Possibly - include for portability though. Maybe create an option. // TODO(jonskeet): Redundant API calls? Possibly - include for portability though. Maybe create an option.
writer.WriteLine("public int {0}Count {{", CapitalizedName); writer.WriteLine("public int {0}Count {{", PropertyName);
writer.WriteLine(" get {{ return {0}_.Count; }}", Name); writer.WriteLine(" get {{ return {0}_.Count; }}", Name);
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public {0} Get{1}(int index) {{", TypeName, CapitalizedName); writer.WriteLine("public {0} Get{1}(int index) {{", TypeName, PropertyName);
writer.WriteLine(" return {0}_[index];", Name); writer.WriteLine(" return {0}_[index];", Name);
writer.WriteLine("}"); writer.WriteLine("}");
} }
public void GenerateBuilderMembers(TextGenerator writer) { public void GenerateBuilderMembers(TextGenerator writer) {
// Note: We can return the original list here, because we make it unmodifiable when we build // Note: We can return the original list here, because we make it unmodifiable when we build
writer.WriteLine("public scg::IList<{0}> {1}List {{", TypeName, CapitalizedName); writer.WriteLine("public scg::IList<{0}> {1}List {{", TypeName, PropertyName);
writer.WriteLine(" get {{ return result.{0}_; }}", Name); writer.WriteLine(" get {{ return result.{0}_; }}", Name);
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public int {0}Count {{", CapitalizedName); writer.WriteLine("public int {0}Count {{", PropertyName);
writer.WriteLine(" get {{ return result.{0}Count; }}", CapitalizedName); writer.WriteLine(" get {{ return result.{0}Count; }}", PropertyName);
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public {0} Get{1}(int index) {{", TypeName, CapitalizedName); writer.WriteLine("public {0} Get{1}(int index) {{", TypeName, PropertyName);
writer.WriteLine(" return result.Get{0}(index);", CapitalizedName); writer.WriteLine(" return result.Get{0}(index);", PropertyName);
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public Builder Set{0}(int index, {1} value) {{", CapitalizedName, TypeName); writer.WriteLine("public Builder Set{0}(int index, {1} value) {{", PropertyName, TypeName);
writer.WriteLine(" result.{0}_[index] = value;", Name); writer.WriteLine(" result.{0}_[index] = value;", Name);
writer.WriteLine(" return this;"); writer.WriteLine(" return this;");
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public Builder Add{0}({1} value) {{", CapitalizedName, TypeName); writer.WriteLine("public Builder Add{0}({1} value) {{", PropertyName, TypeName);
writer.WriteLine(" result.{0}_.Add(value);", Name, TypeName); writer.WriteLine(" result.{0}_.Add(value);", Name, TypeName);
writer.WriteLine(" return this;"); writer.WriteLine(" return this;");
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public Builder AddRange{0}(scg::IEnumerable<{1}> values) {{", CapitalizedName, TypeName); writer.WriteLine("public Builder AddRange{0}(scg::IEnumerable<{1}> values) {{", PropertyName, TypeName);
writer.WriteLine(" base.AddRange(values, result.{0}_);", Name); writer.WriteLine(" base.AddRange(values, result.{0}_);", Name);
writer.WriteLine(" return this;"); writer.WriteLine(" return this;");
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public Builder Clear{0}() {{", CapitalizedName); writer.WriteLine("public Builder Clear{0}() {{", PropertyName);
writer.WriteLine(" result.{0}_.Clear();", Name); writer.WriteLine(" result.{0}_.Clear();", Name);
writer.WriteLine(" return this;"); writer.WriteLine(" return this;");
writer.WriteLine("}"); writer.WriteLine("}");
...@@ -71,18 +71,18 @@ namespace Google.ProtocolBuffers.ProtoGen { ...@@ -71,18 +71,18 @@ namespace Google.ProtocolBuffers.ProtoGen {
writer.WriteLine("if (!global::System.Enum.IsDefined(typeof({0}), rawValue)) {{", TypeName); writer.WriteLine("if (!global::System.Enum.IsDefined(typeof({0}), rawValue)) {{", TypeName);
writer.WriteLine(" unknownFields.MergeVarintField({0}, (ulong) rawValue);", Number); writer.WriteLine(" unknownFields.MergeVarintField({0}, (ulong) rawValue);", Number);
writer.WriteLine("} else {"); writer.WriteLine("} else {");
writer.WriteLine(" Add{0}(({1}) rawValue);", CapitalizedName, TypeName); writer.WriteLine(" Add{0}(({1}) rawValue);", PropertyName, TypeName);
writer.WriteLine("}"); writer.WriteLine("}");
} }
public void GenerateSerializationCode(TextGenerator writer) { public void GenerateSerializationCode(TextGenerator writer) {
writer.WriteLine("foreach ({0} element in {1}List) {{", TypeName, CapitalizedName); writer.WriteLine("foreach ({0} element in {1}List) {{", TypeName, PropertyName);
writer.WriteLine(" output.WriteEnum({0}, (int) element);", Number); writer.WriteLine(" output.WriteEnum({0}, (int) element);", Number);
writer.WriteLine("}"); writer.WriteLine("}");
} }
public void GenerateSerializedSizeCode(TextGenerator writer) { public void GenerateSerializedSizeCode(TextGenerator writer) {
writer.WriteLine("foreach ({0} element in {1}List) {{", TypeName, CapitalizedName); writer.WriteLine("foreach ({0} element in {1}List) {{", TypeName, PropertyName);
writer.WriteLine(" size += pb::CodedOutputStream.ComputeEnumSize({0}, (int) element);", Number); writer.WriteLine(" size += pb::CodedOutputStream.ComputeEnumSize({0}, (int) element);", Number);
writer.WriteLine("}"); writer.WriteLine("}");
} }
......
...@@ -12,54 +12,54 @@ namespace Google.ProtocolBuffers.ProtoGen { ...@@ -12,54 +12,54 @@ namespace Google.ProtocolBuffers.ProtoGen {
public void GenerateMembers(TextGenerator writer) { public void GenerateMembers(TextGenerator writer) {
writer.WriteLine("private pbc::PopsicleList<{0}> {1}_ = new pbc::PopsicleList<{0}>();", TypeName, Name); writer.WriteLine("private pbc::PopsicleList<{0}> {1}_ = new pbc::PopsicleList<{0}>();", TypeName, Name);
writer.WriteLine("public scg::IList<{0}> {1}List {{", TypeName, CapitalizedName); writer.WriteLine("public scg::IList<{0}> {1}List {{", TypeName, PropertyName);
writer.WriteLine(" get {{ return {0}_; }}", Name); writer.WriteLine(" get {{ return {0}_; }}", Name);
writer.WriteLine("}"); writer.WriteLine("}");
// TODO(jonskeet): Redundant API calls? Possibly - include for portability though. Maybe create an option. // TODO(jonskeet): Redundant API calls? Possibly - include for portability though. Maybe create an option.
writer.WriteLine("public int {0}Count {{", CapitalizedName); writer.WriteLine("public int {0}Count {{", PropertyName);
writer.WriteLine(" get {{ return {0}_.Count; }}", Name); writer.WriteLine(" get {{ return {0}_.Count; }}", Name);
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public {0} Get{1}(int index) {{", TypeName, CapitalizedName); writer.WriteLine("public {0} Get{1}(int index) {{", TypeName, PropertyName);
writer.WriteLine(" return {0}_[index];", Name); writer.WriteLine(" return {0}_[index];", Name);
writer.WriteLine("}"); writer.WriteLine("}");
} }
public void GenerateBuilderMembers(TextGenerator writer) { public void GenerateBuilderMembers(TextGenerator writer) {
// Note: We can return the original list here, because we make it unmodifiable when we build // Note: We can return the original list here, because we make it unmodifiable when we build
writer.WriteLine("public scg::IList<{0}> {1}List {{", TypeName, CapitalizedName); writer.WriteLine("public scg::IList<{0}> {1}List {{", TypeName, PropertyName);
writer.WriteLine(" get {{ return result.{0}_; }}", Name); writer.WriteLine(" get {{ return result.{0}_; }}", Name);
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public int {0}Count {{", CapitalizedName); writer.WriteLine("public int {0}Count {{", PropertyName);
writer.WriteLine(" get {{ return result.{0}Count; }}", CapitalizedName); writer.WriteLine(" get {{ return result.{0}Count; }}", PropertyName);
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public {0} Get{1}(int index) {{", TypeName, CapitalizedName); writer.WriteLine("public {0} Get{1}(int index) {{", TypeName, PropertyName);
writer.WriteLine(" return result.Get{0}(index);", CapitalizedName); writer.WriteLine(" return result.Get{0}(index);", PropertyName);
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public Builder Set{0}(int index, {1} value) {{", CapitalizedName, TypeName); writer.WriteLine("public Builder Set{0}(int index, {1} value) {{", PropertyName, TypeName);
writer.WriteLine(" result.{0}_[index] = value;", Name); writer.WriteLine(" result.{0}_[index] = value;", Name);
writer.WriteLine(" return this;"); writer.WriteLine(" return this;");
writer.WriteLine("}"); writer.WriteLine("}");
// Extra overload for builder (just on messages) // Extra overload for builder (just on messages)
writer.WriteLine("public Builder Set{0}(int index, {1}.Builder builderForValue) {{", CapitalizedName, TypeName); writer.WriteLine("public Builder Set{0}(int index, {1}.Builder builderForValue) {{", PropertyName, TypeName);
writer.WriteLine(" result.{0}_[index] = builderForValue.Build();", Name); writer.WriteLine(" result.{0}_[index] = builderForValue.Build();", Name);
writer.WriteLine(" return this;"); writer.WriteLine(" return this;");
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public Builder Add{0}({1} value) {{", CapitalizedName, TypeName); writer.WriteLine("public Builder Add{0}({1} value) {{", PropertyName, TypeName);
writer.WriteLine(" result.{0}_.Add(value);", Name, TypeName); writer.WriteLine(" result.{0}_.Add(value);", Name, TypeName);
writer.WriteLine(" return this;"); writer.WriteLine(" return this;");
writer.WriteLine("}"); writer.WriteLine("}");
// Extra overload for builder (just on messages) // Extra overload for builder (just on messages)
writer.WriteLine("public Builder Add{0}({1}.Builder builderForValue) {{", CapitalizedName, TypeName); writer.WriteLine("public Builder Add{0}({1}.Builder builderForValue) {{", PropertyName, TypeName);
writer.WriteLine(" result.{0}_.Add(builderForValue.Build());", Name); writer.WriteLine(" result.{0}_.Add(builderForValue.Build());", Name);
writer.WriteLine(" return this;"); writer.WriteLine(" return this;");
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public Builder AddRange{0}(scg::IEnumerable<{1}> values) {{", CapitalizedName, TypeName); writer.WriteLine("public Builder AddRange{0}(scg::IEnumerable<{1}> values) {{", PropertyName, TypeName);
writer.WriteLine(" base.AddRange(values, result.{0}_);", Name); writer.WriteLine(" base.AddRange(values, result.{0}_);", Name);
writer.WriteLine(" return this;"); writer.WriteLine(" return this;");
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public Builder Clear{0}() {{", CapitalizedName); writer.WriteLine("public Builder Clear{0}() {{", PropertyName);
writer.WriteLine(" result.{0}_.Clear();", Name); writer.WriteLine(" result.{0}_.Clear();", Name);
writer.WriteLine(" return this;"); writer.WriteLine(" return this;");
writer.WriteLine("}"); writer.WriteLine("}");
...@@ -82,17 +82,17 @@ namespace Google.ProtocolBuffers.ProtoGen { ...@@ -82,17 +82,17 @@ namespace Google.ProtocolBuffers.ProtoGen {
} else { } else {
writer.WriteLine("input.ReadMessage(subBuilder, extensionRegistry);"); writer.WriteLine("input.ReadMessage(subBuilder, extensionRegistry);");
} }
writer.WriteLine("Add{0}(subBuilder.BuildPartial());", CapitalizedName); writer.WriteLine("Add{0}(subBuilder.BuildPartial());", PropertyName);
} }
public void GenerateSerializationCode(TextGenerator writer) { public void GenerateSerializationCode(TextGenerator writer) {
writer.WriteLine("foreach ({0} element in {1}List) {{", TypeName, CapitalizedName); writer.WriteLine("foreach ({0} element in {1}List) {{", TypeName, PropertyName);
writer.WriteLine(" output.Write{0}({1}, element);", MessageOrGroup, Number); writer.WriteLine(" output.Write{0}({1}, element);", MessageOrGroup, Number);
writer.WriteLine("}"); writer.WriteLine("}");
} }
public void GenerateSerializedSizeCode(TextGenerator writer) { public void GenerateSerializedSizeCode(TextGenerator writer) {
writer.WriteLine("foreach ({0} element in {1}List) {{", TypeName, CapitalizedName); writer.WriteLine("foreach ({0} element in {1}List) {{", TypeName, PropertyName);
writer.WriteLine(" size += pb::CodedOutputStream.Compute{0}Size({1}, element);", MessageOrGroup, Number); writer.WriteLine(" size += pb::CodedOutputStream.Compute{0}Size({1}, element);", MessageOrGroup, Number);
writer.WriteLine("}"); writer.WriteLine("}");
} }
......
...@@ -12,44 +12,44 @@ namespace Google.ProtocolBuffers.ProtoGen { ...@@ -12,44 +12,44 @@ namespace Google.ProtocolBuffers.ProtoGen {
public void GenerateMembers(TextGenerator writer) { public void GenerateMembers(TextGenerator writer) {
writer.WriteLine("private pbc::PopsicleList<{0}> {1}_ = new pbc::PopsicleList<{0}>();", TypeName, Name); writer.WriteLine("private pbc::PopsicleList<{0}> {1}_ = new pbc::PopsicleList<{0}>();", TypeName, Name);
writer.WriteLine("public scg::IList<{0}> {1}List {{", TypeName, CapitalizedName); writer.WriteLine("public scg::IList<{0}> {1}List {{", TypeName, PropertyName);
writer.WriteLine(" get {{ return pbc::Lists.AsReadOnly({0}_); }}", Name); writer.WriteLine(" get {{ return pbc::Lists.AsReadOnly({0}_); }}", Name);
writer.WriteLine("}"); writer.WriteLine("}");
// TODO(jonskeet): Redundant API calls? Possibly - include for portability though. Maybe create an option. // TODO(jonskeet): Redundant API calls? Possibly - include for portability though. Maybe create an option.
writer.WriteLine("public int {0}Count {{", CapitalizedName); writer.WriteLine("public int {0}Count {{", PropertyName);
writer.WriteLine(" get {{ return {0}_.Count; }}", Name); writer.WriteLine(" get {{ return {0}_.Count; }}", Name);
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public {0} Get{1}(int index) {{", TypeName, CapitalizedName); writer.WriteLine("public {0} Get{1}(int index) {{", TypeName, PropertyName);
writer.WriteLine(" return {0}_[index];", Name); writer.WriteLine(" return {0}_[index];", Name);
writer.WriteLine("}"); writer.WriteLine("}");
} }
public void GenerateBuilderMembers(TextGenerator writer) { public void GenerateBuilderMembers(TextGenerator writer) {
// Note: We can return the original list here, because we make it unmodifiable when we build // Note: We can return the original list here, because we make it unmodifiable when we build
writer.WriteLine("public scg::IList<{0}> {1}List {{", TypeName, CapitalizedName); writer.WriteLine("public scg::IList<{0}> {1}List {{", TypeName, PropertyName);
writer.WriteLine(" get {{ return result.{0}_; }}", Name); writer.WriteLine(" get {{ return result.{0}_; }}", Name);
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public int {0}Count {{", CapitalizedName); writer.WriteLine("public int {0}Count {{", PropertyName);
writer.WriteLine(" get {{ return result.{0}Count; }}", CapitalizedName); writer.WriteLine(" get {{ return result.{0}Count; }}", PropertyName);
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public {0} Get{1}(int index) {{", TypeName, CapitalizedName); writer.WriteLine("public {0} Get{1}(int index) {{", TypeName, PropertyName);
writer.WriteLine(" return result.Get{0}(index);", CapitalizedName); writer.WriteLine(" return result.Get{0}(index);", PropertyName);
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public Builder Set{0}(int index, {1} value) {{", CapitalizedName, TypeName); writer.WriteLine("public Builder Set{0}(int index, {1} value) {{", PropertyName, TypeName);
writer.WriteLine(" result.{0}_[index] = value;", Name); writer.WriteLine(" result.{0}_[index] = value;", Name);
writer.WriteLine(" return this;"); writer.WriteLine(" return this;");
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public Builder Add{0}({1} value) {{", CapitalizedName, TypeName); writer.WriteLine("public Builder Add{0}({1} value) {{", PropertyName, TypeName);
writer.WriteLine(" result.{0}_.Add(value);", Name, TypeName); writer.WriteLine(" result.{0}_.Add(value);", Name, TypeName);
writer.WriteLine(" return this;"); writer.WriteLine(" return this;");
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public Builder AddRange{0}(scg::IEnumerable<{1}> values) {{", CapitalizedName, TypeName); writer.WriteLine("public Builder AddRange{0}(scg::IEnumerable<{1}> values) {{", PropertyName, TypeName);
writer.WriteLine(" base.AddRange(values, result.{0}_);", Name); writer.WriteLine(" base.AddRange(values, result.{0}_);", Name);
writer.WriteLine(" return this;"); writer.WriteLine(" return this;");
writer.WriteLine("}"); writer.WriteLine("}");
writer.WriteLine("public Builder Clear{0}() {{", CapitalizedName); writer.WriteLine("public Builder Clear{0}() {{", PropertyName);
writer.WriteLine(" result.{0}_.Clear();", Name); writer.WriteLine(" result.{0}_.Clear();", Name);
writer.WriteLine(" return this;"); writer.WriteLine(" return this;");
writer.WriteLine("}"); writer.WriteLine("}");
...@@ -66,17 +66,17 @@ namespace Google.ProtocolBuffers.ProtoGen { ...@@ -66,17 +66,17 @@ namespace Google.ProtocolBuffers.ProtoGen {
} }
public void GenerateParsingCode(TextGenerator writer) { public void GenerateParsingCode(TextGenerator writer) {
writer.WriteLine("Add{0}(input.Read{1}());", CapitalizedName, CapitalizedTypeName); writer.WriteLine("Add{0}(input.Read{1}());", PropertyName, CapitalizedTypeName);
} }
public void GenerateSerializationCode(TextGenerator writer) { public void GenerateSerializationCode(TextGenerator writer) {
writer.WriteLine("foreach ({0} element in {1}List) {{", TypeName, CapitalizedName); writer.WriteLine("foreach ({0} element in {1}List) {{", TypeName, PropertyName);
writer.WriteLine(" output.Write{0}({1}, element);", CapitalizedTypeName, Number); writer.WriteLine(" output.Write{0}({1}, element);", CapitalizedTypeName, Number);
writer.WriteLine("}"); writer.WriteLine("}");
} }
public void GenerateSerializedSizeCode(TextGenerator writer) { public void GenerateSerializedSizeCode(TextGenerator writer) {
writer.WriteLine("foreach ({0} element in {1}List) {{", TypeName, CapitalizedName); writer.WriteLine("foreach ({0} element in {1}List) {{", TypeName, PropertyName);
writer.WriteLine(" size += pb::CodedOutputStream.Compute{0}Size({1}, element);", CapitalizedTypeName, Number); writer.WriteLine(" size += pb::CodedOutputStream.Compute{0}Size({1}, element);", CapitalizedTypeName, Number);
writer.WriteLine("}"); writer.WriteLine("}");
} }
......
...@@ -185,7 +185,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -185,7 +185,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
= internal__static_google_protobuf_UninterpretedOption__Descriptor.NestedTypes[0]; = 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 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 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 #endregion
} }
#region Messages #region Messages
...@@ -5517,10 +5517,10 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -5517,10 +5517,10 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable; } get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable; }
} }
private bool hasNamePart; private bool hasNamePart_;
private string namePart_ = ""; private string namePart_ = "";
public bool HasNamePart { public bool HasNamePart_ {
get { return hasNamePart; } get { return hasNamePart_; }
} }
public string NamePart_ { public string NamePart_ {
get { return namePart_; } get { return namePart_; }
...@@ -5537,14 +5537,14 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -5537,14 +5537,14 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public override bool IsInitialized { public override bool IsInitialized {
get { get {
if (!hasNamePart) return false; if (!hasNamePart_) return false;
if (!hasIsExtension) return false; if (!hasIsExtension) return false;
return true; return true;
} }
} }
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
if (HasNamePart) { if (HasNamePart_) {
output.WriteString(1, NamePart_); output.WriteString(1, NamePart_);
} }
if (HasIsExtension) { if (HasIsExtension) {
...@@ -5560,7 +5560,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -5560,7 +5560,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
if (size != -1) return size; if (size != -1) return size;
size = 0; size = 0;
if (HasNamePart) { if (HasNamePart_) {
size += pb::CodedOutputStream.ComputeStringSize(1, NamePart_); size += pb::CodedOutputStream.ComputeStringSize(1, NamePart_);
} }
if (HasIsExtension) { if (HasIsExtension) {
...@@ -5648,7 +5648,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -5648,7 +5648,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public override Builder MergeFrom(NamePart other) { public override Builder MergeFrom(NamePart other) {
if (other == NamePart.DefaultInstance) return this; if (other == NamePart.DefaultInstance) return this;
if (other.HasNamePart) { if (other.HasNamePart_) {
NamePart_ = other.NamePart_; NamePart_ = other.NamePart_;
} }
if (other.HasIsExtension) { if (other.HasIsExtension) {
...@@ -5691,20 +5691,20 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -5691,20 +5691,20 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
} }
public bool HasNamePart { public bool HasNamePart_ {
get { return result.HasNamePart; } get { return result.HasNamePart_; }
} }
public string NamePart_ { public string NamePart_ {
get { return result.NamePart_; } get { return result.NamePart_; }
set { SetNamePart(value); } set { SetNamePart_(value); }
} }
public Builder SetNamePart(string value) { public Builder SetNamePart_(string value) {
result.hasNamePart = true; result.hasNamePart_ = true;
result.namePart_ = value; result.namePart_ = value;
return this; return this;
} }
public Builder ClearNamePart() { public Builder ClearNamePart_() {
result.hasNamePart = false; result.hasNamePart_ = false;
result.namePart_ = ""; result.namePart_ = "";
return this; return this;
} }
......
...@@ -54,6 +54,11 @@ namespace Google.ProtocolBuffers.FieldAccess { ...@@ -54,6 +54,11 @@ namespace Google.ProtocolBuffers.FieldAccess {
/// <summary> /// <summary>
/// Constructs a FieldAccessorTable for a particular message class. /// Constructs a FieldAccessorTable for a particular message class.
/// Only one FieldAccessorTable should be constructed per 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> /// </summary>
/// <param name="descriptor">The type's descriptor</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> /// <param name="propertyNames">The Pascal-case names of all the field-based properties in the message.</param>
......
...@@ -55,11 +55,9 @@ namespace Google.ProtocolBuffers.FieldAccess { ...@@ -55,11 +55,9 @@ namespace Google.ProtocolBuffers.FieldAccess {
} }
internal SinglePrimitiveAccessor(string name) { internal SinglePrimitiveAccessor(string name) {
PropertyInfo messageProperty = typeof(TMessage).GetProperty(name);
string propertyName = name == typeof(TMessage).Name ? name + "_" : name; PropertyInfo builderProperty = typeof(TBuilder).GetProperty(name);
PropertyInfo messageProperty = typeof(TMessage).GetProperty(propertyName); if (builderProperty == null) builderProperty = typeof(TBuilder).GetProperty(name);
PropertyInfo builderProperty = typeof(TBuilder).GetProperty(name); // FIXME!
if (builderProperty == null) builderProperty = typeof(TBuilder).GetProperty(propertyName); // FIXME!
PropertyInfo hasProperty = typeof(TMessage).GetProperty("Has" + name); PropertyInfo hasProperty = typeof(TMessage).GetProperty("Has" + name);
MethodInfo clearMethod = typeof(TBuilder).GetMethod("Clear" + name, Type.EmptyTypes); MethodInfo clearMethod = typeof(TBuilder).GetMethod("Clear" + name, Type.EmptyTypes);
if (messageProperty == null || builderProperty == null || hasProperty == null || clearMethod == null) { if (messageProperty == null || builderProperty == null || hasProperty == null || clearMethod == null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment