Skip to content

Commit

Permalink
Move C#-only test protos to csharp/protos
Browse files Browse the repository at this point in the history
unittest_proto3 had been changed in a very backward-incompatible
way which was never going to work with C# as it imports proto2 messages.

This is now a copy of the old file, but with a package name change for
compatibility with the remaining files in src/google/protobuf.

The other moves are for files that are only used by C#.
  • Loading branch information
jskeet committed Nov 12, 2017
1 parent 9a9a66e commit aa77eab
Show file tree
Hide file tree
Showing 8 changed files with 413 additions and 28 deletions.
5 changes: 5 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,13 @@ csharp_EXTRA_DIST= \
csharp/keys/Google.Protobuf.public.snk \
csharp/keys/Google.Protobuf.snk \
csharp/keys/README.md \
csharp/protos/README.md \
csharp/protos/map_unittest_proto3.proto \
csharp/protos/unittest_custom_options_proto3.proto \
csharp/protos/unittest_import_public_proto3.proto \
csharp/protos/unittest_import_proto3.proto \
csharp/protos/unittest_issues.proto \
csharp/protos/unittest_proto3.proto \
csharp/src/AddressBook/AddPerson.cs \
csharp/src/AddressBook/Addressbook.cs \
csharp/src/AddressBook/AddressBook.csproj \
Expand Down
30 changes: 11 additions & 19 deletions csharp/generate_protos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# You first need to make sure protoc has been built (see instructions on
# building protoc in root of this repository)

set -ex
set -e

# cd to repository root
pushd $(dirname $0)/..
Expand Down Expand Up @@ -40,28 +40,20 @@ $PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf \
src/google/protobuf/type.proto \
src/google/protobuf/wrappers.proto

# Test protos where the namespace matches the target location
$PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf.Test \
--csharp_opt=base_namespace=Google.Protobuf \
src/google/protobuf/map_unittest_proto3.proto \
src/google/protobuf/unittest_proto3.proto \
src/google/protobuf/unittest_import_proto3.proto \
src/google/protobuf/unittest_import_public_proto3.proto \
src/google/protobuf/unittest_well_known_types.proto

# Different base namespace to the protos above
$PROTOC -Isrc -Icsharp/protos --csharp_out=csharp/src/Google.Protobuf.Test \
--csharp_opt=base_namespace=UnitTest.Issues \
# Test protos
$PROTOC -Isrc -Icsharp/protos \
--csharp_out=csharp/src/Google.Protobuf.Test/TestProtos \
csharp/protos/map_unittest_proto3.proto \
csharp/protos/unittest_issues.proto \
csharp/protos/unittest_custom_options_proto3.proto

# Don't specify a base namespace at all; we just want to make sure the
# results end up in TestProtos.
$PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf.Test/TestProtos \
csharp/protos/unittest_custom_options_proto3.proto \
csharp/protos/unittest_proto3.proto \
csharp/protos/unittest_import_proto3.proto \
csharp/protos/unittest_import_public_proto3.proto \
src/google/protobuf/unittest_well_known_types.proto \
src/google/protobuf/test_messages_proto3.proto

# AddressBook sample protos
$PROTOC -Iexamples --csharp_out=csharp/src/AddressBook \
$PROTOC -Iexamples -Isrc --csharp_out=csharp/src/AddressBook \
examples/addressbook.proto

$PROTOC -Iconformance -Isrc --csharp_out=csharp/src/Google.Protobuf.Conformance \
Expand Down
3 changes: 3 additions & 0 deletions csharp/protos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This directory contains unit test protos adapted from those in
src/google/protobuf, and C#-specific test protos for regression
tests against bugs found in the C# codegen or library.
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@ syntax = "proto3";
option cc_enable_arenas = true;
option csharp_namespace = "Google.Protobuf.TestProtos";

import "google/protobuf/unittest_proto3.proto";
import "unittest_proto3.proto";

// 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.
// In map_test_util.h we do "using namespace unittest = protobuf_unittest".
package protobuf_unittest;
package protobuf_unittest3;

// Tests maps.
message TestMap {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ option csharp_namespace = "Google.Protobuf.TestProtos";
// one.

// Test public import
import public "google/protobuf/unittest_import_public_proto3.proto";
import public "unittest_import_public_proto3.proto";

message ImportMessage {
int32 d = 1;
Expand Down
Loading

0 comments on commit aa77eab

Please sign in to comment.