diff --git a/Makefile.am b/Makefile.am index c8e730f94e..3c0cea5ac5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -99,7 +99,6 @@ csharp_EXTRA_DIST= \ csharp/src/Google.Protobuf/Collections/RepeatedField.cs \ csharp/src/Google.Protobuf/FieldCodec.cs \ csharp/src/Google.Protobuf/FrameworkPortability.cs \ - csharp/src/Google.Protobuf/Freezable.cs \ csharp/src/Google.Protobuf/Google.Protobuf.csproj \ csharp/src/Google.Protobuf/Google.Protobuf.nuspec \ csharp/src/Google.Protobuf/IMessage.cs \ diff --git a/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs b/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs index 46d3bd9aaa..c62ac046b6 100644 --- a/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs +++ b/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs @@ -45,53 +45,6 @@ namespace Google.Protobuf.Collections /// public class MapFieldTest { - // Protobuf-specific tests - [Test] - public void Freeze_FreezesMessages() - { - var message = new ForeignMessage { C = 20 }; - var map = new MapField { { "x", message } }; - map.Freeze(); - Assert.IsTrue(message.IsFrozen); - } - - [Test] - public void Freeze_Idempotent() - { - var message = new ForeignMessage { C = 20 }; - var map = new MapField { { "x", message } }; - Assert.IsFalse(map.IsFrozen); - map.Freeze(); - Assert.IsTrue(message.IsFrozen); - map.Freeze(); - Assert.IsTrue(message.IsFrozen); - } - - [Test] - public void Freeze_PreventsMutation() - { - var map = new MapField(); - map.Freeze(); - Assert.IsTrue(map.IsFrozen); - Assert.IsTrue(map.IsReadOnly); - ICollection> collection = map; - Assert.Throws(() => map["x"] = "y"); - Assert.Throws(() => map.Add("x", "y")); - Assert.Throws(() => map.Remove("x")); - Assert.Throws(() => map.Clear()); - Assert.Throws(() => collection.Add(NewKeyValuePair("x", "y"))); - Assert.Throws(() => collection.Remove(NewKeyValuePair("x", "y"))); - } - - [Test] - public void Clone_ReturnsNonFrozen() - { - var map = new MapField(); - map.Freeze(); - var clone = map.Clone(); - clone.Add("x", "y"); - } - [Test] public void Clone_ClonesMessages() { @@ -422,10 +375,6 @@ namespace Google.Protobuf.Collections dictionary.Remove("x"); Assert.AreEqual(0, dictionary.Count); Assert.Throws(() => dictionary.Remove(null)); - - map.Freeze(); - // Call should fail even though it clearly doesn't contain 5 as a key. - Assert.Throws(() => dictionary.Remove(5)); } [Test] @@ -449,8 +398,6 @@ namespace Google.Protobuf.Collections var map = new MapField { { "x", "y" } }; IDictionary dictionary = map; Assert.IsFalse(dictionary.IsFixedSize); - map.Freeze(); - Assert.IsTrue(dictionary.IsFixedSize); } [Test] @@ -504,9 +451,6 @@ namespace Google.Protobuf.Collections Assert.Throws(() => dictionary["x"] = 5); Assert.Throws(() => dictionary[null] = "z"); Assert.Throws(() => dictionary["x"] = null); - map.Freeze(); - // Note: Not InvalidOperationException. - Assert.Throws(() => dictionary["a"] = "c"); } [Test] diff --git a/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs b/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs index 25be7731f4..33c4e10c88 100644 --- a/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs +++ b/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs @@ -193,44 +193,10 @@ namespace Google.Protobuf.Collections Assert.Throws(() => list[2] = "bad"); } - [Test] - public void Freeze_FreezesElements() - { - var list = new RepeatedField { new TestAllTypes() }; - Assert.IsFalse(list[0].IsFrozen); - list.Freeze(); - Assert.IsTrue(list[0].IsFrozen); - } - - [Test] - public void Freeze_PreventsMutations() - { - var list = new RepeatedField { 0 }; - list.Freeze(); - Assert.Throws(() => list.Add(1)); - Assert.Throws(() => list[0] = 1); - Assert.Throws(() => list.Clear()); - Assert.Throws(() => list.RemoveAt(0)); - Assert.Throws(() => list.Remove(0)); - Assert.Throws(() => list.Insert(0, 0)); - } - - [Test] - public void Freeze_ReportsFrozen() - { - var list = new RepeatedField { 0 }; - Assert.IsFalse(list.IsFrozen); - Assert.IsFalse(list.IsReadOnly); - list.Freeze(); - Assert.IsTrue(list.IsFrozen); - Assert.IsTrue(list.IsReadOnly); - } - [Test] public void Clone_ReturnsMutable() { var list = new RepeatedField { 0 }; - list.Freeze(); var clone = list.Clone(); clone[0] = 1; } @@ -585,8 +551,6 @@ namespace Google.Protobuf.Collections var field = new RepeatedField { "first", "second" }; IList list = field; Assert.IsFalse(list.IsFixedSize); - field.Freeze(); - Assert.IsTrue(list.IsFixedSize); } [Test] diff --git a/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs b/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs index 528a4023fc..dfaac48cd0 100644 --- a/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs +++ b/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs @@ -503,23 +503,6 @@ namespace Google.Protobuf Assert.AreNotEqual(original, clone); } - [Test] - public void Freeze() - { - var frozen = new TestAllTypes(); - frozen.Freeze(); - Assert.IsTrue(frozen.IsFrozen); - - Assert.Throws(() => frozen.ClearOneofField()); - Assert.Throws(() => frozen.SingleInt32 = 0); - Assert.Throws(() => frozen.SingleNestedMessage = null); - Assert.Throws(() => frozen.SingleNestedEnum = 0); - Assert.Throws(() => frozen.OneofString = null); - Assert.Throws(() => frozen.OneofUint32 = 0U); - Assert.Throws(() => frozen.RepeatedDouble.Add(0.0)); - Assert.Throws(() => frozen.RepeatedNestedMessage.Add(new TestAllTypes.Types.NestedMessage())); - } - [Test] public void OneofProperties() { diff --git a/csharp/src/Google.Protobuf/Collections/MapField.cs b/csharp/src/Google.Protobuf/Collections/MapField.cs index 68f2f1cc2a..0f7227c212 100644 --- a/csharp/src/Google.Protobuf/Collections/MapField.cs +++ b/csharp/src/Google.Protobuf/Collections/MapField.cs @@ -50,7 +50,7 @@ namespace Google.Protobuf.Collections /// /// Key type in the map. Must be a type supported by Protocol Buffer map keys. /// Value type in the map. Must be a type supported by Protocol Buffers. - public sealed class MapField : IDeepCloneable>, IFreezable, IDictionary, IEquatable>, IDictionary + public sealed class MapField : IDeepCloneable>, IDictionary, IEquatable>, IDictionary { // TODO: Don't create the map/list until we have an entry. (Assume many maps will be empty.) private readonly bool allowNullValues; @@ -119,7 +119,6 @@ namespace Google.Protobuf.Collections public bool Remove(TKey key) { - this.CheckMutable(); ThrowHelper.ThrowIfNull(key, "key"); LinkedListNode> node; if (map.TryGetValue(key, out node)) @@ -169,7 +168,6 @@ namespace Google.Protobuf.Collections { ThrowHelper.ThrowIfNull(value, "value"); } - this.CheckMutable(); LinkedListNode> node; var pair = new KeyValuePair(key, value); if (map.TryGetValue(key, out node)) @@ -214,7 +212,6 @@ namespace Google.Protobuf.Collections public void Clear() { - this.CheckMutable(); list.Clear(); map.Clear(); } @@ -233,7 +230,6 @@ namespace Google.Protobuf.Collections bool ICollection>.Remove(KeyValuePair item) { - this.CheckMutable(); if (item.Key == null) { throw new ArgumentException("Key is null", "item"); @@ -260,31 +256,6 @@ namespace Google.Protobuf.Collections public int Count { get { return list.Count; } } public bool IsReadOnly { get { return frozen; } } - public void Freeze() - { - if (IsFrozen) - { - return; - } - frozen = true; - // Only values can be frozen, as all the key types are simple. - // Everything can be done in-place, as we're just freezing objects. - if (typeof(IFreezable).IsAssignableFrom(typeof(TValue))) - { - for (var node = list.First; node != null; node = node.Next) - { - var pair = node.Value; - IFreezable freezableValue = pair.Value as IFreezable; - if (freezableValue != null) - { - freezableValue.Freeze(); - } - } - } - } - - public bool IsFrozen { get { return frozen; } } - public override bool Equals(object other) { return Equals(other as MapField); @@ -405,7 +376,6 @@ namespace Google.Protobuf.Collections void IDictionary.Remove(object key) { ThrowHelper.ThrowIfNull(key, "key"); - this.CheckMutable(); if (!(key is TKey)) { return; @@ -420,7 +390,7 @@ namespace Google.Protobuf.Collections temp.CopyTo(array, index); } - bool IDictionary.IsFixedSize { get { return IsFrozen; } } + bool IDictionary.IsFixedSize { get { return false; } } ICollection IDictionary.Keys { get { return (ICollection)Keys; } } diff --git a/csharp/src/Google.Protobuf/Collections/RepeatedField.cs b/csharp/src/Google.Protobuf/Collections/RepeatedField.cs index ccd1a9bb3f..e7fc0a3f81 100644 --- a/csharp/src/Google.Protobuf/Collections/RepeatedField.cs +++ b/csharp/src/Google.Protobuf/Collections/RepeatedField.cs @@ -43,7 +43,7 @@ namespace Google.Protobuf.Collections /// restrictions (no null values) and capabilities (deep cloning and freezing). /// /// The element type of the repeated field. - public sealed class RepeatedField : IList, IList, IDeepCloneable>, IEquatable>, IFreezable + public sealed class RepeatedField : IList, IList, IDeepCloneable>, IEquatable> { private static readonly T[] EmptyArray = new T[0]; private const int MinArraySize = 8; @@ -190,21 +190,6 @@ namespace Google.Protobuf.Collections } } - public bool IsFrozen { get { return frozen; } } - - public void Freeze() - { - frozen = true; - IFreezable[] freezableArray = array as IFreezable[]; - if (freezableArray != null) - { - for (int i = 0; i < count; i++) - { - freezableArray[i].Freeze(); - } - } - } - private void EnsureSize(int size) { if (array.Length < size) @@ -223,14 +208,12 @@ namespace Google.Protobuf.Collections { throw new ArgumentNullException("item"); } - this.CheckMutable(); EnsureSize(count + 1); array[count++] = item; } public void Clear() { - this.CheckMutable(); array = EmptyArray; count = 0; } @@ -247,7 +230,6 @@ namespace Google.Protobuf.Collections public bool Remove(T item) { - this.CheckMutable(); int index = IndexOf(item); if (index == -1) { @@ -261,7 +243,7 @@ namespace Google.Protobuf.Collections public int Count { get { return count; } } - public bool IsReadOnly { get { return IsFrozen; } } + public bool IsReadOnly { get { return false; } } public void Add(RepeatedField values) { @@ -269,7 +251,6 @@ namespace Google.Protobuf.Collections { throw new ArgumentNullException("values"); } - this.CheckMutable(); EnsureSize(count + values.count); // We know that all the values will be valid, because it's a RepeatedField. Array.Copy(values.array, 0, array, count, values.count); @@ -282,7 +263,6 @@ namespace Google.Protobuf.Collections { throw new ArgumentNullException("values"); } - this.CheckMutable(); // TODO: Check for ICollection and get the Count? foreach (T item in values) { @@ -372,7 +352,6 @@ namespace Google.Protobuf.Collections { throw new ArgumentOutOfRangeException("index"); } - this.CheckMutable(); EnsureSize(count + 1); Array.Copy(array, index, array, index + 1, count - index); array[index] = item; @@ -385,7 +364,6 @@ namespace Google.Protobuf.Collections { throw new ArgumentOutOfRangeException("index"); } - this.CheckMutable(); Array.Copy(array, index + 1, array, index, count - index - 1); count--; array[count] = default(T); @@ -407,7 +385,6 @@ namespace Google.Protobuf.Collections { throw new ArgumentOutOfRangeException("index"); } - this.CheckMutable(); if (value == null) { throw new ArgumentNullException("value"); @@ -417,7 +394,7 @@ namespace Google.Protobuf.Collections } #region Explicit interface implementation for IList and ICollection. - bool IList.IsFixedSize { get { return IsFrozen; } } + bool IList.IsFixedSize { get { return false; } } void ICollection.CopyTo(Array array, int index) { diff --git a/csharp/src/Google.Protobuf/Freezable.cs b/csharp/src/Google.Protobuf/Freezable.cs deleted file mode 100644 index d16e1b4272..0000000000 --- a/csharp/src/Google.Protobuf/Freezable.cs +++ /dev/null @@ -1,58 +0,0 @@ -#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; - -namespace Google.Protobuf -{ - /// - /// Extension methods for types. - /// - public static class Freezable - { - /// - /// Throws an if - /// is frozen. - /// - /// - /// This is a convenience methods that freezable types can call before all - /// mutations, to protect frozen objects. - /// - public static void CheckMutable(this IFreezable target) - { - if (target.IsFrozen) - { - throw new InvalidOperationException("Attempt to mutate frozen object"); - } - } - } -} diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index b1f20816da..b141e4342c 100644 --- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj +++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj @@ -64,7 +64,6 @@ - diff --git a/csharp/src/Google.Protobuf/IMessage.cs b/csharp/src/Google.Protobuf/IMessage.cs index d179c38607..60c6f8c317 100644 --- a/csharp/src/Google.Protobuf/IMessage.cs +++ b/csharp/src/Google.Protobuf/IMessage.cs @@ -79,7 +79,7 @@ namespace Google.Protobuf /// the implementation class. /// /// The message type. - public interface IMessage : IMessage, IEquatable, IDeepCloneable, IFreezable where T : IMessage + public interface IMessage : IMessage, IEquatable, IDeepCloneable where T : IMessage { /// /// Merges the given message into this one. @@ -97,10 +97,6 @@ namespace Google.Protobuf /// Additionally, due to the type constraint on T in , /// it is simpler to keep this as a separate interface. /// - /// - /// Freezable types which implement this interface should always return a mutable clone, - /// even if the original object is frozen. - /// /// /// The type itself, returned by the method. public interface IDeepCloneable @@ -111,32 +107,4 @@ namespace Google.Protobuf /// A deep clone of this object. T Clone(); } - - /// - /// Provides a mechanism for freezing a message (or repeated field collection) - /// to make it immutable. - /// - /// - /// Implementations are under no obligation to make this thread-safe: if a freezable - /// type instance is shared between threads before being frozen, and one thread then - /// freezes it, it is possible for other threads to make changes during the freezing - /// operation and also to observe stale values for mutated fields. Objects should be - /// frozen before being made available to other threads. - /// - public interface IFreezable - { - /// - /// Freezes this object. - /// - /// - /// If the object is already frozen, this method has no effect. - /// - void Freeze(); - - /// - /// Returns whether or not this object is frozen (and therefore immutable). - /// - /// true if this object is frozen; false otherwise. - bool IsFrozen { get; } - } } diff --git a/src/google/protobuf/compiler/csharp/csharp_map_field.cc b/src/google/protobuf/compiler/csharp/csharp_map_field.cc index cba24a59a3..f84ad6f7ac 100644 --- a/src/google/protobuf/compiler/csharp/csharp_map_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_map_field.cc @@ -129,8 +129,6 @@ void MapFieldGenerator::GenerateCloningCode(io::Printer* printer) { } void MapFieldGenerator::GenerateFreezingCode(io::Printer* printer) { - printer->Print(variables_, - "$name$_.Freeze();\n"); } } // namespace csharp diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 81d6274174..86ef0489e2 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -190,7 +190,6 @@ void MessageGenerator::Generate(io::Printer* printer) { " get { return $name$Case_; }\n" "}\n\n" "public void Clear$property_name$() {\n" - " pb::Freezable.CheckMutable(this);\n" " $name$Case_ = $property_name$OneofCase.None;\n" " $name$_ = null;\n" "}\n\n"); @@ -293,33 +292,6 @@ void MessageGenerator::GenerateCloningCode(io::Printer* printer) { } void MessageGenerator::GenerateFreezingCode(io::Printer* printer) { - map vars; - vars["class_name"] = class_name(); - printer->Print( - "public void Freeze() {\n" - " if (IsFrozen) {\n" - " return;\n" - " }\n" - " _frozen = true;\n"); - printer->Indent(); - // Freeze non-oneof fields first (only messages and repeated fields will actually generate any code) - for (int i = 0; i < descriptor_->field_count(); i++) { - if (!descriptor_->field(i)->containing_oneof()) { - scoped_ptr generator( - CreateFieldGeneratorInternal(descriptor_->field(i))); - generator->GenerateFreezingCode(printer); - } - } - - // For each oneof, if the value is freezable, freeze it. We don't actually need to know which type it was. - for (int i = 0; i < descriptor_->oneof_decl_count(); ++i) { - vars["name"] = UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), false); - printer->Print(vars, - "if ($name$_ is IFreezable) ((IFreezable) $name$_).Freeze();\n"); - } - - printer->Outdent(); - printer->Print("}\n\n"); } void MessageGenerator::GenerateFrameworkMethods(io::Printer* printer) { diff --git a/src/google/protobuf/compiler/csharp/csharp_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_message_field.cc index d2c3a88b48..4f576cd1f6 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.cc @@ -67,7 +67,6 @@ void MessageFieldGenerator::GenerateMembers(io::Printer* printer) { "$access_level$ $type_name$ $property_name$ {\n" " get { return $name$_; }\n" " set {\n" - " pb::Freezable.CheckMutable(this);\n" " $name$_ = value;\n" " }\n" "}\n"); @@ -134,8 +133,6 @@ void MessageFieldGenerator::GenerateCloningCode(io::Printer* printer) { } void MessageFieldGenerator::GenerateFreezingCode(io::Printer* printer) { - printer->Print(variables_, - "if ($has_property_check$) $property_name$.Freeze();\n"); } void MessageFieldGenerator::GenerateCodecCode(io::Printer* printer) { @@ -161,7 +158,6 @@ void MessageOneofFieldGenerator::GenerateMembers(io::Printer* printer) { "$access_level$ $type_name$ $property_name$ {\n" " get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : null; }\n" " set {\n" - " pb::Freezable.CheckMutable(this);\n" " $oneof_name$_ = value;\n" " $oneof_name$Case_ = value == null ? $oneof_property_name$OneofCase.None : $oneof_property_name$OneofCase.$property_name$;\n" " }\n" diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc index 4454ef029f..80f4a92d02 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc @@ -73,8 +73,7 @@ void PrimitiveFieldGenerator::GenerateMembers(io::Printer* printer) { variables_, "$access_level$ $type_name$ $property_name$ {\n" " get { return $name$_; }\n" - " set {\n" - " pb::Freezable.CheckMutable(this);\n"); + " set {\n"); if (is_value_type) { printer->Print( variables_, @@ -176,8 +175,7 @@ void PrimitiveOneofFieldGenerator::GenerateMembers(io::Printer* printer) { variables_, "$access_level$ $type_name$ $property_name$ {\n" " get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : $default_value$; }\n" - " set {\n" - " pb::Freezable.CheckMutable(this);\n"); + " set {\n"); if (is_value_type) { printer->Print( variables_, diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc index c1b29e2b6c..625631dfc8 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc @@ -117,8 +117,6 @@ void RepeatedEnumFieldGenerator::GenerateCloningCode(io::Printer* printer) { } void RepeatedEnumFieldGenerator::GenerateFreezingCode(io::Printer* printer) { - printer->Print(variables_, - "$name$_.Freeze();\n"); } } // namespace csharp diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc index d939fc7983..7fbab681fb 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc @@ -132,8 +132,6 @@ void RepeatedMessageFieldGenerator::GenerateCloningCode(io::Printer* printer) { } void RepeatedMessageFieldGenerator::GenerateFreezingCode(io::Printer* printer) { - printer->Print(variables_, - "$name$_.Freeze();\n"); } } // namespace csharp diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc index 5b5d9b3d9b..1163ce73d4 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc @@ -115,8 +115,6 @@ void RepeatedPrimitiveFieldGenerator::GenerateCloningCode(io::Printer* printer) } void RepeatedPrimitiveFieldGenerator::GenerateFreezingCode(io::Printer* printer) { - printer->Print(variables_, - "$name$_.Freeze();\n"); } } // namespace csharp diff --git a/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc b/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc index 75ef5e50c2..44f832bfca 100644 --- a/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc @@ -76,7 +76,6 @@ void WrapperFieldGenerator::GenerateMembers(io::Printer* printer) { "$access_level$ $type_name$ $property_name$ {\n" " get { return $name$_; }\n" " set {\n" - " pb::Freezable.CheckMutable(this);\n" " $name$_ = value;\n" " }\n" "}\n"); @@ -172,7 +171,6 @@ void WrapperOneofFieldGenerator::GenerateMembers(io::Printer* printer) { "$access_level$ $type_name$ $property_name$ {\n" " get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : ($type_name$) null; }\n" " set {\n" - " pb::Freezable.CheckMutable(this);\n" " $oneof_name$_ = value;\n" " $oneof_name$Case_ = value == null ? $oneof_property_name$OneofCase.None : $oneof_property_name$OneofCase.$property_name$;\n" " }\n"