Commit 8bae6c09 authored by Jie Luo's avatar Jie Luo

Merge pull request #1 from google/csharp

Csharp update
parents 8a3ec53e 32ead755
......@@ -74,3 +74,8 @@ src/**/*.trs
# JavaBuild output.
java/target
javanano/target
# Windows native output.
vsprojects/Debug
vsprojects/Release
// 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
// 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";
syntax = "proto2";
package protobuf_unittest_extra;
option csharp_namespace = "Google.ProtocolBuffers.TestProtos";
option optimize_for = CODE_SIZE;
option java_package = "com.google.protobuf";
message TestInteropPerson {
......@@ -45,7 +41,10 @@ message TestInteropEmployeeId {
}
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 {
......
// 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 = "UnitTestExtrasLiteProtoFile";
option (google.protobuf.csharp_file_options).add_serializable = true;
syntax = "proto2";
package protobuf_unittest_extra;
option csharp_namespace = "Google.ProtocolBuffers.TestProtos";
option optimize_for = LITE_RUNTIME;
option java_package = "com.google.protobuf";
message TestRequiredLite {
......@@ -58,7 +53,10 @@ message TestInteropEmployeeIdLite {
}
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 */
......
import "google/protobuf/csharp_options.proto";
option (google.protobuf.csharp_file_options).namespace = "Google.ProtocolBuffers.TestProtos";
option (google.protobuf.csharp_file_options).umbrella_classname = "UnitTestXmlSerializerTestProtoFile";
option (google.protobuf.csharp_file_options).add_serializable = true;
syntax = "proto2";
option csharp_namespace = "Google.ProtocolBuffers.TestProtos";
package protobuf_unittest_extra;
......
syntax = "proto2";
// Additional options required for C# generation. File from copyright
// line onwards is as per original distribution.
import "google/protobuf/csharp_options.proto";
import "google/protobuf/unittest.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
// 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.
// 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
option (google.protobuf.csharp_file_options).namespace = "UnitTest.Issues.TestProtos";
option (google.protobuf.csharp_file_options).umbrella_classname = "UnitTestExtrasIssuesProtoFile";
option csharp_namespace = "UnitTest.Issues.TestProtos";
package unittest_issues;
option optimize_for = SPEED;
......@@ -67,24 +67,28 @@ service TestGenericService {
rpc Bar(TestBasicNoFields) returns (TestBasicMessage);
}
*/
// Issue 13: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=13
message A {
optional int32 _A = 1;
}
// Old issue 13: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=13
// New issue 309: https://github.com/google/protobuf/issues/309
message B {
optional int32 B_ = 1;
}
// message A {
// optional int32 _A = 1;
// }
message AB {
optional int32 a_b = 1;
}
// message B {
// optional int32 B_ = 1;
// }
//message AB {
// optional int32 a_b = 1;
//}
// Similar issue with numeric names
message NumberField {
optional int32 _01 = 1;
}
// Java code failed too, so probably best for this to be a restriction.
// 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
......
......@@ -132,8 +132,8 @@ namespace Google.ProtocolBuffers
{
byte[] bytes = TestUtil.GetPackedSet().ToByteArray();
ExtensionRegistry registry = ExtensionRegistry.CreateInstance();
UnitTestProtoFile.RegisterAllExtensions(registry);
UnitTestExtrasProtoFile.RegisterAllExtensions(registry);
Unittest.RegisterAllExtensions(registry);
UnittestImport.RegisterAllExtensions(registry);
TestUnpackedExtensions message = TestUnpackedExtensions.ParseFrom(bytes, registry);
TestUtil.AssertUnpackedExtensionsSet(message);
}
......@@ -143,7 +143,7 @@ namespace Google.ProtocolBuffers
{
byte[] bytes = TestUnpackedTypes.ParseFrom(TestUtil.GetPackedSet().ToByteArray()).ToByteArray();
ExtensionRegistry registry = ExtensionRegistry.CreateInstance();
UnitTestProtoFile.RegisterAllExtensions(registry);
Unittest.RegisterAllExtensions(registry);
TestPackedExtensions message = TestPackedExtensions.ParseFrom(bytes, registry);
TestUtil.AssertPackedExtensionsSet(message);
}
......@@ -250,7 +250,7 @@ namespace Google.ProtocolBuffers
TestAllTypes d = TestAllTypes.CreateBuilder(c).AddRepeatedString("y").Build();
TestAllExtensions e = TestUtil.GetAllExtensionsSet();
TestAllExtensions f = TestAllExtensions.CreateBuilder(e)
.AddExtension(UnitTestProtoFile.RepeatedInt32Extension, 999).Build();
.AddExtension(Unittest.RepeatedInt32Extension, 999).Build();
CheckEqualsIsConsistent(a);
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
{
/// <summary>
/// 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.
/// </summary>
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
{
// ClearExtension() is not actually used in TestUtil, so try it manually.
Assert.IsFalse(TestAllExtensions.CreateBuilder()
.SetExtension(UnitTestProtoFile.OptionalInt32Extension, 1)
.ClearExtension(UnitTestProtoFile.OptionalInt32Extension)
.HasExtension(UnitTestProtoFile.OptionalInt32Extension));
.SetExtension(Unittest.OptionalInt32Extension, 1)
.ClearExtension(Unittest.OptionalInt32Extension)
.HasExtension(Unittest.OptionalInt32Extension));
Assert.AreEqual(0, TestAllExtensions.CreateBuilder()
.AddExtension(UnitTestProtoFile.RepeatedInt32Extension, 1)
.ClearExtension(UnitTestProtoFile.RepeatedInt32Extension)
.GetExtensionCount(UnitTestProtoFile.RepeatedInt32Extension));
.AddExtension(Unittest.RepeatedInt32Extension, 1)
.ClearExtension(Unittest.RepeatedInt32Extension)
.GetExtensionCount(Unittest.RepeatedInt32Extension));
}
[TestMethod]
public void ExtensionMergeFrom()
{
TestAllExtensions original = TestAllExtensions.CreateBuilder()
.SetExtension(UnitTestProtoFile.OptionalInt32Extension, 1).Build();
.SetExtension(Unittest.OptionalInt32Extension, 1).Build();
TestAllExtensions merged =
TestAllExtensions.CreateBuilder().MergeFrom(original).Build();
Assert.IsTrue((merged.HasExtension(UnitTestProtoFile.OptionalInt32Extension)));
Assert.AreEqual(1, (int) merged.GetExtension(UnitTestProtoFile.OptionalInt32Extension));
Assert.IsTrue((merged.HasExtension(Unittest.OptionalInt32Extension)));
Assert.AreEqual(1, (int) merged.GetExtension(Unittest.OptionalInt32Extension));
}
/* Removed multiple files option for the moment
......@@ -430,13 +430,13 @@ namespace Google.ProtocolBuffers
.Build();
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");
Assert.AreEqual(MultiFileProto.Descriptor.FindTypeByName<EnumDescriptor>("EnumWithNoOuter")
FieldDescriptor field = MessageWithNoOuter.DescriptorProtoFile.FindDescriptor<FieldDescriptor>("foreign_enum");
Assert.AreEqual(MultiFileProto.DescriptorProtoFile.FindTypeByName<EnumDescriptor>("EnumWithNoOuter")
.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));
}*/
......@@ -512,14 +512,14 @@ namespace Google.ProtocolBuffers
{
Assert.AreEqual(TestRequired.SingleFieldNumber, 1000);
Assert.AreEqual(TestRequired.MultiFieldNumber, 1001);
Assert.AreEqual(UnitTestProtoFile.OptionalInt32ExtensionFieldNumber, 1);
Assert.AreEqual(UnitTestProtoFile.OptionalGroupExtensionFieldNumber, 16);
Assert.AreEqual(UnitTestProtoFile.OptionalNestedMessageExtensionFieldNumber, 18);
Assert.AreEqual(UnitTestProtoFile.OptionalNestedEnumExtensionFieldNumber, 21);
Assert.AreEqual(UnitTestProtoFile.RepeatedInt32ExtensionFieldNumber, 31);
Assert.AreEqual(UnitTestProtoFile.RepeatedGroupExtensionFieldNumber, 46);
Assert.AreEqual(UnitTestProtoFile.RepeatedNestedMessageExtensionFieldNumber, 48);
Assert.AreEqual(UnitTestProtoFile.RepeatedNestedEnumExtensionFieldNumber, 51);
Assert.AreEqual(Unittest.OptionalInt32ExtensionFieldNumber, 1);
Assert.AreEqual(Unittest.OptionalGroupExtensionFieldNumber, 16);
Assert.AreEqual(Unittest.OptionalNestedMessageExtensionFieldNumber, 18);
Assert.AreEqual(Unittest.OptionalNestedEnumExtensionFieldNumber, 21);
Assert.AreEqual(Unittest.RepeatedInt32ExtensionFieldNumber, 31);
Assert.AreEqual(Unittest.RepeatedGroupExtensionFieldNumber, 46);
Assert.AreEqual(Unittest.RepeatedNestedMessageExtensionFieldNumber, 48);
Assert.AreEqual(Unittest.RepeatedNestedEnumExtensionFieldNumber, 51);
}
[TestMethod]
......
......@@ -32,4 +32,4 @@ using System.Runtime.InteropServices;
// We don't really need CLSCompliance, but if the assembly builds with no warnings,
// that means the generator is okay.
[assembly: CLSCompliant(true)]
\ No newline at end of file
[assembly: CLSCompliant(false)]
\ No newline at end of file
......@@ -82,14 +82,23 @@
<Compile Include="Compatibility\TextCompatibilityTests.cs" />
<Compile Include="Compatibility\XmlCompatibilityTests.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="TestRpcForMimeTypes.cs" />
<Compile Include="TestReaderForUrlEncoded.cs" />
<Compile Include="CSharpOptionsTest.cs" />
<Compile Include="DeprecatedMemberTest.cs" />
<Compile Include="DescriptorsTest.cs" />
<Compile Include="Descriptors\MessageDescriptorTest.cs" />
<Compile Include="DynamicMessageTest.cs" />
<Compile Include="ExtendableMessageTest.cs" />
<Compile Include="GeneratedBuilderTest.cs" />
......@@ -104,26 +113,8 @@
<Compile Include="ReflectionTester.cs" />
<Compile Include="ReusableBuilderTest.cs" />
<Compile Include="SerializableTest.cs" />
<Compile Include="ServiceTest.cs" />
<Compile Include="TestCornerCases.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="TestWriterFormatJson.cs" />
<Compile Include="TestWriterFormatXml.cs" />
......@@ -162,6 +153,7 @@
<EmbeddedResource Include="Compatibility\google_message1.dat" />
<EmbeddedResource Include="Compatibility\google_message2.dat" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- 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.
......
......@@ -97,10 +97,8 @@ namespace Google.ProtocolBuffers
this.extensionRegistry = extensionRegistry;
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);
// TODO(jonskeet): Find dependency by name instead of number?
this.importFile = file.Dependencies[1];
Assert.AreEqual(1, file.Dependencies.Count);
this.importFile = file.Dependencies[0];
MessageDescriptor testAllTypes;
if (baseDescriptor.Name == "TestAllTypes")
......
......@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Hosting;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
......@@ -20,6 +21,7 @@ namespace Google.ProtocolBuffers
public static readonly ISerializable CompileTimeCheckSerializableBuilder = new TestXmlMessage.Builder();
[TestMethod]
[Ignore] // Serialization hasn't been reimplemented yet
public void TestPlainMessage()
{
TestXmlMessage message = TestXmlMessage.CreateBuilder()
......@@ -53,6 +55,7 @@ namespace Google.ProtocolBuffers
}
[TestMethod]
[Ignore] // Serialization hasn't been reimplemented yet
public void TestMessageWithExtensions()
{
TestXmlMessage message = TestXmlMessage.CreateBuilder()
......@@ -74,16 +77,16 @@ namespace Google.ProtocolBuffers
.AddChildren(TestXmlMessage.Types.Children.CreateBuilder()
.AddOptions(EnumOptions.THREE)
.SetBinary(ByteString.CopyFrom(new byte[3])))
.SetExtension(UnitTestXmlSerializerTestProtoFile.ExtensionText, " extension text value ! ")
.SetExtension(UnitTestXmlSerializerTestProtoFile.ExtensionMessage, new TestXmlExtension.Builder().SetNumber(42).Build())
.AddExtension(UnitTestXmlSerializerTestProtoFile.ExtensionNumber, 100)
.AddExtension(UnitTestXmlSerializerTestProtoFile.ExtensionNumber, 101)
.AddExtension(UnitTestXmlSerializerTestProtoFile.ExtensionNumber, 102)
.SetExtension(UnitTestXmlSerializerTestProtoFile.ExtensionEnum, EnumOptions.ONE)
.SetExtension(UnittestExtrasXmltest.ExtensionText, " extension text value ! ")
.SetExtension(UnittestExtrasXmltest.ExtensionMessage, new TestXmlExtension.Builder().SetNumber(42).Build())
.AddExtension(UnittestExtrasXmltest.ExtensionNumber, 100)
.AddExtension(UnittestExtrasXmltest.ExtensionNumber, 101)
.AddExtension(UnittestExtrasXmltest.ExtensionNumber, 102)
.SetExtension(UnittestExtrasXmltest.ExtensionEnum, EnumOptions.ONE)
.Build();
ExtensionRegistry registry = ExtensionRegistry.CreateInstance();
UnitTestXmlSerializerTestProtoFile.RegisterAllExtensions(registry);
UnittestExtrasXmltest.RegisterAllExtensions(registry);
MemoryStream ms = new MemoryStream();
new BinaryFormatter().Serialize(ms, message);
......@@ -98,6 +101,7 @@ namespace Google.ProtocolBuffers
}
[TestMethod]
[Ignore] // Serialization hasn't been reimplemented yet
public void TestPlainBuilder()
{
TestXmlMessage.Builder builder = TestXmlMessage.CreateBuilder()
......@@ -131,6 +135,7 @@ namespace Google.ProtocolBuffers
}
[TestMethod]
[Ignore] // Serialization hasn't been reimplemented yet
public void TestBuilderWithExtensions()
{
TestXmlMessage.Builder builder = TestXmlMessage.CreateBuilder()
......@@ -152,16 +157,16 @@ namespace Google.ProtocolBuffers
.AddChildren(TestXmlMessage.Types.Children.CreateBuilder()
.AddOptions(EnumOptions.THREE)
.SetBinary(ByteString.CopyFrom(new byte[3])))
.SetExtension(UnitTestXmlSerializerTestProtoFile.ExtensionText, " extension text value ! ")
.SetExtension(UnitTestXmlSerializerTestProtoFile.ExtensionMessage, new TestXmlExtension.Builder().SetNumber(42).Build())
.AddExtension(UnitTestXmlSerializerTestProtoFile.ExtensionNumber, 100)
.AddExtension(UnitTestXmlSerializerTestProtoFile.ExtensionNumber, 101)
.AddExtension(UnitTestXmlSerializerTestProtoFile.ExtensionNumber, 102)
.SetExtension(UnitTestXmlSerializerTestProtoFile.ExtensionEnum, EnumOptions.ONE)
.SetExtension(UnittestExtrasXmltest.ExtensionText, " extension text value ! ")
.SetExtension(UnittestExtrasXmltest.ExtensionMessage, new TestXmlExtension.Builder().SetNumber(42).Build())
.AddExtension(UnittestExtrasXmltest.ExtensionNumber, 100)
.AddExtension(UnittestExtrasXmltest.ExtensionNumber, 101)
.AddExtension(UnittestExtrasXmltest.ExtensionNumber, 102)
.SetExtension(UnittestExtrasXmltest.ExtensionEnum, EnumOptions.ONE)
;
ExtensionRegistry registry = ExtensionRegistry.CreateInstance();
UnitTestXmlSerializerTestProtoFile.RegisterAllExtensions(registry);
UnittestExtrasXmltest.RegisterAllExtensions(registry);
MemoryStream ms = new MemoryStream();
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
#region Designer generated code
......@@ -9,7 +10,7 @@ using scg = global::System.Collections.Generic;
namespace Google.ProtocolBuffers.TestProtos {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public static partial class UnitTestImportProtoFile {
public static partial class UnittestImport {
#region Extension registration
public static void RegisterAllExtensions(pb::ExtensionRegistry registry) {
......@@ -25,16 +26,16 @@ namespace Google.ProtocolBuffers.TestProtos {
}
private static pbd::FileDescriptor descriptor;
static UnitTestImportProtoFile() {
static UnittestImport() {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"CiVnb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfaW1wb3J0LnByb3RvEhhwcm90",
"b2J1Zl91bml0dGVzdF9pbXBvcnQaJGdvb2dsZS9wcm90b2J1Zi9jc2hhcnBf",
"b3B0aW9ucy5wcm90byIaCg1JbXBvcnRNZXNzYWdlEgkKAWQYASABKAUqPAoK",
"SW1wb3J0RW51bRIOCgpJTVBPUlRfRk9PEAcSDgoKSU1QT1JUX0JBUhAIEg4K",
"CklNUE9SVF9CQVoQCUJbChhjb20uZ29vZ2xlLnByb3RvYnVmLnRlc3RIAcI+",
"PAohR29vZ2xlLlByb3RvY29sQnVmZmVycy5UZXN0UHJvdG9zEhdVbml0VGVz",
"dEltcG9ydFByb3RvRmlsZQ=="));
"b2J1Zl91bml0dGVzdF9pbXBvcnQaLGdvb2dsZS9wcm90b2J1Zi91bml0dGVz",
"dF9pbXBvcnRfcHVibGljLnByb3RvIhoKDUltcG9ydE1lc3NhZ2USCQoBZBgB",
"IAEoBSo8CgpJbXBvcnRFbnVtEg4KCklNUE9SVF9GT08QBxIOCgpJTVBPUlRf",
"QkFSEAgSDgoKSU1QT1JUX0JBWhAJQkMKGGNvbS5nb29nbGUucHJvdG9idWYu",
"dGVzdEgB+AEBqgIhR29vZ2xlLlByb3RvY29sQnVmZmVycy5UZXN0UHJvdG9z",
"UAA="));
pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) {
descriptor = root;
internal__static_protobuf_unittest_import_ImportMessage__Descriptor = Descriptor.MessageTypes[0];
......@@ -43,12 +44,12 @@ namespace Google.ProtocolBuffers.TestProtos {
new string[] { "D", });
pb::ExtensionRegistry registry = pb::ExtensionRegistry.CreateInstance();
RegisterAllExtensions(registry);
global::Google.ProtocolBuffers.DescriptorProtos.CSharpOptions.RegisterAllExtensions(registry);
global::Google.ProtocolBuffers.TestProtos.UnittestImportPublic.RegisterAllExtensions(registry);
return registry;
};
pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData,
new pbd::FileDescriptor[] {
global::Google.ProtocolBuffers.DescriptorProtos.CSharpOptions.Descriptor,
global::Google.ProtocolBuffers.TestProtos.UnittestImportPublic.Descriptor,
}, assigner);
}
#endregion
......@@ -83,11 +84,11 @@ namespace Google.ProtocolBuffers.TestProtos {
}
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 {
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;
......@@ -335,7 +336,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
}
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.
......@@ -315,7 +315,7 @@ namespace Google.ProtocolBuffers
public void TestXmlWithExtensionText()
{
TestXmlMessage message = TestXmlMessage.CreateBuilder()
.SetExtension(UnitTestXmlSerializerTestProtoFile.ExtensionText, " extension text value ! ")
.SetExtension(UnittestExtrasXmltest.ExtensionText, " extension text value ! ")
.Build();
StringWriter sw = new StringWriter();
......@@ -324,7 +324,7 @@ namespace Google.ProtocolBuffers
string xml = sw.ToString();
ExtensionRegistry registry = ExtensionRegistry.CreateInstance();
UnitTestXmlSerializerTestProtoFile.RegisterAllExtensions(registry);
UnittestExtrasXmltest.RegisterAllExtensions(registry);
XmlFormatReader rdr = XmlFormatReader.CreateInstance(xml);
TestXmlMessage copy = rdr.Merge(TestXmlMessage.CreateBuilder(), registry).Build();
......@@ -334,7 +334,7 @@ namespace Google.ProtocolBuffers
public void TestXmlWithExtensionMessage()
{
TestXmlMessage message = TestXmlMessage.CreateBuilder()
.SetExtension(UnitTestXmlSerializerTestProtoFile.ExtensionMessage,
.SetExtension(UnittestExtrasXmltest.ExtensionMessage,
new TestXmlExtension.Builder().SetNumber(42).Build()).Build();
StringWriter sw = new StringWriter();
......@@ -343,7 +343,7 @@ namespace Google.ProtocolBuffers
string xml = sw.ToString();
ExtensionRegistry registry = ExtensionRegistry.CreateInstance();
UnitTestXmlSerializerTestProtoFile.RegisterAllExtensions(registry);
UnittestExtrasXmltest.RegisterAllExtensions(registry);
XmlFormatReader rdr = XmlFormatReader.CreateInstance(xml);
TestXmlMessage copy = rdr.Merge(TestXmlMessage.CreateBuilder(), registry).Build();
......@@ -353,9 +353,9 @@ namespace Google.ProtocolBuffers
public void TestXmlWithExtensionArray()
{
TestXmlMessage message = TestXmlMessage.CreateBuilder()
.AddExtension(UnitTestXmlSerializerTestProtoFile.ExtensionNumber, 100)
.AddExtension(UnitTestXmlSerializerTestProtoFile.ExtensionNumber, 101)
.AddExtension(UnitTestXmlSerializerTestProtoFile.ExtensionNumber, 102)
.AddExtension(UnittestExtrasXmltest.ExtensionNumber, 100)
.AddExtension(UnittestExtrasXmltest.ExtensionNumber, 101)
.AddExtension(UnittestExtrasXmltest.ExtensionNumber, 102)
.Build();
StringWriter sw = new StringWriter();
......@@ -364,7 +364,7 @@ namespace Google.ProtocolBuffers
string xml = sw.ToString();
ExtensionRegistry registry = ExtensionRegistry.CreateInstance();
UnitTestXmlSerializerTestProtoFile.RegisterAllExtensions(registry);
UnittestExtrasXmltest.RegisterAllExtensions(registry);
XmlFormatReader rdr = XmlFormatReader.CreateInstance(xml);
TestXmlMessage copy = rdr.Merge(TestXmlMessage.CreateBuilder(), registry).Build();
......@@ -374,7 +374,7 @@ namespace Google.ProtocolBuffers
public void TestXmlWithExtensionEnum()
{
TestXmlMessage message = TestXmlMessage.CreateBuilder()
.SetExtension(UnitTestXmlSerializerTestProtoFile.ExtensionEnum, EnumOptions.ONE)
.SetExtension(UnittestExtrasXmltest.ExtensionEnum, EnumOptions.ONE)
.Build();
StringWriter sw = new StringWriter();
......@@ -383,7 +383,7 @@ namespace Google.ProtocolBuffers
string xml = sw.ToString();
ExtensionRegistry registry = ExtensionRegistry.CreateInstance();
UnitTestXmlSerializerTestProtoFile.RegisterAllExtensions(registry);
UnittestExtrasXmltest.RegisterAllExtensions(registry);
XmlFormatReader rdr = XmlFormatReader.CreateInstance(xml);
TestXmlMessage copy = rdr.Merge(TestXmlMessage.CreateBuilder(), registry).Build();
......
......@@ -334,9 +334,9 @@ namespace Google.ProtocolBuffers
TestAllExtensions message =
TestAllExtensions.ParseFrom(data, TestUtil.CreateExtensionRegistry());
Assert.AreEqual(TestAllTypes.Types.NestedEnum.BAR,
message.GetExtension(UnitTestProtoFile.OptionalNestedEnumExtension));
message.GetExtension(Unittest.OptionalNestedEnumExtension));
TestUtil.AssertEqual(new[] {TestAllTypes.Types.NestedEnum.FOO, TestAllTypes.Types.NestedEnum.BAZ},
message.GetExtension(UnitTestProtoFile.RepeatedNestedEnumExtension));
message.GetExtension(Unittest.RepeatedNestedEnumExtension));
TestUtil.AssertEqual(new[] {5UL}, message.UnknownFields[singularField.FieldNumber].VarintList);
TestUtil.AssertEqual(new[] {4UL, 6UL}, message.UnknownFields[repeatedField.FieldNumber].VarintList);
}
......
......@@ -68,7 +68,6 @@
<Compile Include="Collections\Dictionaries.cs" />
<Compile Include="Collections\Lists.cs" />
<Compile Include="Collections\ReadOnlyDictionary.cs" />
<Compile Include="DescriptorProtos\CSharpOptions.cs" />
<Compile Include="DescriptorProtos\DescriptorProtoFile.cs" />
<Compile Include="DescriptorProtos\IDescriptorProto.cs" />
<Compile Include="DescriptorProtos\PartialClasses.cs" />
......
This diff is collapsed.
This diff is collapsed.
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