diff options
author | csharptest <roger@csharptest.net> | 2011-06-03 12:58:14 -0500 |
---|---|---|
committer | rogerk <devnull@localhost> | 2011-06-03 12:58:14 -0500 |
commit | ffafdaa0f9a96d17d456c844a3e554512a5c121d (patch) | |
tree | da8bb40d40228429fa4b846bc7ef29c06e717e82 /src/ProtocolBuffers | |
parent | cc8d2aaa3a0b6bed6677fd488bc7deecd90f5604 (diff) | |
download | protobuf-ffafdaa0f9a96d17d456c844a3e554512a5c121d.tar.gz protobuf-ffafdaa0f9a96d17d456c844a3e554512a5c121d.tar.bz2 protobuf-ffafdaa0f9a96d17d456c844a3e554512a5c121d.zip |
Fully converted over to ICodedOutputStream for all WriteTo derivations
Diffstat (limited to 'src/ProtocolBuffers')
-rw-r--r-- | src/ProtocolBuffers/AbstractMessage.cs | 42 | ||||
-rw-r--r-- | src/ProtocolBuffers/AbstractMessageLite.cs | 6 | ||||
-rw-r--r-- | src/ProtocolBuffers/CodedOutputStream.cs | 14 | ||||
-rw-r--r-- | src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs | 8 | ||||
-rw-r--r-- | src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs | 76 | ||||
-rw-r--r-- | src/ProtocolBuffers/DynamicMessage.cs | 2 | ||||
-rw-r--r-- | src/ProtocolBuffers/ExtendableMessage.cs | 2 | ||||
-rw-r--r-- | src/ProtocolBuffers/ExtendableMessageLite.cs | 2 | ||||
-rw-r--r-- | src/ProtocolBuffers/FieldSet.cs | 48 | ||||
-rw-r--r-- | src/ProtocolBuffers/ICodedOutputStream.cs | 6 | ||||
-rw-r--r-- | src/ProtocolBuffers/IMessage.cs | 8 | ||||
-rw-r--r-- | src/ProtocolBuffers/IMessageLite.cs | 8 | ||||
-rw-r--r-- | src/ProtocolBuffers/ProtocolBuffersLite.csproj | 228 | ||||
-rw-r--r-- | src/ProtocolBuffers/UnknownField.cs | 6 | ||||
-rw-r--r-- | src/ProtocolBuffers/UnknownFieldSet.cs | 10 |
15 files changed, 231 insertions, 235 deletions
diff --git a/src/ProtocolBuffers/AbstractMessage.cs b/src/ProtocolBuffers/AbstractMessage.cs index 1e1ac1da..038fc0c5 100644 --- a/src/ProtocolBuffers/AbstractMessage.cs +++ b/src/ProtocolBuffers/AbstractMessage.cs @@ -138,7 +138,7 @@ namespace Google.ProtocolBuffers /// of the message before the data, then making sure you limit the input to
/// that size when receiving the data. Alternatively, use WriteDelimitedTo(Stream).
/// </remarks>
- public override void WriteTo(CodedOutputStream output)
+ public override void WriteTo(ICodedOutputStream output)
{
foreach (KeyValuePair<FieldDescriptor, object> entry in AllFields)
{
@@ -149,26 +149,28 @@ namespace Google.ProtocolBuffers // IEnumerable is the best we can do. (C# generics aren't covariant yet.)
IEnumerable valueList = (IEnumerable) entry.Value;
if (field.IsPacked)
- {
- output.WriteTag(field.FieldNumber, WireFormat.WireType.LengthDelimited);
- int dataSize = 0;
- foreach (object element in valueList)
- {
- dataSize += CodedOutputStream.ComputeFieldSizeNoTag(field.FieldType, element);
- }
- output.WriteRawVarint32((uint) dataSize);
- foreach (object element in valueList)
- {
- output.WriteFieldNoTag(field.FieldType, element);
- }
- }
+ output.WritePackedArray(field.FieldType, field.FieldNumber, field.Name, valueList);
+ //{
+ // output.WriteTag(field.FieldNumber, WireFormat.WireType.LengthDelimited);
+ // int dataSize = 0;
+ // foreach (object element in valueList)
+ // {
+ // dataSize += CodedOutputStream.ComputeFieldSizeNoTag(field.FieldType, element);
+ // }
+ // output.WriteRawVarint32((uint) dataSize);
+ // foreach (object element in valueList)
+ // {
+ // output.WriteFieldNoTag(field.FieldType, element);
+ // }
+ //}
else
- {
- foreach (object element in valueList)
- {
- output.WriteField(field.FieldType, field.FieldNumber, field.Name, element);
- }
- }
+ output.WriteArray(field.FieldType, field.FieldNumber, field.Name, valueList);
+ //{
+ // foreach (object element in valueList)
+ // {
+ // output.WriteField(field.FieldType, field.FieldNumber, field.Name, element);
+ // }
+ //}
}
else
{
diff --git a/src/ProtocolBuffers/AbstractMessageLite.cs b/src/ProtocolBuffers/AbstractMessageLite.cs index c98b2242..407238bf 100644 --- a/src/ProtocolBuffers/AbstractMessageLite.cs +++ b/src/ProtocolBuffers/AbstractMessageLite.cs @@ -55,7 +55,7 @@ namespace Google.ProtocolBuffers public abstract bool IsInitialized { get; }
- public abstract void WriteTo(CodedOutputStream output);
+ public abstract void WriteTo(ICodedOutputStream output);
public abstract int SerializedSize { get; }
@@ -71,7 +71,7 @@ namespace Google.ProtocolBuffers /// <summary>
/// Serializes the message to a ByteString. This is a trivial wrapper
- /// around WriteTo(CodedOutputStream).
+ /// around WriteTo(ICodedOutputStream).
/// </summary>
public ByteString ToByteString()
{
@@ -82,7 +82,7 @@ namespace Google.ProtocolBuffers /// <summary>
/// Serializes the message to a byte array. This is a trivial wrapper
- /// around WriteTo(CodedOutputStream).
+ /// around WriteTo(ICodedOutputStream).
/// </summary>
public byte[] ToByteArray()
{
diff --git a/src/ProtocolBuffers/CodedOutputStream.cs b/src/ProtocolBuffers/CodedOutputStream.cs index 7ebba9b0..39523c96 100644 --- a/src/ProtocolBuffers/CodedOutputStream.cs +++ b/src/ProtocolBuffers/CodedOutputStream.cs @@ -308,7 +308,7 @@ namespace Google.ProtocolBuffers WriteTag(WireFormat.MessageSetField.Item, WireFormat.WireType.EndGroup);
}
- public void WriteRawMessageSetExtension(int fieldNumber, ByteString value)
+ public void WriteMessageSetExtension(int fieldNumber, string fieldName, ByteString value)
{
WriteTag(WireFormat.MessageSetField.Item, WireFormat.WireType.StartGroup);
WriteUInt32(WireFormat.MessageSetField.TypeID, "type_id", (uint) fieldNumber);
@@ -316,18 +316,6 @@ namespace Google.ProtocolBuffers WriteTag(WireFormat.MessageSetField.Item, WireFormat.WireType.EndGroup);
}
- public void WriteMessageArray(int fieldNumber, string fieldName, System.Collections.IEnumerable list)
- {
- foreach (IMessageLite msg in list)
- WriteMessage(fieldNumber, fieldName, msg);
- }
-
- public void WriteGroupArray(int fieldNumber, string fieldName, System.Collections.IEnumerable list)
- {
- foreach (IMessageLite msg in list)
- WriteGroup(fieldNumber, fieldName, msg);
- }
-
public void WriteArray(FieldType fieldType, int fieldNumber, string fieldName, System.Collections.IEnumerable list)
{
foreach (object element in list)
diff --git a/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs b/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs index 956efd18..d1ae767e 100644 --- a/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs +++ b/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs @@ -280,7 +280,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { }
}
- public override void WriteTo(pb::CodedOutputStream output) {
+ public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
if (HasNamespace) {
output.WriteString(1, "namespace", Namespace);
@@ -886,7 +886,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { }
}
- public override void WriteTo(pb::CodedOutputStream output) {
+ public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
if (HasPropertyName) {
output.WriteString(1, "property_name", PropertyName);
@@ -1108,7 +1108,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { }
}
- public override void WriteTo(pb::CodedOutputStream output) {
+ public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
if (HasInterfaceId) {
output.WriteString(1, "interface_id", InterfaceId);
@@ -1330,7 +1330,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { }
}
- public override void WriteTo(pb::CodedOutputStream output) {
+ public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
if (HasDispatchId) {
output.WriteInt32(1, "dispatch_id", DispatchId);
diff --git a/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs index b9b31855..d4e5126e 100644 --- a/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs +++ b/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs @@ -273,10 +273,10 @@ namespace Google.ProtocolBuffers.DescriptorProtos { }
}
- public override void WriteTo(pb::CodedOutputStream output) {
+ public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
if (file_.Count > 0) {
- output.WriteMessageArray(1, "file", file_);
+ output.WriteArray(pbd::FieldType.Message, 1, "file", file_);
}
UnknownFields.WriteTo(output);
}
@@ -612,7 +612,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { }
}
- public override void WriteTo(pb::CodedOutputStream output) {
+ public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
if (HasName) {
output.WriteString(1, "name", Name);
@@ -624,16 +624,16 @@ namespace Google.ProtocolBuffers.DescriptorProtos { output.WriteArray(pbd::FieldType.String, 3, "dependency", dependency_);
}
if (messageType_.Count > 0) {
- output.WriteMessageArray(4, "message_type", messageType_);
+ output.WriteArray(pbd::FieldType.Message, 4, "message_type", messageType_);
}
if (enumType_.Count > 0) {
- output.WriteMessageArray(5, "enum_type", enumType_);
+ output.WriteArray(pbd::FieldType.Message, 5, "enum_type", enumType_);
}
if (service_.Count > 0) {
- output.WriteMessageArray(6, "service", service_);
+ output.WriteArray(pbd::FieldType.Message, 6, "service", service_);
}
if (extension_.Count > 0) {
- output.WriteMessageArray(7, "extension", extension_);
+ output.WriteArray(pbd::FieldType.Message, 7, "extension", extension_);
}
if (HasOptions) {
output.WriteMessage(8, "options", Options);
@@ -1223,7 +1223,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { }
}
- public override void WriteTo(pb::CodedOutputStream output) {
+ public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
if (HasStart) {
output.WriteInt32(1, "start", Start);
@@ -1538,25 +1538,25 @@ namespace Google.ProtocolBuffers.DescriptorProtos { }
}
- public override void WriteTo(pb::CodedOutputStream output) {
+ public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
if (HasName) {
output.WriteString(1, "name", Name);
}
if (field_.Count > 0) {
- output.WriteMessageArray(2, "field", field_);
+ output.WriteArray(pbd::FieldType.Message, 2, "field", field_);
}
if (nestedType_.Count > 0) {
- output.WriteMessageArray(3, "nested_type", nestedType_);
+ output.WriteArray(pbd::FieldType.Message, 3, "nested_type", nestedType_);
}
if (enumType_.Count > 0) {
- output.WriteMessageArray(4, "enum_type", enumType_);
+ output.WriteArray(pbd::FieldType.Message, 4, "enum_type", enumType_);
}
if (extensionRange_.Count > 0) {
- output.WriteMessageArray(5, "extension_range", extensionRange_);
+ output.WriteArray(pbd::FieldType.Message, 5, "extension_range", extensionRange_);
}
if (extension_.Count > 0) {
- output.WriteMessageArray(6, "extension", extension_);
+ output.WriteArray(pbd::FieldType.Message, 6, "extension", extension_);
}
if (HasOptions) {
output.WriteMessage(7, "options", Options);
@@ -2196,7 +2196,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { }
}
- public override void WriteTo(pb::CodedOutputStream output) {
+ public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
if (HasName) {
output.WriteString(1, "name", Name);
@@ -2705,13 +2705,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { }
}
- public override void WriteTo(pb::CodedOutputStream output) {
+ public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
if (HasName) {
output.WriteString(1, "name", Name);
}
if (value_.Count > 0) {
- output.WriteMessageArray(2, "value", value_);
+ output.WriteArray(pbd::FieldType.Message, 2, "value", value_);
}
if (HasOptions) {
output.WriteMessage(3, "options", Options);
@@ -3058,7 +3058,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { }
}
- public override void WriteTo(pb::CodedOutputStream output) {
+ public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
if (HasName) {
output.WriteString(1, "name", Name);
@@ -3393,13 +3393,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { }
}
- public override void WriteTo(pb::CodedOutputStream output) {
+ public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
if (HasName) {
output.WriteString(1, "name", Name);
}
if (method_.Count > 0) {
- output.WriteMessageArray(2, "method", method_);
+ output.WriteArray(pbd::FieldType.Message, 2, "method", method_);
}
if (HasOptions) {
output.WriteMessage(3, "options", Options);
@@ -3756,7 +3756,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { }
}
- public override void WriteTo(pb::CodedOutputStream output) {
+ public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
if (HasName) {
output.WriteString(1, "name", Name);
@@ -4188,7 +4188,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { }
}
- public override void WriteTo(pb::CodedOutputStream output) {
+ public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
pb::ExtendableMessage<FileOptions, FileOptions.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this);
if (HasJavaPackage) {
@@ -4213,7 +4213,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { output.WriteBool(18, "py_generic_services", PyGenericServices);
}
if (uninterpretedOption_.Count > 0) {
- output.WriteMessageArray(999, "uninterpreted_option", uninterpretedOption_);
+ output.WriteArray(pbd::FieldType.Message, 999, "uninterpreted_option", uninterpretedOption_);
}
extensionWriter.WriteUntil(536870912, output);
UnknownFields.WriteTo(output);
@@ -4689,7 +4689,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { }
}
- public override void WriteTo(pb::CodedOutputStream output) {
+ public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
pb::ExtendableMessage<MessageOptions, MessageOptions.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this);
if (HasMessageSetWireFormat) {
@@ -4699,7 +4699,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { output.WriteBool(2, "no_standard_descriptor_accessor", NoStandardDescriptorAccessor);
}
if (uninterpretedOption_.Count > 0) {
- output.WriteMessageArray(999, "uninterpreted_option", uninterpretedOption_);
+ output.WriteArray(pbd::FieldType.Message, 999, "uninterpreted_option", uninterpretedOption_);
}
extensionWriter.WriteUntil(536870912, output);
UnknownFields.WriteTo(output);
@@ -5061,7 +5061,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { }
}
- public override void WriteTo(pb::CodedOutputStream output) {
+ public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
pb::ExtendableMessage<FieldOptions, FieldOptions.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this);
if (HasCtype) {
@@ -5077,7 +5077,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { output.WriteString(9, "experimental_map_key", ExperimentalMapKey);
}
if (uninterpretedOption_.Count > 0) {
- output.WriteMessageArray(999, "uninterpreted_option", uninterpretedOption_);
+ output.WriteArray(pbd::FieldType.Message, 999, "uninterpreted_option", uninterpretedOption_);
}
extensionWriter.WriteUntil(536870912, output);
UnknownFields.WriteTo(output);
@@ -5448,11 +5448,11 @@ namespace Google.ProtocolBuffers.DescriptorProtos { }
}
- public override void WriteTo(pb::CodedOutputStream output) {
+ public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
pb::ExtendableMessage<EnumOptions, EnumOptions.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this);
if (uninterpretedOption_.Count > 0) {
- output.WriteMessageArray(999, "uninterpreted_option", uninterpretedOption_);
+ output.WriteArray(pbd::FieldType.Message, 999, "uninterpreted_option", uninterpretedOption_);
}
extensionWriter.WriteUntil(536870912, output);
UnknownFields.WriteTo(output);
@@ -5702,11 +5702,11 @@ namespace Google.ProtocolBuffers.DescriptorProtos { }
}
- public override void WriteTo(pb::CodedOutputStream output) {
+ public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
pb::ExtendableMessage<EnumValueOptions, EnumValueOptions.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this);
if (uninterpretedOption_.Count > 0) {
- output.WriteMessageArray(999, "uninterpreted_option", uninterpretedOption_);
+ output.WriteArray(pbd::FieldType.Message, 999, "uninterpreted_option", uninterpretedOption_);
}
extensionWriter.WriteUntil(536870912, output);
UnknownFields.WriteTo(output);
@@ -5956,11 +5956,11 @@ namespace Google.ProtocolBuffers.DescriptorProtos { }
}
- public override void WriteTo(pb::CodedOutputStream output) {
+ public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
pb::ExtendableMessage<ServiceOptions, ServiceOptions.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this);
if (uninterpretedOption_.Count > 0) {
- output.WriteMessageArray(999, "uninterpreted_option", uninterpretedOption_);
+ output.WriteArray(pbd::FieldType.Message, 999, "uninterpreted_option", uninterpretedOption_);
}
extensionWriter.WriteUntil(536870912, output);
UnknownFields.WriteTo(output);
@@ -6210,11 +6210,11 @@ namespace Google.ProtocolBuffers.DescriptorProtos { }
}
- public override void WriteTo(pb::CodedOutputStream output) {
+ public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
pb::ExtendableMessage<MethodOptions, MethodOptions.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this);
if (uninterpretedOption_.Count > 0) {
- output.WriteMessageArray(999, "uninterpreted_option", uninterpretedOption_);
+ output.WriteArray(pbd::FieldType.Message, 999, "uninterpreted_option", uninterpretedOption_);
}
extensionWriter.WriteUntil(536870912, output);
UnknownFields.WriteTo(output);
@@ -6500,7 +6500,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { }
}
- public override void WriteTo(pb::CodedOutputStream output) {
+ public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
if (HasNamePart_) {
output.WriteString(1, "name_part", NamePart_);
@@ -6787,10 +6787,10 @@ namespace Google.ProtocolBuffers.DescriptorProtos { }
}
- public override void WriteTo(pb::CodedOutputStream output) {
+ public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
if (name_.Count > 0) {
- output.WriteMessageArray(2, "name", name_);
+ output.WriteArray(pbd::FieldType.Message, 2, "name", name_);
}
if (HasIdentifierValue) {
output.WriteString(3, "identifier_value", IdentifierValue);
diff --git a/src/ProtocolBuffers/DynamicMessage.cs b/src/ProtocolBuffers/DynamicMessage.cs index 0255b00d..3103706c 100644 --- a/src/ProtocolBuffers/DynamicMessage.cs +++ b/src/ProtocolBuffers/DynamicMessage.cs @@ -246,7 +246,7 @@ namespace Google.ProtocolBuffers get { return fields.IsInitializedWithRespectTo(type.Fields); }
}
- public override void WriteTo(CodedOutputStream output)
+ public override void WriteTo(ICodedOutputStream output)
{
fields.WriteTo(output);
if (type.Options.MessageSetWireFormat)
diff --git a/src/ProtocolBuffers/ExtendableMessage.cs b/src/ProtocolBuffers/ExtendableMessage.cs index 7e988c49..b5fbac37 100644 --- a/src/ProtocolBuffers/ExtendableMessage.cs +++ b/src/ProtocolBuffers/ExtendableMessage.cs @@ -230,7 +230,7 @@ namespace Google.ProtocolBuffers }
}
- public void WriteUntil(int end, CodedOutputStream output)
+ public void WriteUntil(int end, ICodedOutputStream output)
{
while (next != null && next.Value.Key.FieldNumber < end)
{
diff --git a/src/ProtocolBuffers/ExtendableMessageLite.cs b/src/ProtocolBuffers/ExtendableMessageLite.cs index 8c330bb9..3417f152 100644 --- a/src/ProtocolBuffers/ExtendableMessageLite.cs +++ b/src/ProtocolBuffers/ExtendableMessageLite.cs @@ -173,7 +173,7 @@ namespace Google.ProtocolBuffers }
}
- public void WriteUntil(int end, CodedOutputStream output)
+ public void WriteUntil(int end, ICodedOutputStream output)
{
while (next != null && next.Value.Key.FieldNumber < end)
{
diff --git a/src/ProtocolBuffers/FieldSet.cs b/src/ProtocolBuffers/FieldSet.cs index 93082b51..18e57662 100644 --- a/src/ProtocolBuffers/FieldSet.cs +++ b/src/ProtocolBuffers/FieldSet.cs @@ -455,7 +455,7 @@ namespace Google.ProtocolBuffers /// <summary>
/// See <see cref="IMessageLite.WriteTo(CodedOutputStream)" />.
/// </summary>
- public void WriteTo(CodedOutputStream output)
+ public void WriteTo(ICodedOutputStream output)
{
foreach (KeyValuePair<IFieldDescriptorLite, object> entry in fields)
{
@@ -466,7 +466,7 @@ namespace Google.ProtocolBuffers /// <summary>
/// Writes a single field to a CodedOutputStream.
/// </summary>
- public void WriteField(IFieldDescriptorLite field, Object value, CodedOutputStream output)
+ public void WriteField(IFieldDescriptorLite field, Object value, ICodedOutputStream output)
{
if (field.IsExtension && field.MessageSetWireFormat)
{
@@ -478,28 +478,30 @@ namespace Google.ProtocolBuffers {
IEnumerable valueList = (IEnumerable) value;
if (field.IsPacked)
- {
- output.WriteTag(field.FieldNumber, WireFormat.WireType.LengthDelimited);
- // Compute the total data size so the length can be written.
- int dataSize = 0;
- foreach (object element in valueList)
- {
- dataSize += CodedOutputStream.ComputeFieldSizeNoTag(field.FieldType, element);
- }
- output.WriteRawVarint32((uint) dataSize);
- // Write the data itself, without any tags.
- foreach (object element in valueList)
- {
- output.WriteFieldNoTag(field.FieldType, element);
- }
- }
+ output.WritePackedArray(field.FieldType, field.FieldNumber, field.Name, valueList);
+ //{
+ // output.WriteTag(field.FieldNumber, WireFormat.WireType.LengthDelimited);
+ // // Compute the total data size so the length can be written.
+ // int dataSize = 0;
+ // foreach (object element in valueList)
+ // {
+ // dataSize += CodedOutputStream.ComputeFieldSizeNoTag(field.FieldType, element);
+ // }
+ // output.WriteRawVarint32((uint) dataSize);
+ // // Write the data itself, without any tags.
+ // foreach (object element in valueList)
+ // {
+ // output.WriteFieldNoTag(field.FieldType, element);
+ // }
+ //}
else
- {
- foreach (object element in valueList)
- {
- output.WriteField(field.FieldType, field.FieldNumber, field.Name, element);
- }
- }
+ output.WriteArray(field.FieldType, field.FieldNumber, field.Name, valueList);
+ //{
+ // foreach (object element in valueList)
+ // {
+ // output.WriteField(field.FieldType, field.FieldNumber, field.Name, element);
+ // }
+ //}
}
else
{
diff --git a/src/ProtocolBuffers/ICodedOutputStream.cs b/src/ProtocolBuffers/ICodedOutputStream.cs index fb290eb6..f008e798 100644 --- a/src/ProtocolBuffers/ICodedOutputStream.cs +++ b/src/ProtocolBuffers/ICodedOutputStream.cs @@ -1,6 +1,9 @@ using System;
using Google.ProtocolBuffers.Descriptors;
+//Disable warning CS3010: CLS-compliant interfaces must have only CLS-compliant members
+#pragma warning disable 3010
+
namespace Google.ProtocolBuffers
{
public interface ICodedOutputStream
@@ -73,8 +76,7 @@ namespace Google.ProtocolBuffers void WriteSInt32(int fieldNumber, string fieldName, int value);
void WriteSInt64(int fieldNumber, string fieldName, long value);
void WriteMessageSetExtension(int fieldNumber, string fieldName, IMessageLite value);
- void WriteMessageArray(int fieldNumber, string fieldName, System.Collections.IEnumerable list);
- void WriteGroupArray(int fieldNumber, string fieldName, System.Collections.IEnumerable list);
+ void WriteMessageSetExtension(int fieldNumber, string fieldName, ByteString value);
void WriteArray(FieldType fieldType, int fieldNumber, string fieldName, System.Collections.IEnumerable list);
void WritePackedArray(FieldType fieldType, int fieldNumber, string fieldName, System.Collections.IEnumerable list);
void WritePackedArray(FieldType fieldType, int fieldNumber, string fieldName, int calculatedSize, System.Collections.IEnumerable list);
diff --git a/src/ProtocolBuffers/IMessage.cs b/src/ProtocolBuffers/IMessage.cs index 7631a958..c23bc3f7 100644 --- a/src/ProtocolBuffers/IMessage.cs +++ b/src/ProtocolBuffers/IMessage.cs @@ -128,7 +128,7 @@ namespace Google.ProtocolBuffers /// of the message before the data, then making sure you limit the input to
/// that size when receiving the data. Alternatively, use WriteDelimitedTo(Stream).
/// </remarks>
- new void WriteTo(CodedOutputStream output);
+ new void WriteTo(ICodedOutputStream output);
/// <summary>
/// Like WriteTo(Stream) but writes the size of the message as a varint before
@@ -174,19 +174,19 @@ namespace Google.ProtocolBuffers /// <summary>
/// Serializes the message to a ByteString. This is a trivial wrapper
- /// around WriteTo(CodedOutputStream).
+ /// around WriteTo(ICodedOutputStream).
/// </summary>
new ByteString ToByteString();
/// <summary>
/// Serializes the message to a byte array. This is a trivial wrapper
- /// around WriteTo(CodedOutputStream).
+ /// around WriteTo(ICodedOutputStream).
/// </summary>
new byte[] ToByteArray();
/// <summary>
/// Serializes the message and writes it to the given stream.
- /// This is just a wrapper around WriteTo(CodedOutputStream). This
+ /// This is just a wrapper around WriteTo(ICodedOutputStream). This
/// does not flush or close the stream.
/// </summary>
/// <param name="output"></param>
diff --git a/src/ProtocolBuffers/IMessageLite.cs b/src/ProtocolBuffers/IMessageLite.cs index 5fc0d94f..62d325cc 100644 --- a/src/ProtocolBuffers/IMessageLite.cs +++ b/src/ProtocolBuffers/IMessageLite.cs @@ -64,7 +64,7 @@ namespace Google.ProtocolBuffers /// of the message before the data, then making sure you limit the input to
/// that size when receiving the data. Alternatively, use WriteDelimitedTo(Stream).
/// </remarks>
- void WriteTo(CodedOutputStream output);
+ void WriteTo(ICodedOutputStream output);
/// <summary>
/// Like WriteTo(Stream) but writes the size of the message as a varint before
@@ -115,19 +115,19 @@ namespace Google.ProtocolBuffers /// <summary>
/// Serializes the message to a ByteString. This is a trivial wrapper
- /// around WriteTo(CodedOutputStream).
+ /// around WriteTo(ICodedOutputStream).
/// </summary>
ByteString ToByteString();
/// <summary>
/// Serializes the message to a byte array. This is a trivial wrapper
- /// around WriteTo(CodedOutputStream).
+ /// around WriteTo(ICodedOutputStream).
/// </summary>
byte[] ToByteArray();
/// <summary>
/// Serializes the message and writes it to the given stream.
- /// This is just a wrapper around WriteTo(CodedOutputStream). This
+ /// This is just a wrapper around WriteTo(ICodedOutputStream). This
/// does not flush or close the stream.
/// </summary>
/// <param name="output"></param>
diff --git a/src/ProtocolBuffers/ProtocolBuffersLite.csproj b/src/ProtocolBuffers/ProtocolBuffersLite.csproj index 6371c274..042ffd17 100644 --- a/src/ProtocolBuffers/ProtocolBuffersLite.csproj +++ b/src/ProtocolBuffers/ProtocolBuffersLite.csproj @@ -1,120 +1,122 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>9.0.30729</ProductVersion> - <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{6969BDCE-D925-43F3-94AC-A531E6DF2591}</ProjectGuid> - <OutputType>Library</OutputType> - <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>Google.ProtocolBuffers</RootNamespace> - <AssemblyName>Google.ProtocolBuffersLite</AssemblyName> - <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> - <FileAlignment>512</FileAlignment> - <SignAssembly>true</SignAssembly> - <AssemblyOriginatorKeyFile>..\..\keys\Google.ProtocolBuffers.snk</AssemblyOriginatorKeyFile> - <FileUpgradeFlags> - </FileUpgradeFlags> - <OldToolsVersion>3.5</OldToolsVersion> - <UpgradeBackupLocation /> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <DebugSymbols>true</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>false</Optimize> - <OutputPath>bin\Debug\</OutputPath> - <DocumentationFile>$(OutputPath)\$(AssemblyName).xml</DocumentationFile> - <NoWarn>1591, 1570, 1571, 1572, 1573, 1574</NoWarn> - <DefineConstants>TRACE;DEBUG;LITE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <NoStdLib>true</NoStdLib> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <DebugType>pdbonly</DebugType> - <Optimize>true</Optimize> - <OutputPath>bin\Release\</OutputPath> - <DocumentationFile>$(OutputPath)\$(AssemblyName).xml</DocumentationFile> - <NoWarn>1591, 1570, 1571, 1572, 1573, 1574</NoWarn> - <DefineConstants>TRACE;LITE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <NoStdLib>true</NoStdLib> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug_Silverlight2|AnyCPU'"> - <DebugSymbols>true</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>false</Optimize> - <OutputPath>bin\Debug_Silverlight2\</OutputPath> - <DocumentationFile>$(OutputPath)\$(AssemblyName).xml</DocumentationFile> - <NoWarn>1591, 1570, 1571, 1572, 1573, 1574</NoWarn> - <DefineConstants>DEBUG;TRACE;SILVERLIGHT2;LITE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <NoStdLib>true</NoStdLib> - <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release_Silverlight2|AnyCPU'"> - <DebugType>pdbonly</DebugType> - <Optimize>true</Optimize> - <OutputPath>bin\Release_Silverlight2\</OutputPath> - <DocumentationFile>$(OutputPath)\$(AssemblyName).xml</DocumentationFile> - <NoWarn>1591, 1570, 1571, 1572, 1573, 1574</NoWarn> - <DefineConstants>TRACE;SILVERLIGHT2;LITE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <NoStdLib>true</NoStdLib> - <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> - </PropertyGroup> - <ItemGroup> - <Reference Include="mscorlib" /> - <Reference Include="System" /> - <Reference Include="System.Data" /> - <Reference Include="System.Xml" /> - </ItemGroup> - <ItemGroup> - </ItemGroup> - <ItemGroup> - <Compile Include="AbstractBuilderLite.cs" /> - <Compile Include="AbstractMessageLite.cs" /> - <Compile Include="Collections\Dictionaries.cs" /> - <Compile Include="Collections\Enumerables.cs" /> - <Compile Include="Collections\IPopsicleList.cs" /> - <Compile Include="Collections\Lists.cs" /> - <Compile Include="Collections\PopsicleList.cs" /> - <Compile Include="Collections\ReadOnlyDictionary.cs" /> - <Compile Include="Descriptors\FieldMappingAttribute.cs" /> - <Compile Include="Descriptors\FieldType.cs" /> - <Compile Include="Descriptors\MappedType.cs" /> - <Compile Include="EnumLite.cs" /> - <Compile Include="ExtendableBuilderLite.cs" /> - <Compile Include="ExtendableMessageLite.cs" /> - <Compile Include="FieldSet.cs" /> - <Compile Include="GeneratedBuilderLite.cs" /> - <Compile Include="GeneratedExtensionLite.cs" /> - <Compile Include="GeneratedMessageLite.cs" /> - <Compile Include="Properties\AssemblyInfo.cs" /> - <Compile Include="ByteString.cs" /> - <Compile Include="CodedInputStream.cs" /> - <Compile Include="CodedOutputStream.cs" /> - <Compile Include="ExtensionRegistryLite.cs" /> - <Compile Include="IBuilderLite.cs" /> - <Compile Include="IMessageLite.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="InvalidProtocolBufferException.cs" /> - <Compile Include="ThrowHelper.cs" /> - <Compile Include="UninitializedMessageException.cs" /> - <Compile Include="WireFormat.cs" /> - </ItemGroup> - <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" Condition=" '$(Configuration)' != 'Silverlight2' " /> - <Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight\v2.0\Microsoft.Silverlight.CSharp.targets" Condition=" '$(Configuration)' == 'Silverlight2' " /> +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{6969BDCE-D925-43F3-94AC-A531E6DF2591}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Google.ProtocolBuffers</RootNamespace>
+ <AssemblyName>Google.ProtocolBuffersLite</AssemblyName>
+ <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <SignAssembly>true</SignAssembly>
+ <AssemblyOriginatorKeyFile>..\..\keys\Google.ProtocolBuffers.snk</AssemblyOriginatorKeyFile>
+ <FileUpgradeFlags>
+ </FileUpgradeFlags>
+ <OldToolsVersion>3.5</OldToolsVersion>
+ <UpgradeBackupLocation />
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DocumentationFile>$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
+ <NoWarn>1591, 1570, 1571, 1572, 1573, 1574</NoWarn>
+ <DefineConstants>TRACE;DEBUG;LITE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <NoStdLib>true</NoStdLib>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DocumentationFile>$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
+ <NoWarn>1591, 1570, 1571, 1572, 1573, 1574</NoWarn>
+ <DefineConstants>TRACE;LITE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <NoStdLib>true</NoStdLib>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug_Silverlight2|AnyCPU'">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug_Silverlight2\</OutputPath>
+ <DocumentationFile>$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
+ <NoWarn>1591, 1570, 1571, 1572, 1573, 1574</NoWarn>
+ <DefineConstants>DEBUG;TRACE;SILVERLIGHT2;LITE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <NoStdLib>true</NoStdLib>
+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release_Silverlight2|AnyCPU'">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release_Silverlight2\</OutputPath>
+ <DocumentationFile>$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
+ <NoWarn>1591, 1570, 1571, 1572, 1573, 1574</NoWarn>
+ <DefineConstants>TRACE;SILVERLIGHT2;LITE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <NoStdLib>true</NoStdLib>
+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="mscorlib" />
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="AbstractBuilderLite.cs" />
+ <Compile Include="AbstractMessageLite.cs" />
+ <Compile Include="CodedOutputStream.ComputeSize.cs" />
+ <Compile Include="Collections\Dictionaries.cs" />
+ <Compile Include="Collections\Enumerables.cs" />
+ <Compile Include="Collections\IPopsicleList.cs" />
+ <Compile Include="Collections\Lists.cs" />
+ <Compile Include="Collections\PopsicleList.cs" />
+ <Compile Include="Collections\ReadOnlyDictionary.cs" />
+ <Compile Include="Descriptors\FieldMappingAttribute.cs" />
+ <Compile Include="Descriptors\FieldType.cs" />
+ <Compile Include="Descriptors\MappedType.cs" />
+ <Compile Include="EnumLite.cs" />
+ <Compile Include="ExtendableBuilderLite.cs" />
+ <Compile Include="ExtendableMessageLite.cs" />
+ <Compile Include="FieldSet.cs" />
+ <Compile Include="GeneratedBuilderLite.cs" />
+ <Compile Include="GeneratedExtensionLite.cs" />
+ <Compile Include="GeneratedMessageLite.cs" />
+ <Compile Include="ICodedOutputStream.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="ByteString.cs" />
+ <Compile Include="CodedInputStream.cs" />
+ <Compile Include="CodedOutputStream.cs" />
+ <Compile Include="ExtensionRegistryLite.cs" />
+ <Compile Include="IBuilderLite.cs" />
+ <Compile Include="IMessageLite.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="InvalidProtocolBufferException.cs" />
+ <Compile Include="ThrowHelper.cs" />
+ <Compile Include="UninitializedMessageException.cs" />
+ <Compile Include="WireFormat.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" Condition=" '$(Configuration)' != 'Silverlight2' " />
+ <Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight\v2.0\Microsoft.Silverlight.CSharp.targets" Condition=" '$(Configuration)' == 'Silverlight2' " />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> - --> + -->
</Project>
\ No newline at end of file diff --git a/src/ProtocolBuffers/UnknownField.cs b/src/ProtocolBuffers/UnknownField.cs index d3a73799..edbbc29e 100644 --- a/src/ProtocolBuffers/UnknownField.cs +++ b/src/ProtocolBuffers/UnknownField.cs @@ -174,7 +174,7 @@ namespace Google.ProtocolBuffers /// Serializes the field, including the field number, and writes it to
/// <paramref name="output"/>.
/// </summary>
- public void WriteTo(int fieldNumber, CodedOutputStream output)
+ public void WriteTo(int fieldNumber, ICodedOutputStream output)
{
foreach (ulong value in varintList)
{
@@ -238,11 +238,11 @@ namespace Google.ProtocolBuffers /// </summary>
/// <param name="fieldNumber"></param>
/// <param name="output"></param>
- public void WriteAsMessageSetExtensionTo(int fieldNumber, CodedOutputStream output)
+ public void WriteAsMessageSetExtensionTo(int fieldNumber, ICodedOutputStream output)
{
foreach (ByteString value in lengthDelimitedList)
{
- output.WriteRawMessageSetExtension(fieldNumber, value);
+ output.WriteMessageSetExtension(fieldNumber, UnknownFieldName, value);
}
}
diff --git a/src/ProtocolBuffers/UnknownFieldSet.cs b/src/ProtocolBuffers/UnknownFieldSet.cs index ee268c54..20a46936 100644 --- a/src/ProtocolBuffers/UnknownFieldSet.cs +++ b/src/ProtocolBuffers/UnknownFieldSet.cs @@ -124,7 +124,7 @@ namespace Google.ProtocolBuffers /// <summary>
/// Serializes the set and writes it to <paramref name="output"/>.
/// </summary>
- public void WriteTo(CodedOutputStream output)
+ public void WriteTo(ICodedOutputStream output)
{
foreach (KeyValuePair<int, UnknownField> entry in fields)
{
@@ -168,7 +168,7 @@ namespace Google.ProtocolBuffers /// <summary>
/// Serializes the message to a ByteString and returns it. This is
- /// just a trivial wrapper around WriteTo(CodedOutputStream).
+ /// just a trivial wrapper around WriteTo(ICodedOutputStream).
/// </summary>
/// <returns></returns>
public ByteString ToByteString()
@@ -180,7 +180,7 @@ namespace Google.ProtocolBuffers /// <summary>
/// Serializes the message to a byte array and returns it. This is
- /// just a trivial wrapper around WriteTo(CodedOutputStream).
+ /// just a trivial wrapper around WriteTo(ICodedOutputStream).
/// </summary>
/// <returns></returns>
public byte[] ToByteArray()
@@ -194,7 +194,7 @@ namespace Google.ProtocolBuffers /// <summary>
/// Serializes the message and writes it to <paramref name="output"/>. This is
- /// just a trivial wrapper around WriteTo(CodedOutputStream).
+ /// just a trivial wrapper around WriteTo(ICodedOutputStream).
/// </summary>
/// <param name="output"></param>
public void WriteTo(Stream output)
@@ -208,7 +208,7 @@ namespace Google.ProtocolBuffers /// Serializes the set and writes it to <paramref name="output"/> using
/// the MessageSet wire format.
/// </summary>
- public void WriteAsMessageSetTo(CodedOutputStream output)
+ public void WriteAsMessageSetTo(ICodedOutputStream output)
{
foreach (KeyValuePair<int, UnknownField> entry in fields)
{
|