Skip to content

Commit

Permalink
Merge pull request #1 from google/csharp
Browse files Browse the repository at this point in the history
Csharp update
  • Loading branch information
anandolee committed Apr 28, 2015
2 parents 8a3ec53 + 32ead75 commit 8bae6c0
Show file tree
Hide file tree
Showing 81 changed files with 183,496 additions and 104,432 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,8 @@ src/**/*.trs
# JavaBuild output.
java/target
javanano/target

# Windows native output.
vsprojects/Debug
vsprojects/Release

37 changes: 0 additions & 37 deletions csharp/protos/extest/unittest_extras.proto

This file was deleted.

13 changes: 6 additions & 7 deletions csharp/protos/extest/unittest_extras_full.proto
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
// 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 {
Expand Down Expand Up @@ -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 {
Expand Down
14 changes: 6 additions & 8 deletions csharp/protos/extest/unittest_extras_lite.proto
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
// 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 {
Expand Down Expand Up @@ -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 */
Expand Down
7 changes: 3 additions & 4 deletions csharp/protos/extest/unittest_extras_xmltest.proto
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
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;

Expand Down
35 changes: 18 additions & 17 deletions csharp/protos/extest/unittest_generic_services.proto
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
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.
package protobuf_unittest;

// 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.
package protobuf_unittest;

option optimize_for = SPEED;

service TestGenericService {
rpc Foo(FooRequest) returns (FooResponse);
rpc Bar(BarRequest) returns (BarResponse);
}

service TestGenericServiceWithCustomOptions {
option (service_opt1) = -9876543210;

rpc Foo(CustomOptionFooRequest) returns (CustomOptionFooResponse) {
option (method_opt1) = METHODOPT1_VAL2;
}
}


service TestGenericServiceWithCustomOptions {
option (service_opt1) = -9876543210;

rpc Foo(CustomOptionFooRequest) returns (CustomOptionFooResponse) {
option (method_opt1) = METHODOPT1_VAL2;
}
}

36 changes: 20 additions & 16 deletions csharp/protos/extest/unittest_issues.proto
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
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;
Expand Down Expand Up @@ -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

// 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 A {
optional int32 _A = 1;
}
// message A {
// optional int32 _A = 1;
// }

message B {
optional int32 B_ = 1;
}
// message B {
// optional int32 B_ = 1;
// }

message AB {
optional int32 a_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

Expand Down
8 changes: 4 additions & 4 deletions csharp/src/ProtocolBuffers.Test/AbstractMessageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ public void UnpackedParsingOfPackedInputExtensions()
{
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);
}
Expand All @@ -143,7 +143,7 @@ public void PackedParsingOfUnpackedInputExtensions()
{
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);
}
Expand Down Expand Up @@ -250,7 +250,7 @@ public void EqualsAndHashCode()
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);
Expand Down
127 changes: 0 additions & 127 deletions csharp/src/ProtocolBuffers.Test/CSharpOptionsTest.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 8bae6c0

Please sign in to comment.