Commit 32ead755 authored by Jie Luo's avatar Jie Luo

Merge pull request #313 from jskeet/csharp

First steps to making the C# runtime work with new codegen
parents b977c3ed 5ca6dd76
// Additional options required for C# generation. File from copyright
// line onwards is as per original distribution.
import "google/protobuf/csharp_options.proto";
option (google.protobuf.csharp_file_options).namespace = "Google.ProtocolBuffers.TestProtos";
option (google.protobuf.csharp_file_options).umbrella_classname = "UnitTestExtrasProtoFile";
option (google.protobuf.csharp_file_options).add_serializable = true;
package protobuf_unittest_extra;
option java_package = "com.google.protobuf";
message TestUnpackedExtensions {
extensions 1 to max;
}
extend TestUnpackedExtensions {
repeated int32 unpacked_int32_extension = 90;
repeated int64 unpacked_int64_extension = 91;
repeated uint32 unpacked_uint32_extension = 92;
repeated uint64 unpacked_uint64_extension = 93;
repeated sint32 unpacked_sint32_extension = 94;
repeated sint64 unpacked_sint64_extension = 95;
repeated fixed32 unpacked_fixed32_extension = 96;
repeated fixed64 unpacked_fixed64_extension = 97;
repeated sfixed32 unpacked_sfixed32_extension = 98;
repeated sfixed64 unpacked_sfixed64_extension = 99;
repeated float unpacked_float_extension = 100;
repeated double unpacked_double_extension = 101;
repeated bool unpacked_bool_extension = 102;
repeated UnpackedExtensionsForeignEnum unpacked_enum_extension = 103;
}
enum UnpackedExtensionsForeignEnum {
FOREIGN_FOO = 4;
FOREIGN_BAR = 5;
FOREIGN_BAZ = 6;
}
// Additional options required for C# generation. File from copyright syntax = "proto2";
// line onwards is as per original distribution.
import "google/protobuf/csharp_options.proto";
option (google.protobuf.csharp_file_options).namespace = "Google.ProtocolBuffers.TestProtos";
option (google.protobuf.csharp_file_options).umbrella_classname = "UnitTestExtrasFullProtoFile";
package protobuf_unittest_extra; package protobuf_unittest_extra;
option csharp_namespace = "Google.ProtocolBuffers.TestProtos";
option optimize_for = CODE_SIZE; option optimize_for = CODE_SIZE;
option java_package = "com.google.protobuf"; option java_package = "com.google.protobuf";
message TestInteropPerson { message TestInteropPerson {
...@@ -45,7 +41,10 @@ message TestInteropEmployeeId { ...@@ -45,7 +41,10 @@ message TestInteropEmployeeId {
} }
extend TestInteropPerson { extend TestInteropPerson {
required TestInteropEmployeeId employee_id = 126; // Note: changed from required to optional, as required fields are not
// permitted in extensions. (The fact that this was allowed in protogen
// before was almost certainly a bug.)
optional TestInteropEmployeeId employee_id = 126;
} }
message TestMissingFieldsA { message TestMissingFieldsA {
......
// Additional options required for C# generation. File from copyright syntax = "proto2";
// line onwards is as per original distribution.
import "google/protobuf/csharp_options.proto";
option (google.protobuf.csharp_file_options).namespace = "Google.ProtocolBuffers.TestProtos";
option (google.protobuf.csharp_file_options).umbrella_classname = "UnitTestExtrasLiteProtoFile";
option (google.protobuf.csharp_file_options).add_serializable = true;
package protobuf_unittest_extra; package protobuf_unittest_extra;
option csharp_namespace = "Google.ProtocolBuffers.TestProtos";
option optimize_for = LITE_RUNTIME; option optimize_for = LITE_RUNTIME;
option java_package = "com.google.protobuf"; option java_package = "com.google.protobuf";
message TestRequiredLite { message TestRequiredLite {
...@@ -58,7 +53,10 @@ message TestInteropEmployeeIdLite { ...@@ -58,7 +53,10 @@ message TestInteropEmployeeIdLite {
} }
extend TestInteropPersonLite { extend TestInteropPersonLite {
required TestInteropEmployeeIdLite employee_id_lite = 126; // Note: changed from required to optional, as required fields are not
// permitted in extensions. (The fact that this was allowed in protogen
// before was almost certainly a bug.)
optional TestInteropEmployeeIdLite employee_id_lite = 126;
} }
/* Removed from unittest_lite.proto and added back here */ /* Removed from unittest_lite.proto and added back here */
......
import "google/protobuf/csharp_options.proto"; syntax = "proto2";
option (google.protobuf.csharp_file_options).namespace = "Google.ProtocolBuffers.TestProtos";
option (google.protobuf.csharp_file_options).umbrella_classname = "UnitTestXmlSerializerTestProtoFile"; option csharp_namespace = "Google.ProtocolBuffers.TestProtos";
option (google.protobuf.csharp_file_options).add_serializable = true;
package protobuf_unittest_extra; package protobuf_unittest_extra;
......
syntax = "proto2";
// Additional options required for C# generation. File from copyright // Additional options required for C# generation. File from copyright
// line onwards is as per original distribution. // line onwards is as per original distribution.
import "google/protobuf/csharp_options.proto";
import "google/protobuf/unittest.proto"; import "google/protobuf/unittest.proto";
import "google/protobuf/unittest_custom_options.proto"; import "google/protobuf/unittest_custom_options.proto";
option (google.protobuf.csharp_file_options).namespace = "Google.ProtocolBuffers.TestProtos";
option (google.protobuf.csharp_file_options).umbrella_classname = "UnitTestGenericServices";
option (google.protobuf.csharp_file_options).service_generator_type = GENERIC; option csharp_namespace = "Google.ProtocolBuffers.TestProtos";
// option (google.protobuf.csharp_file_options).service_generator_type = GENERIC;
// We don't put this in a package within proto2 because we need to make sure // We don't put this in a package within proto2 because we need to make sure
// that the generated code doesn't depend on being in the proto2 namespace. // that the generated code doesn't depend on being in the proto2 namespace.
......
syntax = "proto2";
// These proto descriptors have at one time been reported as an issue or defect. // These proto descriptors have at one time been reported as an issue or defect.
// They are kept here to replicate the issue, and continue to verify the fix. // They are kept here to replicate the issue, and continue to verify the fix.
import "google/protobuf/csharp_options.proto";
// Issue: Non-"Google.Protobuffers" namespace will ensure that protobuffer library types are qualified // Issue: Non-"Google.Protobuffers" namespace will ensure that protobuffer library types are qualified
option (google.protobuf.csharp_file_options).namespace = "UnitTest.Issues.TestProtos"; option csharp_namespace = "UnitTest.Issues.TestProtos";
option (google.protobuf.csharp_file_options).umbrella_classname = "UnitTestExtrasIssuesProtoFile";
package unittest_issues; package unittest_issues;
option optimize_for = SPEED; option optimize_for = SPEED;
...@@ -67,24 +67,28 @@ service TestGenericService { ...@@ -67,24 +67,28 @@ service TestGenericService {
rpc Bar(TestBasicNoFields) returns (TestBasicMessage); rpc Bar(TestBasicNoFields) returns (TestBasicMessage);
} }
*/ */
// Issue 13: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=13
message A { // Old issue 13: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=13
optional int32 _A = 1; // New issue 309: https://github.com/google/protobuf/issues/309
}
message B { // message A {
optional int32 B_ = 1; // optional int32 _A = 1;
} // }
message AB { // message B {
optional int32 a_b = 1; // optional int32 B_ = 1;
} // }
//message AB {
// optional int32 a_b = 1;
//}
// Similar issue with numeric names // Similar issue with numeric names
message NumberField { // Java code failed too, so probably best for this to be a restriction.
optional int32 _01 = 1; // See https://github.com/google/protobuf/issues/308
} // message NumberField {
// optional int32 _01 = 1;
// }
// Issue 28: Circular message dependencies result in null defaults for DefaultInstance // Issue 28: Circular message dependencies result in null defaults for DefaultInstance
......
...@@ -132,8 +132,8 @@ namespace Google.ProtocolBuffers ...@@ -132,8 +132,8 @@ namespace Google.ProtocolBuffers
{ {
byte[] bytes = TestUtil.GetPackedSet().ToByteArray(); byte[] bytes = TestUtil.GetPackedSet().ToByteArray();
ExtensionRegistry registry = ExtensionRegistry.CreateInstance(); ExtensionRegistry registry = ExtensionRegistry.CreateInstance();
UnitTestProtoFile.RegisterAllExtensions(registry); Unittest.RegisterAllExtensions(registry);
UnitTestExtrasProtoFile.RegisterAllExtensions(registry); UnittestImport.RegisterAllExtensions(registry);
TestUnpackedExtensions message = TestUnpackedExtensions.ParseFrom(bytes, registry); TestUnpackedExtensions message = TestUnpackedExtensions.ParseFrom(bytes, registry);
TestUtil.AssertUnpackedExtensionsSet(message); TestUtil.AssertUnpackedExtensionsSet(message);
} }
...@@ -143,7 +143,7 @@ namespace Google.ProtocolBuffers ...@@ -143,7 +143,7 @@ namespace Google.ProtocolBuffers
{ {
byte[] bytes = TestUnpackedTypes.ParseFrom(TestUtil.GetPackedSet().ToByteArray()).ToByteArray(); byte[] bytes = TestUnpackedTypes.ParseFrom(TestUtil.GetPackedSet().ToByteArray()).ToByteArray();
ExtensionRegistry registry = ExtensionRegistry.CreateInstance(); ExtensionRegistry registry = ExtensionRegistry.CreateInstance();
UnitTestProtoFile.RegisterAllExtensions(registry); Unittest.RegisterAllExtensions(registry);
TestPackedExtensions message = TestPackedExtensions.ParseFrom(bytes, registry); TestPackedExtensions message = TestPackedExtensions.ParseFrom(bytes, registry);
TestUtil.AssertPackedExtensionsSet(message); TestUtil.AssertPackedExtensionsSet(message);
} }
...@@ -250,7 +250,7 @@ namespace Google.ProtocolBuffers ...@@ -250,7 +250,7 @@ namespace Google.ProtocolBuffers
TestAllTypes d = TestAllTypes.CreateBuilder(c).AddRepeatedString("y").Build(); TestAllTypes d = TestAllTypes.CreateBuilder(c).AddRepeatedString("y").Build();
TestAllExtensions e = TestUtil.GetAllExtensionsSet(); TestAllExtensions e = TestUtil.GetAllExtensionsSet();
TestAllExtensions f = TestAllExtensions.CreateBuilder(e) TestAllExtensions f = TestAllExtensions.CreateBuilder(e)
.AddExtension(UnitTestProtoFile.RepeatedInt32Extension, 999).Build(); .AddExtension(Unittest.RepeatedInt32Extension, 999).Build();
CheckEqualsIsConsistent(a); CheckEqualsIsConsistent(a);
CheckEqualsIsConsistent(b); CheckEqualsIsConsistent(b);
......
#region Copyright notice and license
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// http://github.com/jskeet/dotnet-protobufs/
// Original C++/Java/Python code:
// http://code.google.com/p/protobuf/
//
// 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 Google.ProtocolBuffers.DescriptorProtos;
using Google.ProtocolBuffers.Descriptors;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Google.ProtocolBuffers
{
[TestClass]
public class DescriptorUtilTest
{
[TestMethod]
public void ExplicitNamespace()
{
FileDescriptorProto proto = new FileDescriptorProto.Builder
{
Name = "x",
Package = "pack",
Options =
new FileOptions.Builder().SetExtension(
CSharpOptions.CSharpFileOptions,
new CSharpFileOptions.Builder {Namespace = "Foo.Bar"}.Build()).
Build()
}.Build();
FileDescriptor descriptor = FileDescriptor.BuildFrom(proto, null);
Assert.AreEqual("Foo.Bar", descriptor.CSharpOptions.Namespace);
}
[TestMethod]
public void NoNamespaceFallsBackToPackage()
{
FileDescriptorProto proto = new FileDescriptorProto.Builder {Name = "x", Package = "pack"}.Build();
FileDescriptor descriptor = FileDescriptor.BuildFrom(proto, null);
Assert.AreEqual("pack", descriptor.CSharpOptions.Namespace);
}
[TestMethod]
public void NoNamespaceOrPackageFallsBackToEmptyString()
{
FileDescriptorProto proto = new FileDescriptorProto.Builder {Name = "x"}.Build();
FileDescriptor descriptor = FileDescriptor.BuildFrom(proto, null);
Assert.AreEqual("", descriptor.CSharpOptions.Namespace);
}
[TestMethod]
public void ExplicitlyNamedFileClass()
{
FileDescriptorProto proto = new FileDescriptorProto.Builder
{
Name = "x",
Options =
new FileOptions.Builder().SetExtension(
CSharpOptions.CSharpFileOptions,
new CSharpFileOptions.Builder {UmbrellaClassname = "Foo"}.Build())
.Build()
}.Build();
FileDescriptor descriptor = FileDescriptor.BuildFrom(proto, null);
Assert.AreEqual("Foo", descriptor.CSharpOptions.UmbrellaClassname);
}
[TestMethod]
public void ImplicitFileClassWithProtoSuffix()
{
FileDescriptorProto proto = new FileDescriptorProto.Builder {Name = "foo_bar.proto"}.Build();
FileDescriptor descriptor = FileDescriptor.BuildFrom(proto, null);
Assert.AreEqual("FooBar", descriptor.CSharpOptions.UmbrellaClassname);
}
[TestMethod]
public void ImplicitFileClassWithProtoDevelSuffix()
{
FileDescriptorProto proto = new FileDescriptorProto.Builder {Name = "foo_bar.protodevel"}.Build();
FileDescriptor descriptor = FileDescriptor.BuildFrom(proto, null);
Assert.AreEqual("FooBar", descriptor.CSharpOptions.UmbrellaClassname);
}
[TestMethod]
public void ImplicitFileClassWithNoSuffix()
{
FileDescriptorProto proto = new FileDescriptorProto.Builder {Name = "foo_bar"}.Build();
FileDescriptor descriptor = FileDescriptor.BuildFrom(proto, null);
Assert.AreEqual("FooBar", descriptor.CSharpOptions.UmbrellaClassname);
}
[TestMethod]
public void ImplicitFileClassWithDirectoryStructure()
{
FileDescriptorProto proto = new FileDescriptorProto.Builder {Name = "x/y/foo_bar"}.Build();
FileDescriptor descriptor = FileDescriptor.BuildFrom(proto, null);
Assert.AreEqual("FooBar", descriptor.CSharpOptions.UmbrellaClassname);
}
}
}
\ No newline at end of file
...@@ -7,7 +7,7 @@ namespace Google.ProtocolBuffers.Compatibility ...@@ -7,7 +7,7 @@ namespace Google.ProtocolBuffers.Compatibility
{ {
/// <summary> /// <summary>
/// This abstract base implements several tests to ensure that well-known messages can be written /// This abstract base implements several tests to ensure that well-known messages can be written
/// and read to/from various formats without loosing data. Implementations overload the two serailization /// and read to/from various formats without losing data. Implementations overload the two serailization
/// methods to provide the tests with the means to read and write for a given format. /// methods to provide the tests with the means to read and write for a given format.
/// </summary> /// </summary>
public abstract class CompatibilityTests public abstract class CompatibilityTests
......
#region Copyright notice and license
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// http://github.com/jskeet/dotnet-protobufs/
// Original C++/Java/Python code:
// http://code.google.com/p/protobuf/
//
// 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 Microsoft.VisualStudio.TestTools.UnitTesting;
using Google.ProtocolBuffers.TestProtos;
namespace Google.ProtocolBuffers.Descriptors
{
[TestClass]
public class MessageDescriptorTest
{
[TestMethod]
public void FindPropertyWithDefaultName()
{
Assert.AreSame(OptionsMessage.Descriptor.FindFieldByNumber(OptionsMessage.NormalFieldNumber),
OptionsMessage.Descriptor.FindFieldByPropertyName("Normal"));
}
[TestMethod]
public void FindPropertyWithAutoModifiedName()
{
Assert.AreSame(OptionsMessage.Descriptor.FindFieldByNumber(OptionsMessage.OptionsMessage_FieldNumber),
OptionsMessage.Descriptor.FindFieldByPropertyName("OptionsMessage_"));
}
[TestMethod]
public void FindPropertyWithCustomizedName()
{
Assert.AreSame(OptionsMessage.Descriptor.FindFieldByNumber(OptionsMessage.CustomNameFieldNumber),
OptionsMessage.Descriptor.FindFieldByPropertyName("CustomName"));
}
[TestMethod]
public void FindPropertyWithInvalidName()
{
Assert.IsNull(OptionsMessage.Descriptor.FindFieldByPropertyName("Bogus"));
}
}
}
\ No newline at end of file
...@@ -398,24 +398,24 @@ namespace Google.ProtocolBuffers ...@@ -398,24 +398,24 @@ namespace Google.ProtocolBuffers
{ {
// ClearExtension() is not actually used in TestUtil, so try it manually. // ClearExtension() is not actually used in TestUtil, so try it manually.
Assert.IsFalse(TestAllExtensions.CreateBuilder() Assert.IsFalse(TestAllExtensions.CreateBuilder()
.SetExtension(UnitTestProtoFile.OptionalInt32Extension, 1) .SetExtension(Unittest.OptionalInt32Extension, 1)
.ClearExtension(UnitTestProtoFile.OptionalInt32Extension) .ClearExtension(Unittest.OptionalInt32Extension)
.HasExtension(UnitTestProtoFile.OptionalInt32Extension)); .HasExtension(Unittest.OptionalInt32Extension));
Assert.AreEqual(0, TestAllExtensions.CreateBuilder() Assert.AreEqual(0, TestAllExtensions.CreateBuilder()
.AddExtension(UnitTestProtoFile.RepeatedInt32Extension, 1) .AddExtension(Unittest.RepeatedInt32Extension, 1)
.ClearExtension(UnitTestProtoFile.RepeatedInt32Extension) .ClearExtension(Unittest.RepeatedInt32Extension)
.GetExtensionCount(UnitTestProtoFile.RepeatedInt32Extension)); .GetExtensionCount(Unittest.RepeatedInt32Extension));
} }
[TestMethod] [TestMethod]
public void ExtensionMergeFrom() public void ExtensionMergeFrom()
{ {
TestAllExtensions original = TestAllExtensions.CreateBuilder() TestAllExtensions original = TestAllExtensions.CreateBuilder()
.SetExtension(UnitTestProtoFile.OptionalInt32Extension, 1).Build(); .SetExtension(Unittest.OptionalInt32Extension, 1).Build();
TestAllExtensions merged = TestAllExtensions merged =
TestAllExtensions.CreateBuilder().MergeFrom(original).Build(); TestAllExtensions.CreateBuilder().MergeFrom(original).Build();
Assert.IsTrue((merged.HasExtension(UnitTestProtoFile.OptionalInt32Extension))); Assert.IsTrue((merged.HasExtension(Unittest.OptionalInt32Extension)));
Assert.AreEqual(1, (int) merged.GetExtension(UnitTestProtoFile.OptionalInt32Extension)); Assert.AreEqual(1, (int) merged.GetExtension(Unittest.OptionalInt32Extension));
} }
/* Removed multiple files option for the moment /* Removed multiple files option for the moment
...@@ -430,13 +430,13 @@ namespace Google.ProtocolBuffers ...@@ -430,13 +430,13 @@ namespace Google.ProtocolBuffers
.Build(); .Build();
Assert.AreEqual(message, MessageWithNoOuter.ParseFrom(message.ToByteString())); Assert.AreEqual(message, MessageWithNoOuter.ParseFrom(message.ToByteString()));
Assert.AreEqual(MultiFileProto.Descriptor, MessageWithNoOuter.Descriptor.File); Assert.AreEqual(MultiFileProto.DescriptorProtoFile, MessageWithNoOuter.DescriptorProtoFile.File);
FieldDescriptor field = MessageWithNoOuter.Descriptor.FindDescriptor<FieldDescriptor>("foreign_enum"); FieldDescriptor field = MessageWithNoOuter.DescriptorProtoFile.FindDescriptor<FieldDescriptor>("foreign_enum");
Assert.AreEqual(MultiFileProto.Descriptor.FindTypeByName<EnumDescriptor>("EnumWithNoOuter") Assert.AreEqual(MultiFileProto.DescriptorProtoFile.FindTypeByName<EnumDescriptor>("EnumWithNoOuter")
.FindValueByNumber((int)EnumWithNoOuter.BAR), message[field]); .FindValueByNumber((int)EnumWithNoOuter.BAR), message[field]);
Assert.AreEqual(MultiFileProto.Descriptor, ServiceWithNoOuter.Descriptor.File); Assert.AreEqual(MultiFileProto.DescriptorProtoFile, ServiceWithNoOuter.DescriptorProtoFile.File);
Assert.IsFalse(TestAllExtensions.DefaultInstance.HasExtension(MultiFileProto.ExtensionWithOuter)); Assert.IsFalse(TestAllExtensions.DefaultInstance.HasExtension(MultiFileProto.ExtensionWithOuter));
}*/ }*/
...@@ -512,14 +512,14 @@ namespace Google.ProtocolBuffers ...@@ -512,14 +512,14 @@ namespace Google.ProtocolBuffers
{ {
Assert.AreEqual(TestRequired.SingleFieldNumber, 1000); Assert.AreEqual(TestRequired.SingleFieldNumber, 1000);
Assert.AreEqual(TestRequired.MultiFieldNumber, 1001); Assert.AreEqual(TestRequired.MultiFieldNumber, 1001);
Assert.AreEqual(UnitTestProtoFile.OptionalInt32ExtensionFieldNumber, 1); Assert.AreEqual(Unittest.OptionalInt32ExtensionFieldNumber, 1);
Assert.AreEqual(UnitTestProtoFile.OptionalGroupExtensionFieldNumber, 16); Assert.AreEqual(Unittest.OptionalGroupExtensionFieldNumber, 16);
Assert.AreEqual(UnitTestProtoFile.OptionalNestedMessageExtensionFieldNumber, 18); Assert.AreEqual(Unittest.OptionalNestedMessageExtensionFieldNumber, 18);
Assert.AreEqual(UnitTestProtoFile.OptionalNestedEnumExtensionFieldNumber, 21); Assert.AreEqual(Unittest.OptionalNestedEnumExtensionFieldNumber, 21);
Assert.AreEqual(UnitTestProtoFile.RepeatedInt32ExtensionFieldNumber, 31); Assert.AreEqual(Unittest.RepeatedInt32ExtensionFieldNumber, 31);
Assert.AreEqual(UnitTestProtoFile.RepeatedGroupExtensionFieldNumber, 46); Assert.AreEqual(Unittest.RepeatedGroupExtensionFieldNumber, 46);
Assert.AreEqual(UnitTestProtoFile.RepeatedNestedMessageExtensionFieldNumber, 48); Assert.AreEqual(Unittest.RepeatedNestedMessageExtensionFieldNumber, 48);
Assert.AreEqual(UnitTestProtoFile.RepeatedNestedEnumExtensionFieldNumber, 51); Assert.AreEqual(Unittest.RepeatedNestedEnumExtensionFieldNumber, 51);
} }
[TestMethod] [TestMethod]
......
...@@ -32,4 +32,4 @@ using System.Runtime.InteropServices; ...@@ -32,4 +32,4 @@ using System.Runtime.InteropServices;
// We don't really need CLSCompliance, but if the assembly builds with no warnings, // We don't really need CLSCompliance, but if the assembly builds with no warnings,
// that means the generator is okay. // that means the generator is okay.
[assembly: CLSCompliant(true)] [assembly: CLSCompliant(false)]
\ No newline at end of file \ No newline at end of file
...@@ -82,14 +82,23 @@ ...@@ -82,14 +82,23 @@
<Compile Include="Compatibility\TextCompatibilityTests.cs" /> <Compile Include="Compatibility\TextCompatibilityTests.cs" />
<Compile Include="Compatibility\XmlCompatibilityTests.cs" /> <Compile Include="Compatibility\XmlCompatibilityTests.cs" />
<Compile Include="SerializableAttribute.cs" /> <Compile Include="SerializableAttribute.cs" />
<Compile Include="TestProtos\UnitTestExtrasProtoFile.cs" /> <Compile Include="TestProtos\GoogleSize.cs" />
<Compile Include="TestProtos\GoogleSpeed.cs" />
<Compile Include="TestProtos\Unittest.cs" />
<Compile Include="TestProtos\UnittestCustomOptions.cs" />
<Compile Include="TestProtos\UnittestDropUnknownFields.cs" />
<Compile Include="TestProtos\UnittestEnormousDescriptor.cs" />
<Compile Include="TestProtos\UnittestExtrasXmltest.cs" />
<Compile Include="TestProtos\UnittestImport.cs" />
<Compile Include="TestProtos\UnittestImportPublic.cs" />
<Compile Include="TestProtos\UnittestIssues.cs" />
<Compile Include="TestProtos\UnittestMset.cs" />
<Compile Include="TestProtos\UnittestOptimizeFor.cs" />
<Compile Include="TestProtos\UnknownEnumTest.cs" />
<Compile Include="TestResources.cs" /> <Compile Include="TestResources.cs" />
<Compile Include="TestRpcForMimeTypes.cs" />
<Compile Include="TestReaderForUrlEncoded.cs" /> <Compile Include="TestReaderForUrlEncoded.cs" />
<Compile Include="CSharpOptionsTest.cs" />
<Compile Include="DeprecatedMemberTest.cs" /> <Compile Include="DeprecatedMemberTest.cs" />
<Compile Include="DescriptorsTest.cs" /> <Compile Include="DescriptorsTest.cs" />
<Compile Include="Descriptors\MessageDescriptorTest.cs" />
<Compile Include="DynamicMessageTest.cs" /> <Compile Include="DynamicMessageTest.cs" />
<Compile Include="ExtendableMessageTest.cs" /> <Compile Include="ExtendableMessageTest.cs" />
<Compile Include="GeneratedBuilderTest.cs" /> <Compile Include="GeneratedBuilderTest.cs" />
...@@ -104,26 +113,8 @@ ...@@ -104,26 +113,8 @@
<Compile Include="ReflectionTester.cs" /> <Compile Include="ReflectionTester.cs" />
<Compile Include="ReusableBuilderTest.cs" /> <Compile Include="ReusableBuilderTest.cs" />
<Compile Include="SerializableTest.cs" /> <Compile Include="SerializableTest.cs" />
<Compile Include="ServiceTest.cs" />
<Compile Include="TestCornerCases.cs" /> <Compile Include="TestCornerCases.cs" />
<Compile Include="TestMimeMessageFormats.cs" /> <Compile Include="TestMimeMessageFormats.cs" />
<Compile Include="TestProtos\UnitTestCSharpOptionsProtoFile.cs" />
<Compile Include="TestProtos\UnitTestCustomOptionsProtoFile.cs" />
<Compile Include="TestProtos\UnitTestEmbedOptimizeForProtoFile.cs" />
<Compile Include="TestProtos\UnitTestEmptyProtoFile.cs" />
<Compile Include="TestProtos\UnitTestExtrasIssuesProtoFile.cs" />
<Compile Include="TestProtos\UnitTestGenericServices.cs" />
<Compile Include="TestProtos\UnitTestGoogleSizeProtoFile.cs" />
<Compile Include="TestProtos\UnitTestGoogleSpeedProtoFile.cs" />
<Compile Include="TestProtos\UnitTestImportLiteProtoFile.cs" />
<Compile Include="TestProtos\UnitTestImportProtoFile.cs" />
<Compile Include="TestProtos\UnitTestMessageSetProtoFile.cs" />
<Compile Include="TestProtos\UnitTestNoGenericServicesProtoFile.cs" />
<Compile Include="TestProtos\UnitTestOptimizeForProtoFile.cs" />
<Compile Include="TestProtos\UnitTestProtoFile.cs" />
<Compile Include="TestProtos\UnitTestRpcInterop.cs" />
<Compile Include="TestProtos\UnitTestXmlSerializerTestProtoFile.cs" />
<Compile Include="TestRpcGenerator.cs" />
<Compile Include="TestUtil.cs" /> <Compile Include="TestUtil.cs" />
<Compile Include="TestWriterFormatJson.cs" /> <Compile Include="TestWriterFormatJson.cs" />
<Compile Include="TestWriterFormatXml.cs" /> <Compile Include="TestWriterFormatXml.cs" />
...@@ -162,6 +153,7 @@ ...@@ -162,6 +153,7 @@
<EmbeddedResource Include="Compatibility\google_message1.dat" /> <EmbeddedResource Include="Compatibility\google_message1.dat" />
<EmbeddedResource Include="Compatibility\google_message2.dat" /> <EmbeddedResource Include="Compatibility\google_message2.dat" />
</ItemGroup> </ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- 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. Other similar extension points exist, see Microsoft.Common.targets.
......
...@@ -97,10 +97,8 @@ namespace Google.ProtocolBuffers ...@@ -97,10 +97,8 @@ namespace Google.ProtocolBuffers
this.extensionRegistry = extensionRegistry; this.extensionRegistry = extensionRegistry;
this.file = baseDescriptor.File; this.file = baseDescriptor.File;
// TODO(jonskeet): We've got 2 dependencies, not 1 - because of the C# options. Hmm. Assert.AreEqual(1, file.Dependencies.Count);
// Assert.AreEqual(1, file.Dependencies.Count); this.importFile = file.Dependencies[0];
// TODO(jonskeet): Find dependency by name instead of number?
this.importFile = file.Dependencies[1];
MessageDescriptor testAllTypes; MessageDescriptor testAllTypes;
if (baseDescriptor.Name == "TestAllTypes") if (baseDescriptor.Name == "TestAllTypes")
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Runtime.Hosting;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Serialization.Formatters.Binary;
using System.Text; using System.Text;
...@@ -20,6 +21,7 @@ namespace Google.ProtocolBuffers ...@@ -20,6 +21,7 @@ namespace Google.ProtocolBuffers
public static readonly ISerializable CompileTimeCheckSerializableBuilder = new TestXmlMessage.Builder(); public static readonly ISerializable CompileTimeCheckSerializableBuilder = new TestXmlMessage.Builder();
[TestMethod] [TestMethod]
[Ignore] // Serialization hasn't been reimplemented yet
public void TestPlainMessage() public void TestPlainMessage()
{ {
TestXmlMessage message = TestXmlMessage.CreateBuilder() TestXmlMessage message = TestXmlMessage.CreateBuilder()
...@@ -53,6 +55,7 @@ namespace Google.ProtocolBuffers ...@@ -53,6 +55,7 @@ namespace Google.ProtocolBuffers
} }
[TestMethod] [TestMethod]
[Ignore] // Serialization hasn't been reimplemented yet
public void TestMessageWithExtensions() public void TestMessageWithExtensions()
{ {
TestXmlMessage message = TestXmlMessage.CreateBuilder() TestXmlMessage message = TestXmlMessage.CreateBuilder()
...@@ -74,16 +77,16 @@ namespace Google.ProtocolBuffers ...@@ -74,16 +77,16 @@ namespace Google.ProtocolBuffers
.AddChildren(TestXmlMessage.Types.Children.CreateBuilder() .AddChildren(TestXmlMessage.Types.Children.CreateBuilder()
.AddOptions(EnumOptions.THREE) .AddOptions(EnumOptions.THREE)
.SetBinary(ByteString.CopyFrom(new byte[3]))) .SetBinary(ByteString.CopyFrom(new byte[3])))
.SetExtension(UnitTestXmlSerializerTestProtoFile.ExtensionText, " extension text value ! ") .SetExtension(UnittestExtrasXmltest.ExtensionText, " extension text value ! ")
.SetExtension(UnitTestXmlSerializerTestProtoFile.ExtensionMessage, new TestXmlExtension.Builder().SetNumber(42).Build()) .SetExtension(UnittestExtrasXmltest.ExtensionMessage, new TestXmlExtension.Builder().SetNumber(42).Build())
.AddExtension(UnitTestXmlSerializerTestProtoFile.ExtensionNumber, 100) .AddExtension(UnittestExtrasXmltest.ExtensionNumber, 100)
.AddExtension(UnitTestXmlSerializerTestProtoFile.ExtensionNumber, 101) .AddExtension(UnittestExtrasXmltest.ExtensionNumber, 101)
.AddExtension(UnitTestXmlSerializerTestProtoFile.ExtensionNumber, 102) .AddExtension(UnittestExtrasXmltest.ExtensionNumber, 102)
.SetExtension(UnitTestXmlSerializerTestProtoFile.ExtensionEnum, EnumOptions.ONE) .SetExtension(UnittestExtrasXmltest.ExtensionEnum, EnumOptions.ONE)
.Build(); .Build();
ExtensionRegistry registry = ExtensionRegistry.CreateInstance(); ExtensionRegistry registry = ExtensionRegistry.CreateInstance();
UnitTestXmlSerializerTestProtoFile.RegisterAllExtensions(registry); UnittestExtrasXmltest.RegisterAllExtensions(registry);
MemoryStream ms = new MemoryStream(); MemoryStream ms = new MemoryStream();
new BinaryFormatter().Serialize(ms, message); new BinaryFormatter().Serialize(ms, message);
...@@ -98,6 +101,7 @@ namespace Google.ProtocolBuffers ...@@ -98,6 +101,7 @@ namespace Google.ProtocolBuffers
} }
[TestMethod] [TestMethod]
[Ignore] // Serialization hasn't been reimplemented yet
public void TestPlainBuilder() public void TestPlainBuilder()
{ {
TestXmlMessage.Builder builder = TestXmlMessage.CreateBuilder() TestXmlMessage.Builder builder = TestXmlMessage.CreateBuilder()
...@@ -131,6 +135,7 @@ namespace Google.ProtocolBuffers ...@@ -131,6 +135,7 @@ namespace Google.ProtocolBuffers
} }
[TestMethod] [TestMethod]
[Ignore] // Serialization hasn't been reimplemented yet
public void TestBuilderWithExtensions() public void TestBuilderWithExtensions()
{ {
TestXmlMessage.Builder builder = TestXmlMessage.CreateBuilder() TestXmlMessage.Builder builder = TestXmlMessage.CreateBuilder()
...@@ -152,16 +157,16 @@ namespace Google.ProtocolBuffers ...@@ -152,16 +157,16 @@ namespace Google.ProtocolBuffers
.AddChildren(TestXmlMessage.Types.Children.CreateBuilder() .AddChildren(TestXmlMessage.Types.Children.CreateBuilder()
.AddOptions(EnumOptions.THREE) .AddOptions(EnumOptions.THREE)
.SetBinary(ByteString.CopyFrom(new byte[3]))) .SetBinary(ByteString.CopyFrom(new byte[3])))
.SetExtension(UnitTestXmlSerializerTestProtoFile.ExtensionText, " extension text value ! ") .SetExtension(UnittestExtrasXmltest.ExtensionText, " extension text value ! ")
.SetExtension(UnitTestXmlSerializerTestProtoFile.ExtensionMessage, new TestXmlExtension.Builder().SetNumber(42).Build()) .SetExtension(UnittestExtrasXmltest.ExtensionMessage, new TestXmlExtension.Builder().SetNumber(42).Build())
.AddExtension(UnitTestXmlSerializerTestProtoFile.ExtensionNumber, 100) .AddExtension(UnittestExtrasXmltest.ExtensionNumber, 100)
.AddExtension(UnitTestXmlSerializerTestProtoFile.ExtensionNumber, 101) .AddExtension(UnittestExtrasXmltest.ExtensionNumber, 101)
.AddExtension(UnitTestXmlSerializerTestProtoFile.ExtensionNumber, 102) .AddExtension(UnittestExtrasXmltest.ExtensionNumber, 102)
.SetExtension(UnitTestXmlSerializerTestProtoFile.ExtensionEnum, EnumOptions.ONE) .SetExtension(UnittestExtrasXmltest.ExtensionEnum, EnumOptions.ONE)
; ;
ExtensionRegistry registry = ExtensionRegistry.CreateInstance(); ExtensionRegistry registry = ExtensionRegistry.CreateInstance();
UnitTestXmlSerializerTestProtoFile.RegisterAllExtensions(registry); UnittestExtrasXmltest.RegisterAllExtensions(registry);
MemoryStream ms = new MemoryStream(); MemoryStream ms = new MemoryStream();
new BinaryFormatter().Serialize(ms, builder); new BinaryFormatter().Serialize(ms, builder);
......
This diff is collapsed.
// Generated by ProtoGen, Version=2.4.1.555, Culture=neutral, PublicKeyToken=55f7125234beb589. DO NOT EDIT!
#pragma warning disable 1591, 0612, 3021
#region Designer generated code
using pb = global::Google.ProtocolBuffers;
using pbc = global::Google.ProtocolBuffers.Collections;
using pbd = global::Google.ProtocolBuffers.Descriptors;
using scg = global::System.Collections.Generic;
namespace Google.ProtocolBuffers.TestProtos {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public static partial class UnitTestEmptyProtoFile {
#region Extension registration
public static void RegisterAllExtensions(pb::ExtensionRegistry registry) {
}
#endregion
#region Static variables
#endregion
#region Descriptor
public static pbd::FileDescriptor Descriptor {
get { return descriptor; }
}
private static pbd::FileDescriptor descriptor;
static UnitTestEmptyProtoFile() {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"CiRnb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfZW1wdHkucHJvdG8aJGdvb2ds",
"ZS9wcm90b2J1Zi9jc2hhcnBfb3B0aW9ucy5wcm90b0I+wj47CiFHb29nbGUu",
"UHJvdG9jb2xCdWZmZXJzLlRlc3RQcm90b3MSFlVuaXRUZXN0RW1wdHlQcm90",
"b0ZpbGU="));
pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) {
descriptor = root;
pb::ExtensionRegistry registry = pb::ExtensionRegistry.CreateInstance();
RegisterAllExtensions(registry);
global::Google.ProtocolBuffers.DescriptorProtos.CSharpOptions.RegisterAllExtensions(registry);
return registry;
};
pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData,
new pbd::FileDescriptor[] {
global::Google.ProtocolBuffers.DescriptorProtos.CSharpOptions.Descriptor,
}, assigner);
}
#endregion
}
}
#endregion Designer generated code
// Generated by ProtoGen, Version=2.4.1.555, Culture=neutral, PublicKeyToken=55f7125234beb589. DO NOT EDIT! // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/unittest_import.proto
#pragma warning disable 1591, 0612, 3021 #pragma warning disable 1591, 0612, 3021
#region Designer generated code #region Designer generated code
...@@ -9,7 +10,7 @@ using scg = global::System.Collections.Generic; ...@@ -9,7 +10,7 @@ using scg = global::System.Collections.Generic;
namespace Google.ProtocolBuffers.TestProtos { namespace Google.ProtocolBuffers.TestProtos {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public static partial class UnitTestImportProtoFile { public static partial class UnittestImport {
#region Extension registration #region Extension registration
public static void RegisterAllExtensions(pb::ExtensionRegistry registry) { public static void RegisterAllExtensions(pb::ExtensionRegistry registry) {
...@@ -25,16 +26,16 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -25,16 +26,16 @@ namespace Google.ProtocolBuffers.TestProtos {
} }
private static pbd::FileDescriptor descriptor; private static pbd::FileDescriptor descriptor;
static UnitTestImportProtoFile() { static UnittestImport() {
byte[] descriptorData = global::System.Convert.FromBase64String( byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat( string.Concat(
"CiVnb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfaW1wb3J0LnByb3RvEhhwcm90", "CiVnb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfaW1wb3J0LnByb3RvEhhwcm90",
"b2J1Zl91bml0dGVzdF9pbXBvcnQaJGdvb2dsZS9wcm90b2J1Zi9jc2hhcnBf", "b2J1Zl91bml0dGVzdF9pbXBvcnQaLGdvb2dsZS9wcm90b2J1Zi91bml0dGVz",
"b3B0aW9ucy5wcm90byIaCg1JbXBvcnRNZXNzYWdlEgkKAWQYASABKAUqPAoK", "dF9pbXBvcnRfcHVibGljLnByb3RvIhoKDUltcG9ydE1lc3NhZ2USCQoBZBgB",
"SW1wb3J0RW51bRIOCgpJTVBPUlRfRk9PEAcSDgoKSU1QT1JUX0JBUhAIEg4K", "IAEoBSo8CgpJbXBvcnRFbnVtEg4KCklNUE9SVF9GT08QBxIOCgpJTVBPUlRf",
"CklNUE9SVF9CQVoQCUJbChhjb20uZ29vZ2xlLnByb3RvYnVmLnRlc3RIAcI+", "QkFSEAgSDgoKSU1QT1JUX0JBWhAJQkMKGGNvbS5nb29nbGUucHJvdG9idWYu",
"PAohR29vZ2xlLlByb3RvY29sQnVmZmVycy5UZXN0UHJvdG9zEhdVbml0VGVz", "dGVzdEgB+AEBqgIhR29vZ2xlLlByb3RvY29sQnVmZmVycy5UZXN0UHJvdG9z",
"dEltcG9ydFByb3RvRmlsZQ==")); "UAA="));
pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) {
descriptor = root; descriptor = root;
internal__static_protobuf_unittest_import_ImportMessage__Descriptor = Descriptor.MessageTypes[0]; internal__static_protobuf_unittest_import_ImportMessage__Descriptor = Descriptor.MessageTypes[0];
...@@ -43,12 +44,12 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -43,12 +44,12 @@ namespace Google.ProtocolBuffers.TestProtos {
new string[] { "D", }); new string[] { "D", });
pb::ExtensionRegistry registry = pb::ExtensionRegistry.CreateInstance(); pb::ExtensionRegistry registry = pb::ExtensionRegistry.CreateInstance();
RegisterAllExtensions(registry); RegisterAllExtensions(registry);
global::Google.ProtocolBuffers.DescriptorProtos.CSharpOptions.RegisterAllExtensions(registry); global::Google.ProtocolBuffers.TestProtos.UnittestImportPublic.RegisterAllExtensions(registry);
return registry; return registry;
}; };
pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData,
new pbd::FileDescriptor[] { new pbd::FileDescriptor[] {
global::Google.ProtocolBuffers.DescriptorProtos.CSharpOptions.Descriptor, global::Google.ProtocolBuffers.TestProtos.UnittestImportPublic.Descriptor,
}, assigner); }, assigner);
} }
#endregion #endregion
...@@ -83,11 +84,11 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -83,11 +84,11 @@ namespace Google.ProtocolBuffers.TestProtos {
} }
public static pbd::MessageDescriptor Descriptor { public static pbd::MessageDescriptor Descriptor {
get { return global::Google.ProtocolBuffers.TestProtos.UnitTestImportProtoFile.internal__static_protobuf_unittest_import_ImportMessage__Descriptor; } get { return global::Google.ProtocolBuffers.TestProtos.UnittestImport.internal__static_protobuf_unittest_import_ImportMessage__Descriptor; }
} }
protected override pb::FieldAccess.FieldAccessorTable<ImportMessage, ImportMessage.Builder> InternalFieldAccessors { protected override pb::FieldAccess.FieldAccessorTable<ImportMessage, ImportMessage.Builder> InternalFieldAccessors {
get { return global::Google.ProtocolBuffers.TestProtos.UnitTestImportProtoFile.internal__static_protobuf_unittest_import_ImportMessage__FieldAccessorTable; } get { return global::Google.ProtocolBuffers.TestProtos.UnittestImport.internal__static_protobuf_unittest_import_ImportMessage__FieldAccessorTable; }
} }
public const int DFieldNumber = 1; public const int DFieldNumber = 1;
...@@ -335,7 +336,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -335,7 +336,7 @@ namespace Google.ProtocolBuffers.TestProtos {
} }
} }
static ImportMessage() { static ImportMessage() {
object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnitTestImportProtoFile.Descriptor, null); object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestImport.Descriptor, null);
} }
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -88,7 +88,7 @@ namespace Google.ProtocolBuffers ...@@ -88,7 +88,7 @@ namespace Google.ProtocolBuffers
Content = sw.ToString(); Content = sw.ToString();
ExtensionRegistry registry = ExtensionRegistry.CreateInstance(); ExtensionRegistry registry = ExtensionRegistry.CreateInstance();
UnitTestXmlSerializerTestProtoFile.RegisterAllExtensions(registry); UnittestExtrasXmltest.RegisterAllExtensions(registry);
IMessageLite copy = IMessageLite copy =
JsonFormatReader.CreateInstance(Content) JsonFormatReader.CreateInstance(Content)
...@@ -258,7 +258,7 @@ namespace Google.ProtocolBuffers ...@@ -258,7 +258,7 @@ namespace Google.ProtocolBuffers
FormatterAssert( FormatterAssert(
TestXmlMessage.CreateBuilder() TestXmlMessage.CreateBuilder()
.SetValid(false) .SetValid(false)
.SetExtension(UnitTestXmlSerializerTestProtoFile.ExtensionText, " extension text value ! ") .SetExtension(UnittestExtrasXmltest.ExtensionText, " extension text value ! ")
.Build(), .Build(),
@"{""valid"":false,""extension_text"":"" extension text value ! ""}" @"{""valid"":false,""extension_text"":"" extension text value ! ""}"
); );
...@@ -269,7 +269,7 @@ namespace Google.ProtocolBuffers ...@@ -269,7 +269,7 @@ namespace Google.ProtocolBuffers
{ {
FormatterAssert( FormatterAssert(
TestXmlMessage.CreateBuilder() TestXmlMessage.CreateBuilder()
.SetExtension(UnitTestXmlSerializerTestProtoFile.ExtensionMessage, .SetExtension(UnittestExtrasXmltest.ExtensionMessage,
new TestXmlExtension.Builder().SetNumber(42).Build()) new TestXmlExtension.Builder().SetNumber(42).Build())
.Build(), .Build(),
@"{""number"":42}" @"{""number"":42}"
...@@ -281,9 +281,9 @@ namespace Google.ProtocolBuffers ...@@ -281,9 +281,9 @@ namespace Google.ProtocolBuffers
{ {
FormatterAssert( FormatterAssert(
TestXmlMessage.CreateBuilder() TestXmlMessage.CreateBuilder()
.AddExtension(UnitTestXmlSerializerTestProtoFile.ExtensionNumber, 100) .AddExtension(UnittestExtrasXmltest.ExtensionNumber, 100)
.AddExtension(UnitTestXmlSerializerTestProtoFile.ExtensionNumber, 101) .AddExtension(UnittestExtrasXmltest.ExtensionNumber, 101)
.AddExtension(UnitTestXmlSerializerTestProtoFile.ExtensionNumber, 102) .AddExtension(UnittestExtrasXmltest.ExtensionNumber, 102)
.Build(), .Build(),
@"{""extension_number"":[100,101,102]}" @"{""extension_number"":[100,101,102]}"
); );
...@@ -294,7 +294,7 @@ namespace Google.ProtocolBuffers ...@@ -294,7 +294,7 @@ namespace Google.ProtocolBuffers
{ {
FormatterAssert( FormatterAssert(
TestXmlMessage.CreateBuilder() TestXmlMessage.CreateBuilder()
.SetExtension(UnitTestXmlSerializerTestProtoFile.ExtensionEnum, EnumOptions.ONE) .SetExtension(UnittestExtrasXmltest.ExtensionEnum, EnumOptions.ONE)
.Build(), .Build(),
@"{""extension_enum"":""ONE""}" @"{""extension_enum"":""ONE""}"
); );
...@@ -307,12 +307,12 @@ namespace Google.ProtocolBuffers ...@@ -307,12 +307,12 @@ namespace Google.ProtocolBuffers
TestXmlMessage.CreateBuilder() TestXmlMessage.CreateBuilder()
.SetValid(true) .SetValid(true)
.SetText("text") .SetText("text")
.SetExtension(UnitTestXmlSerializerTestProtoFile.ExtensionText, "extension text") .SetExtension(UnittestExtrasXmltest.ExtensionText, "extension text")
.SetExtension(UnitTestXmlSerializerTestProtoFile.ExtensionMessage, new TestXmlExtension.Builder().SetNumber(42).Build()) .SetExtension(UnittestExtrasXmltest.ExtensionMessage, new TestXmlExtension.Builder().SetNumber(42).Build())
.AddExtension(UnitTestXmlSerializerTestProtoFile.ExtensionNumber, 100) .AddExtension(UnittestExtrasXmltest.ExtensionNumber, 100)
.AddExtension(UnitTestXmlSerializerTestProtoFile.ExtensionNumber, 101) .AddExtension(UnittestExtrasXmltest.ExtensionNumber, 101)
.AddExtension(UnitTestXmlSerializerTestProtoFile.ExtensionNumber, 102) .AddExtension(UnittestExtrasXmltest.ExtensionNumber, 102)
.SetExtension(UnitTestXmlSerializerTestProtoFile.ExtensionEnum, EnumOptions.ONE) .SetExtension(UnittestExtrasXmltest.ExtensionEnum, EnumOptions.ONE)
.Build(), .Build(),
@"""text"":""text""", @"""text"":""text""",
@"""valid"":true", @"""valid"":true",
...@@ -329,19 +329,19 @@ namespace Google.ProtocolBuffers ...@@ -329,19 +329,19 @@ namespace Google.ProtocolBuffers
TestXmlMessage original = TestXmlMessage.CreateBuilder() TestXmlMessage original = TestXmlMessage.CreateBuilder()
.SetValid(true) .SetValid(true)
.SetText("text") .SetText("text")
.SetExtension(UnitTestXmlSerializerTestProtoFile.ExtensionText, " extension text value ! ") .SetExtension(UnittestExtrasXmltest.ExtensionText, " extension text value ! ")
.SetExtension(UnitTestXmlSerializerTestProtoFile.ExtensionMessage, new TestXmlExtension.Builder().SetNumber(42).Build()) .SetExtension(UnittestExtrasXmltest.ExtensionMessage, new TestXmlExtension.Builder().SetNumber(42).Build())
.AddExtension(UnitTestXmlSerializerTestProtoFile.ExtensionNumber, 100) .AddExtension(UnittestExtrasXmltest.ExtensionNumber, 100)
.AddExtension(UnitTestXmlSerializerTestProtoFile.ExtensionNumber, 101) .AddExtension(UnittestExtrasXmltest.ExtensionNumber, 101)
.AddExtension(UnitTestXmlSerializerTestProtoFile.ExtensionNumber, 102) .AddExtension(UnittestExtrasXmltest.ExtensionNumber, 102)
.SetExtension(UnitTestXmlSerializerTestProtoFile.ExtensionEnum, EnumOptions.ONE) .SetExtension(UnittestExtrasXmltest.ExtensionEnum, EnumOptions.ONE)
.Build(); .Build();
TestXmlMessage message = original.ToBuilder() TestXmlMessage message = original.ToBuilder()
.ClearExtension(UnitTestXmlSerializerTestProtoFile.ExtensionText) .ClearExtension(UnittestExtrasXmltest.ExtensionText)
.ClearExtension(UnitTestXmlSerializerTestProtoFile.ExtensionMessage) .ClearExtension(UnittestExtrasXmltest.ExtensionMessage)
.ClearExtension(UnitTestXmlSerializerTestProtoFile.ExtensionNumber) .ClearExtension(UnittestExtrasXmltest.ExtensionNumber)
.ClearExtension(UnitTestXmlSerializerTestProtoFile.ExtensionEnum) .ClearExtension(UnittestExtrasXmltest.ExtensionEnum)
.Build(); .Build();
JsonFormatWriter writer = JsonFormatWriter.CreateInstance(); JsonFormatWriter writer = JsonFormatWriter.CreateInstance();
......
This diff is collapsed.
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