From 008dc92c9d32abcf608883ae44d5a78f59a4e3c2 Mon Sep 17 00:00:00 2001 From: Ewout Date: Thu, 9 Mar 2017 20:47:56 +0100 Subject: Ruby version optionally emits default values in JSON encoding. Usage: Message.encode_json(m, emit_defaults: true) Message fields that are nil will still not appear in the encoded JSON. --- ruby/ext/google/protobuf_c/encode_decode.c | 59 +++++++++++++++--------------- ruby/tests/basic.rb | 38 +++++++++++++++++++ 2 files changed, 68 insertions(+), 29 deletions(-) diff --git a/ruby/ext/google/protobuf_c/encode_decode.c b/ruby/ext/google/protobuf_c/encode_decode.c index d86a1145..6ce6d083 100644 --- a/ruby/ext/google/protobuf_c/encode_decode.c +++ b/ruby/ext/google/protobuf_c/encode_decode.c @@ -914,13 +914,9 @@ void stringsink_uninit(stringsink *sink) { // semantics, which means that we have true field presence, we will want to // modify msgvisitor so that it emits all present fields rather than all // non-default-value fields. -// -// Likewise, when implementing JSON serialization, we may need to have a -// 'verbose' mode that outputs all fields and a 'concise' mode that outputs only -// those with non-default values. static void putmsg(VALUE msg, const Descriptor* desc, - upb_sink *sink, int depth); + upb_sink *sink, int depth, bool emit_defaults); static upb_selector_t getsel(const upb_fielddef *f, upb_handlertype_t type) { upb_selector_t ret; @@ -952,7 +948,7 @@ static void putstr(VALUE str, const upb_fielddef *f, upb_sink *sink) { } static void putsubmsg(VALUE submsg, const upb_fielddef *f, upb_sink *sink, - int depth) { + int depth, bool emit_defaults) { upb_sink subsink; VALUE descriptor; Descriptor* subdesc; @@ -963,12 +959,12 @@ static void putsubmsg(VALUE submsg, const upb_fielddef *f, upb_sink *sink, subdesc = ruby_to_Descriptor(descriptor); upb_sink_startsubmsg(sink, getsel(f, UPB_HANDLER_STARTSUBMSG), &subsink); - putmsg(submsg, subdesc, &subsink, depth + 1); + putmsg(submsg, subdesc, &subsink, depth + 1, emit_defaults); upb_sink_endsubmsg(sink, getsel(f, UPB_HANDLER_ENDSUBMSG)); } static void putary(VALUE ary, const upb_fielddef *f, upb_sink *sink, - int depth) { + int depth, bool emit_defaults) { upb_sink subsink; upb_fieldtype_t type = upb_fielddef_type(f); upb_selector_t sel = 0; @@ -1005,7 +1001,7 @@ static void putary(VALUE ary, const upb_fielddef *f, upb_sink *sink, putstr(*((VALUE *)memory), f, &subsink); break; case UPB_TYPE_MESSAGE: - putsubmsg(*((VALUE *)memory), f, &subsink, depth); + putsubmsg(*((VALUE *)memory), f, &subsink, depth, emit_defaults); break; #undef T @@ -1019,7 +1015,8 @@ static void put_ruby_value(VALUE value, const upb_fielddef *f, VALUE type_class, int depth, - upb_sink *sink) { + upb_sink *sink, + bool emit_defaults) { upb_selector_t sel = 0; if (upb_fielddef_isprimitive(f)) { sel = getsel(f, upb_handlers_getprimitivehandlertype(f)); @@ -1059,12 +1056,12 @@ static void put_ruby_value(VALUE value, putstr(value, f, sink); break; case UPB_TYPE_MESSAGE: - putsubmsg(value, f, sink, depth); + putsubmsg(value, f, sink, depth, emit_defaults); } } static void putmap(VALUE map, const upb_fielddef *f, upb_sink *sink, - int depth) { + int depth, bool emit_defaults) { Map* self; upb_sink subsink; const upb_fielddef* key_field; @@ -1090,9 +1087,9 @@ static void putmap(VALUE map, const upb_fielddef *f, upb_sink *sink, &entry_sink); upb_sink_startmsg(&entry_sink); - put_ruby_value(key, key_field, Qnil, depth + 1, &entry_sink); + put_ruby_value(key, key_field, Qnil, depth + 1, &entry_sink, emit_defaults); put_ruby_value(value, value_field, self->value_type_class, depth + 1, - &entry_sink); + &entry_sink, emit_defaults); upb_sink_endmsg(&entry_sink, &status); upb_sink_endsubmsg(&subsink, getsel(f, UPB_HANDLER_ENDSUBMSG)); @@ -1102,7 +1099,7 @@ static void putmap(VALUE map, const upb_fielddef *f, upb_sink *sink, } static void putmsg(VALUE msg_rb, const Descriptor* desc, - upb_sink *sink, int depth) { + upb_sink *sink, int depth, bool emit_defaults) { MessageHeader* msg; upb_msg_field_iter i; upb_status status; @@ -1144,31 +1141,31 @@ static void putmsg(VALUE msg_rb, const Descriptor* desc, if (is_map_field(f)) { VALUE map = DEREF(msg, offset, VALUE); - if (map != Qnil) { - putmap(map, f, sink, depth); + if (map != Qnil || emit_defaults) { + putmap(map, f, sink, depth, emit_defaults); } } else if (upb_fielddef_isseq(f)) { VALUE ary = DEREF(msg, offset, VALUE); if (ary != Qnil) { - putary(ary, f, sink, depth); + putary(ary, f, sink, depth, emit_defaults); } } else if (upb_fielddef_isstring(f)) { VALUE str = DEREF(msg, offset, VALUE); - if (is_matching_oneof || RSTRING_LEN(str) > 0) { + if (is_matching_oneof || emit_defaults || RSTRING_LEN(str) > 0) { putstr(str, f, sink); } } else if (upb_fielddef_issubmsg(f)) { - putsubmsg(DEREF(msg, offset, VALUE), f, sink, depth); + putsubmsg(DEREF(msg, offset, VALUE), f, sink, depth, emit_defaults); } else { upb_selector_t sel = getsel(f, upb_handlers_getprimitivehandlertype(f)); -#define T(upbtypeconst, upbtype, ctype, default_value) \ - case upbtypeconst: { \ - ctype value = DEREF(msg, offset, ctype); \ - if (is_matching_oneof || value != default_value) { \ - upb_sink_put##upbtype(sink, sel, value); \ - } \ - } \ +#define T(upbtypeconst, upbtype, ctype, default_value) \ + case upbtypeconst: { \ + ctype value = DEREF(msg, offset, ctype); \ + if (is_matching_oneof || emit_defaults || value != default_value) { \ + upb_sink_put##upbtype(sink, sel, value); \ + } \ + } \ break; switch (upb_fielddef_type(f)) { @@ -1246,7 +1243,7 @@ VALUE Message_encode(VALUE klass, VALUE msg_rb) { stackenv_init(&se, "Error occurred during encoding: %s"); encoder = upb_pb_encoder_create(&se.env, serialize_handlers, &sink.sink); - putmsg(msg_rb, desc, upb_pb_encoder_input(encoder), 0); + putmsg(msg_rb, desc, upb_pb_encoder_input(encoder), 0, false); ret = rb_str_new(sink.ptr, sink.len); @@ -1268,6 +1265,7 @@ VALUE Message_encode_json(int argc, VALUE* argv, VALUE klass) { Descriptor* desc = ruby_to_Descriptor(descriptor); VALUE msg_rb; VALUE preserve_proto_fieldnames = Qfalse; + VALUE emit_defaults = Qfalse; stringsink sink; if (argc < 1 || argc > 2) { @@ -1283,6 +1281,9 @@ VALUE Message_encode_json(int argc, VALUE* argv, VALUE klass) { } preserve_proto_fieldnames = rb_hash_lookup2( hash_args, ID2SYM(rb_intern("preserve_proto_fieldnames")), Qfalse); + + emit_defaults = rb_hash_lookup2( + hash_args, ID2SYM(rb_intern("emit_defaults")), Qfalse); } stringsink_init(&sink); @@ -1297,7 +1298,7 @@ VALUE Message_encode_json(int argc, VALUE* argv, VALUE klass) { stackenv_init(&se, "Error occurred during encoding: %s"); printer = upb_json_printer_create(&se.env, serialize_handlers, &sink.sink); - putmsg(msg_rb, desc, upb_json_printer_input(printer), 0); + putmsg(msg_rb, desc, upb_json_printer_input(printer), 0, RTEST(emit_defaults)); ret = rb_enc_str_new(sink.ptr, sink.len, rb_utf8_encoding()); diff --git a/ruby/tests/basic.rb b/ruby/tests/basic.rb index ca81e3a5..367be167 100644 --- a/ruby/tests/basic.rb +++ b/ruby/tests/basic.rb @@ -1174,6 +1174,36 @@ module BasicTest Foo.encode_json(Foo.new(bar: bar, baz: [baz1, baz2])) end + def test_json_emit_defaults + # TODO: Fix JSON in JRuby version. + return if RUBY_PLATFORM == "java" + m = TestMessage.new + + expected = '{"optionalInt32":0,"optionalInt64":0,"optionalUint32":0,"optionalUint64":0,"optionalBool":false,"optionalFloat":0,"optionalDouble":0,"optionalString":"","optionalBytes":"","optionalEnum":"Default","repeatedInt32":[],"repeatedInt64":[],"repeatedUint32":[],"repeatedUint64":[],"repeatedBool":[],"repeatedFloat":[],"repeatedDouble":[],"repeatedString":[],"repeatedBytes":[],"repeatedMsg":[],"repeatedEnum":[]}' + + assert TestMessage.encode_json(m, :emit_defaults => true) == expected + end + + def test_json_emit_defaults_submsg + # TODO: Fix JSON in JRuby version. + return if RUBY_PLATFORM == "java" + m = TestMessage.new(optional_msg: TestMessage2.new) + + expected = '{"optionalInt32":0,"optionalInt64":0,"optionalUint32":0,"optionalUint64":0,"optionalBool":false,"optionalFloat":0,"optionalDouble":0,"optionalString":"","optionalBytes":"","optionalMsg":{"foo":0},"optionalEnum":"Default","repeatedInt32":[],"repeatedInt64":[],"repeatedUint32":[],"repeatedUint64":[],"repeatedBool":[],"repeatedFloat":[],"repeatedDouble":[],"repeatedString":[],"repeatedBytes":[],"repeatedMsg":[],"repeatedEnum":[]}' + + assert TestMessage.encode_json(m, :emit_defaults => true) == expected + end + + def test_json_emit_defaults_repeated_submsg + # TODO: Fix JSON in JRuby version. + return if RUBY_PLATFORM == "java" + m = TestMessage.new(repeated_msg: [TestMessage2.new]) + + expected = '{"optionalInt32":0,"optionalInt64":0,"optionalUint32":0,"optionalUint64":0,"optionalBool":false,"optionalFloat":0,"optionalDouble":0,"optionalString":"","optionalBytes":"","optionalEnum":"Default","repeatedInt32":[],"repeatedInt64":[],"repeatedUint32":[],"repeatedUint64":[],"repeatedBool":[],"repeatedFloat":[],"repeatedDouble":[],"repeatedString":[],"repeatedBytes":[],"repeatedMsg":[{"foo":0}],"repeatedEnum":[]}' + + assert TestMessage.encode_json(m, :emit_defaults => true) == expected + end + def test_json_maps # TODO: Fix JSON in JRuby version. return if RUBY_PLATFORM == "java" @@ -1189,6 +1219,14 @@ module BasicTest assert m == m2 end + def test_json_maps_emit_defaults_submsg + # TODO: Fix JSON in JRuby version. + return if RUBY_PLATFORM == "java" + m = MapMessage.new(:map_string_msg => {"a" => TestMessage2.new}) + expected = '{"mapStringInt32":{},"mapStringMsg":{"a":{"foo":0}}}' + assert MapMessage.encode_json(m, :emit_defaults => true) == expected + end + def test_comparison_with_arbitrary_object assert MapMessage.new != nil end -- cgit v1.2.3 From aec07110750924790a939826f8ac3444f22f00bf Mon Sep 17 00:00:00 2001 From: Ewout Date: Fri, 17 Mar 2017 10:28:17 +0100 Subject: Ruby tests compare parsed JSON instead of raw JSON --- ruby/tests/basic.rb | 101 +++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 89 insertions(+), 12 deletions(-) diff --git a/ruby/tests/basic.rb b/ruby/tests/basic.rb index 367be167..d9df7a5a 100644 --- a/ruby/tests/basic.rb +++ b/ruby/tests/basic.rb @@ -1,6 +1,7 @@ #!/usr/bin/ruby require 'google/protobuf' +require 'json' require 'test/unit' # ------------- generated code -------------- @@ -1179,9 +1180,33 @@ module BasicTest return if RUBY_PLATFORM == "java" m = TestMessage.new - expected = '{"optionalInt32":0,"optionalInt64":0,"optionalUint32":0,"optionalUint64":0,"optionalBool":false,"optionalFloat":0,"optionalDouble":0,"optionalString":"","optionalBytes":"","optionalEnum":"Default","repeatedInt32":[],"repeatedInt64":[],"repeatedUint32":[],"repeatedUint64":[],"repeatedBool":[],"repeatedFloat":[],"repeatedDouble":[],"repeatedString":[],"repeatedBytes":[],"repeatedMsg":[],"repeatedEnum":[]}' + expected = { + optionalInt32: 0, + optionalInt64: 0, + optionalUint32: 0, + optionalUint64: 0, + optionalBool: false, + optionalFloat: 0, + optionalDouble: 0, + optionalString: "", + optionalBytes: "", + optionalEnum: "Default", + repeatedInt32: [], + repeatedInt64: [], + repeatedUint32: [], + repeatedUint64: [], + repeatedBool: [], + repeatedFloat: [], + repeatedDouble: [], + repeatedString: [], + repeatedBytes: [], + repeatedMsg: [], + repeatedEnum: [] + } + + actual = TestMessage.encode_json(m, :emit_defaults => true) - assert TestMessage.encode_json(m, :emit_defaults => true) == expected + assert JSON.parse(actual, :symbolize_names => true) == expected end def test_json_emit_defaults_submsg @@ -1189,9 +1214,34 @@ module BasicTest return if RUBY_PLATFORM == "java" m = TestMessage.new(optional_msg: TestMessage2.new) - expected = '{"optionalInt32":0,"optionalInt64":0,"optionalUint32":0,"optionalUint64":0,"optionalBool":false,"optionalFloat":0,"optionalDouble":0,"optionalString":"","optionalBytes":"","optionalMsg":{"foo":0},"optionalEnum":"Default","repeatedInt32":[],"repeatedInt64":[],"repeatedUint32":[],"repeatedUint64":[],"repeatedBool":[],"repeatedFloat":[],"repeatedDouble":[],"repeatedString":[],"repeatedBytes":[],"repeatedMsg":[],"repeatedEnum":[]}' + expected = { + optionalInt32: 0, + optionalInt64: 0, + optionalUint32: 0, + optionalUint64: 0, + optionalBool: false, + optionalFloat: 0, + optionalDouble: 0, + optionalString: "", + optionalBytes: "", + optionalMsg: {foo: 0}, + optionalEnum: "Default", + repeatedInt32: [], + repeatedInt64: [], + repeatedUint32: [], + repeatedUint64: [], + repeatedBool: [], + repeatedFloat: [], + repeatedDouble: [], + repeatedString: [], + repeatedBytes: [], + repeatedMsg: [], + repeatedEnum: [] + } + + actual = TestMessage.encode_json(m, :emit_defaults => true) - assert TestMessage.encode_json(m, :emit_defaults => true) == expected + assert JSON.parse(actual, :symbolize_names => true) == expected end def test_json_emit_defaults_repeated_submsg @@ -1199,21 +1249,45 @@ module BasicTest return if RUBY_PLATFORM == "java" m = TestMessage.new(repeated_msg: [TestMessage2.new]) - expected = '{"optionalInt32":0,"optionalInt64":0,"optionalUint32":0,"optionalUint64":0,"optionalBool":false,"optionalFloat":0,"optionalDouble":0,"optionalString":"","optionalBytes":"","optionalEnum":"Default","repeatedInt32":[],"repeatedInt64":[],"repeatedUint32":[],"repeatedUint64":[],"repeatedBool":[],"repeatedFloat":[],"repeatedDouble":[],"repeatedString":[],"repeatedBytes":[],"repeatedMsg":[{"foo":0}],"repeatedEnum":[]}' + expected = { + optionalInt32: 0, + optionalInt64: 0, + optionalUint32: 0, + optionalUint64: 0, + optionalBool: false, + optionalFloat: 0, + optionalDouble: 0, + optionalString: "", + optionalBytes: "", + optionalEnum: "Default", + repeatedInt32: [], + repeatedInt64: [], + repeatedUint32: [], + repeatedUint64: [], + repeatedBool: [], + repeatedFloat: [], + repeatedDouble: [], + repeatedString: [], + repeatedBytes: [], + repeatedMsg: [{foo: 0}], + repeatedEnum: [] + } + + actual = TestMessage.encode_json(m, :emit_defaults => true) - assert TestMessage.encode_json(m, :emit_defaults => true) == expected + assert JSON.parse(actual, :symbolize_names => true) == expected end def test_json_maps # TODO: Fix JSON in JRuby version. return if RUBY_PLATFORM == "java" m = MapMessage.new(:map_string_int32 => {"a" => 1}) - expected = '{"mapStringInt32":{"a":1},"mapStringMsg":{}}' - expected_preserve = '{"map_string_int32":{"a":1},"map_string_msg":{}}' - assert MapMessage.encode_json(m) == expected + expected = {mapStringInt32: {a: 1}, mapStringMsg: {}} + expected_preserve = {map_string_int32: {a: 1}, map_string_msg: {}} + assert JSON.parse(MapMessage.encode_json(m), :symbolize_names => true) == expected json = MapMessage.encode_json(m, :preserve_proto_fieldnames => true) - assert json == expected_preserve + assert JSON.parse(json, :symbolize_names => true) == expected_preserve m2 = MapMessage.decode_json(MapMessage.encode_json(m)) assert m == m2 @@ -1223,8 +1297,11 @@ module BasicTest # TODO: Fix JSON in JRuby version. return if RUBY_PLATFORM == "java" m = MapMessage.new(:map_string_msg => {"a" => TestMessage2.new}) - expected = '{"mapStringInt32":{},"mapStringMsg":{"a":{"foo":0}}}' - assert MapMessage.encode_json(m, :emit_defaults => true) == expected + expected = {mapStringInt32: {}, mapStringMsg: {a: {foo: 0}}} + + actual = MapMessage.encode_json(m, :emit_defaults => true) + + assert JSON.parse(actual, :symbolize_names => true) == expected end def test_comparison_with_arbitrary_object -- cgit v1.2.3 From 286f0598422a70639e587b5329bd3037f5ee76b0 Mon Sep 17 00:00:00 2001 From: makdharma Date: Mon, 1 May 2017 09:49:26 -0700 Subject: added "objectivec" build target (#3033) This target will be used by gRPC iOS bazel build system. --- BUILD | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/BUILD b/BUILD index d08b7a09..458c6113 100644 --- a/BUILD +++ b/BUILD @@ -797,3 +797,84 @@ proto_lang_toolchain( runtime = ":protobuf_java", visibility = ["//visibility:public"], ) + +OBJC_HDRS = [ + "objectivec/GPBArray.h", + "objectivec/GPBBootstrap.h", + "objectivec/GPBCodedInputStream.h", + "objectivec/GPBCodedOutputStream.h", + "objectivec/GPBDescriptor.h", + "objectivec/GPBDictionary.h", + "objectivec/GPBExtensionInternals.h", + "objectivec/GPBExtensionRegistry.h", + "objectivec/GPBMessage.h", + "objectivec/GPBProtocolBuffers.h", + "objectivec/GPBProtocolBuffers_RuntimeSupport.h", + "objectivec/GPBRootObject.h", + "objectivec/GPBRuntimeTypes.h", + "objectivec/GPBUnknownField.h", + "objectivec/GPBUnknownFieldSet.h", + "objectivec/GPBUtilities.h", + "objectivec/GPBWellKnownTypes.h", + "objectivec/GPBWireFormat.h", + "objectivec/google/protobuf/Any.pbobjc.h", + "objectivec/google/protobuf/Api.pbobjc.h", + "objectivec/google/protobuf/Duration.pbobjc.h", + "objectivec/google/protobuf/Empty.pbobjc.h", + "objectivec/google/protobuf/FieldMask.pbobjc.h", + "objectivec/google/protobuf/SourceContext.pbobjc.h", + "objectivec/google/protobuf/Struct.pbobjc.h", + "objectivec/google/protobuf/Timestamp.pbobjc.h", + "objectivec/google/protobuf/Type.pbobjc.h", + "objectivec/google/protobuf/Wrappers.pbobjc.h", +] + +OBJC_PRIVATE_HDRS = [ + "objectivec/GPBArray_PackagePrivate.h", + "objectivec/GPBCodedInputStream_PackagePrivate.h", + "objectivec/GPBCodedOutputStream_PackagePrivate.h", + "objectivec/GPBDescriptor_PackagePrivate.h", + "objectivec/GPBDictionary_PackagePrivate.h", + "objectivec/GPBMessage_PackagePrivate.h", + "objectivec/GPBRootObject_PackagePrivate.h", + "objectivec/GPBUnknownFieldSet_PackagePrivate.h", + "objectivec/GPBUnknownField_PackagePrivate.h", + "objectivec/GPBUtilities_PackagePrivate.h", +] + +OBJC_SRCS = [ + "objectivec/GPBArray.m", + "objectivec/GPBCodedInputStream.m", + "objectivec/GPBCodedOutputStream.m", + "objectivec/GPBDescriptor.m", + "objectivec/GPBDictionary.m", + "objectivec/GPBExtensionInternals.m", + "objectivec/GPBExtensionRegistry.m", + "objectivec/GPBMessage.m", + "objectivec/GPBRootObject.m", + "objectivec/GPBUnknownField.m", + "objectivec/GPBUnknownFieldSet.m", + "objectivec/GPBUtilities.m", + "objectivec/GPBWellKnownTypes.m", + "objectivec/GPBWireFormat.m", + "objectivec/google/protobuf/Any.pbobjc.m", + "objectivec/google/protobuf/Api.pbobjc.m", + "objectivec/google/protobuf/Duration.pbobjc.m", + "objectivec/google/protobuf/Empty.pbobjc.m", + "objectivec/google/protobuf/FieldMask.pbobjc.m", + "objectivec/google/protobuf/SourceContext.pbobjc.m", + "objectivec/google/protobuf/Struct.pbobjc.m", + "objectivec/google/protobuf/Timestamp.pbobjc.m", + "objectivec/google/protobuf/Type.pbobjc.m", + "objectivec/google/protobuf/Wrappers.pbobjc.m", +] + +objc_library( + name = "objectivec", + hdrs = OBJC_HDRS + OBJC_PRIVATE_HDRS, + includes = [ + "objectivec", + ], + non_arc_srcs = OBJC_SRCS, + visibility = ["//visibility:public"], +) -- cgit v1.2.3 From bcb35066411e46bde936bc4c83405b7bd280fb71 Mon Sep 17 00:00:00 2001 From: Paul Jolly Date: Sun, 19 Mar 2017 13:51:20 +0000 Subject: Fix #1562 by using goog.crypt.byteArrayToString instead of String.fromCharCode.apply --- js/binary/decoder.js | 2 +- js/binary/utils.js | 2 +- js/binary/utils_test.js | 24 ++++++++++++------------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/js/binary/decoder.js b/js/binary/decoder.js index ad9cb01b..6db28e7c 100644 --- a/js/binary/decoder.js +++ b/js/binary/decoder.js @@ -994,7 +994,7 @@ jspb.BinaryDecoder.prototype.readString = function(length) { codeUnits.length = 0; } } - result += String.fromCharCode.apply(null, codeUnits); + result += goog.crypt.byteArrayToString(codeUnits); this.cursor_ = cursor; return result; }; diff --git a/js/binary/utils.js b/js/binary/utils.js index 7702020b..df16249e 100644 --- a/js/binary/utils.js +++ b/js/binary/utils.js @@ -613,7 +613,7 @@ jspb.utils.decimalStringToHash64 = function(dec) { muladd(1, 1); } - return String.fromCharCode.apply(null, resultBytes); + return goog.crypt.byteArrayToString(resultBytes); }; diff --git a/js/binary/utils_test.js b/js/binary/utils_test.js index d27e5ea2..0a2f4f0a 100644 --- a/js/binary/utils_test.js +++ b/js/binary/utils_test.js @@ -205,31 +205,31 @@ describe('binaryUtilsTest', function() { var convert = jspb.utils.decimalStringToHash64; result = convert('0'); - assertEquals(String.fromCharCode.apply(null, + assertEquals(goog.crypt.byteArrayToString( [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]), result); result = convert('-1'); - assertEquals(String.fromCharCode.apply(null, + assertEquals(goog.crypt.byteArrayToString( [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]), result); result = convert('18446744073709551615'); - assertEquals(String.fromCharCode.apply(null, + assertEquals(goog.crypt.byteArrayToString( [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]), result); result = convert('9223372036854775808'); - assertEquals(String.fromCharCode.apply(null, + assertEquals(goog.crypt.byteArrayToString( [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80]), result); result = convert('-9223372036854775808'); - assertEquals(String.fromCharCode.apply(null, + assertEquals(goog.crypt.byteArrayToString( [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80]), result); result = convert('123456789123456789'); - assertEquals(String.fromCharCode.apply(null, + assertEquals(goog.crypt.byteArrayToString( [0x15, 0x5F, 0xD0, 0xAC, 0x4B, 0x9B, 0xB6, 0x01]), result); result = convert('-123456789123456789'); - assertEquals(String.fromCharCode.apply(null, + assertEquals(goog.crypt.byteArrayToString( [0xEB, 0xA0, 0x2F, 0x53, 0xB4, 0x64, 0x49, 0xFE]), result); }); @@ -259,21 +259,21 @@ describe('binaryUtilsTest', function() { var convert = jspb.utils.hexStringToHash64; result = convert('0x0000000000000000'); - assertEquals(String.fromCharCode.apply(null, + assertEquals(goog.crypt.byteArrayToString( [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]), result); result = convert('0xffffffffffffffff'); - assertEquals(String.fromCharCode.apply(null, + assertEquals(goog.crypt.byteArrayToString( [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]), result); // Hex string is big-endian, hash string is little-endian. result = convert('0x123456789ABCDEF0'); - assertEquals(String.fromCharCode.apply(null, + assertEquals(goog.crypt.byteArrayToString( [0xF0, 0xDE, 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12]), result); // Capitalization should not matter. result = convert('0x0000abcdefABCDEF'); - assertEquals(String.fromCharCode.apply(null, + assertEquals(goog.crypt.byteArrayToString( [0xEF, 0xCD, 0xAB, 0xEF, 0xCD, 0xAB, 0x00, 0x00]), result); }); @@ -643,7 +643,7 @@ describe('binaryUtilsTest', function() { var sourceBytes = new Uint8Array(sourceData); var sourceBuffer = sourceBytes.buffer; var sourceBase64 = goog.crypt.base64.encodeByteArray(sourceData); - var sourceString = String.fromCharCode.apply(null, sourceData); + var sourceString = goog.crypt.byteArrayToString(sourceData); function check(result) { assertEquals(Uint8Array, result.constructor); -- cgit v1.2.3 From f00e06c95bc117fb2ed0ca56c96041c93039f1fe Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Tue, 2 May 2017 17:13:27 -0700 Subject: Removed mention of Buffer in byteSourceToUint8Array The Closure compiler complains about Buffer since that class exists only in Node. That logic does not seem to be needed (unit tests and conformance tests pass without it), so let's just remove it to solve the problem. --- js/binary/utils.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/js/binary/utils.js b/js/binary/utils.js index df16249e..58f11b54 100644 --- a/js/binary/utils.js +++ b/js/binary/utils.js @@ -970,10 +970,6 @@ jspb.utils.byteSourceToUint8Array = function(data) { return /** @type {!Uint8Array} */(new Uint8Array(data)); } - if (data.constructor === Buffer) { - return /** @type {!Uint8Array} */(new Uint8Array(data)); - } - if (data.constructor === Array) { data = /** @type {!Array.} */(data); return /** @type {!Uint8Array} */(new Uint8Array(data)); -- cgit v1.2.3 From cd0efc0024482be745e1671461518bac07335ca1 Mon Sep 17 00:00:00 2001 From: "Mario J. Rugiero" Date: Fri, 5 May 2017 13:52:58 -0300 Subject: Workaround gcc < 4.5.0 bug See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=189 Signed-off-by: Mario J. Rugiero --- src/google/protobuf/metadata_lite.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/google/protobuf/metadata_lite.h b/src/google/protobuf/metadata_lite.h index 840c02e8..64fde0c6 100644 --- a/src/google/protobuf/metadata_lite.h +++ b/src/google/protobuf/metadata_lite.h @@ -167,7 +167,8 @@ class InternalMetadataWithArenaLite InternalMetadataWithArenaLite() {} explicit InternalMetadataWithArenaLite(Arena* arena) - : InternalMetadataWithArenaBase(arena) {} + : InternalMetadataWithArenaBase(arena) {} void DoSwap(string* other) { mutable_unknown_fields()->swap(*other); -- cgit v1.2.3 From 25abd7b7e7a6e7f3dfabe6b3a762e2346b2ae185 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Fri, 5 May 2017 11:14:11 -0700 Subject: Add compatibility test for php. (#3041) * Add compatibility test for php. * Revert API incompatible change. --- .gitignore | 2 + Makefile.am | 1 + jenkins/buildcmds/pull_request_32.sh | 2 +- php/tests/compatibility_test.sh | 111 +++++++++++++++++++++++++++++++++++ php/tests/test.sh | 4 +- tests.sh | 13 +++- 6 files changed, 129 insertions(+), 4 deletions(-) create mode 100755 php/tests/compatibility_test.sh diff --git a/.gitignore b/.gitignore index b8356118..af914125 100644 --- a/.gitignore +++ b/.gitignore @@ -138,6 +138,8 @@ conformance/conformance-php-c # php test output composer.lock php/tests/generated/ +php/tests/old_protoc +php/tests/protobuf/ php/ext/google/protobuf/.libs/ php/ext/google/protobuf/Makefile.fragments php/ext/google/protobuf/Makefile.global diff --git a/Makefile.am b/Makefile.am index f1111898..04b4f4a6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -651,6 +651,7 @@ php_EXTRA_DIST= \ php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php \ php/tests/array_test.php \ php/tests/autoload.php \ + php/tests/compatibility_test.sh \ php/tests/encode_decode_test.php \ php/tests/gdb_test.sh \ php/tests/generated_class_test.php \ diff --git a/jenkins/buildcmds/pull_request_32.sh b/jenkins/buildcmds/pull_request_32.sh index 99df2971..bf0fb7ff 100755 --- a/jenkins/buildcmds/pull_request_32.sh +++ b/jenkins/buildcmds/pull_request_32.sh @@ -12,5 +12,5 @@ export DOCKERFILE_DIR=jenkins/docker32 export DOCKER_RUN_SCRIPT=jenkins/pull_request_in_docker.sh export OUTPUT_DIR=testoutput -export TEST_SET="php_all" +export TEST_SET="php_all_32" ./jenkins/build_and_run_docker.sh diff --git a/php/tests/compatibility_test.sh b/php/tests/compatibility_test.sh new file mode 100755 index 00000000..e05b2af1 --- /dev/null +++ b/php/tests/compatibility_test.sh @@ -0,0 +1,111 @@ +#!/bin/bash + +use_php() { + VERSION=$1 + PHP=`which php` + PHP_CONFIG=`which php-config` + PHPIZE=`which phpize` + ln -sfn "/usr/local/php-${VERSION}/bin/php" $PHP + ln -sfn "/usr/local/php-${VERSION}/bin/php-config" $PHP_CONFIG + ln -sfn "/usr/local/php-${VERSION}/bin/phpize" $PHPIZE +} + +generate_proto() { + PROTOC1=$1 + PROTOC2=$2 + + rm -rf generated + mkdir generated + + $PROTOC1 --php_out=generated proto/test_include.proto + $PROTOC2 --php_out=generated proto/test.proto proto/test_no_namespace.proto proto/test_prefix.proto + pushd ../../src + $PROTOC2 --php_out=../php/tests/generated google/protobuf/empty.proto + $PROTOC2 --php_out=../php/tests/generated -I../php/tests -I. ../php/tests/proto/test_import_descriptor_proto.proto + popd +} + +set -ex + +# Change to the script's directory. +cd $(dirname $0) + +# The old version of protobuf that we are testing compatibility against. +case "$1" in + ""|3.3.0) + OLD_VERSION=3.3.0 + OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.3.0/protoc-3.3.0-linux-x86_64.exe + ;; + *) + echo "[ERROR]: Unknown version number: $1" + exit 1 + ;; +esac + +# Extract the latest protobuf version number. +VERSION_NUMBER=`grep "PHP_PROTOBUF_VERSION" ../ext/google/protobuf/protobuf.h | sed "s|#define PHP_PROTOBUF_VERSION \"\(.*\)\"|\1|"` + +echo "Running compatibility tests between $VERSION_NUMBER and $OLD_VERSION" + +# Check protoc +[ -f ../../src/protoc ] || { + echo "[ERROR]: Please build protoc first." + exit 1 +} + +# Download old test. +rm -rf protobuf +git clone https://github.com/google/protobuf.git +pushd protobuf +git checkout v$OLD_VERSION +popd + +# Build and copy the new runtime +use_php 5.5 +pushd ../ext/google/protobuf +make clean || true +phpize && ./configure && make +popd + +rm -rf protobuf/php/ext +rm -rf protobuf/php/src +cp -r ../ext protobuf/php/ext/ +cp -r ../src protobuf/php/src/ + +# Download old version protoc compiler (for linux) +wget $OLD_VERSION_PROTOC -O old_protoc +chmod +x old_protoc + +NEW_PROTOC=`pwd`/../../src/protoc +OLD_PROTOC=`pwd`/old_protoc +cd protobuf/php +cp -r /usr/local/vendor-5.5 vendor +wget https://phar.phpunit.de/phpunit-4.8.0.phar -O /usr/bin/phpunit +cd tests + +# Test A.1: +# proto set 1: use old version +# proto set 2 which may import protos in set 1: use old version +generate_proto $OLD_PROTOC $OLD_PROTOC +./test.sh +pushd .. +phpunit +popd + +# Test A.2: +# proto set 1: use new version +# proto set 2 which may import protos in set 1: use old version +generate_proto $NEW_PROTOC $OLD_PROTOC +./test.sh +pushd .. +phpunit +popd + +# Test A.3: +# proto set 1: use old version +# proto set 2 which may import protos in set 1: use new version +generate_proto $OLD_PROTOC $NEW_PROTOC +./test.sh +pushd .. +phpunit +popd diff --git a/php/tests/test.sh b/php/tests/test.sh index fc3f0186..69849ab3 100755 --- a/php/tests/test.sh +++ b/php/tests/test.sh @@ -2,10 +2,10 @@ # Compile c extension pushd ../ext/google/protobuf/ -make clean +make clean || true set -e # Add following in configure for debug: --enable-debug CFLAGS='-g -O0' -phpize && ./configure --enable-debug CFLAGS='-g -O0' && make +phpize && ./configure CFLAGS='-g -O0' && make popd tests=( array_test.php encode_decode_test.php generated_class_test.php map_field_test.php well_known_test.php ) diff --git a/tests.sh b/tests.sh index edb37da7..96550cb9 100755 --- a/tests.sh +++ b/tests.sh @@ -545,7 +545,12 @@ build_php7.0_mac() { popd } -build_php_all() { +build_php_compatibility() { + internal_build_cpp + php/tests/compatibility_test.sh +} + +build_php_all_32() { build_php5.5 build_php5.6 build_php7.0 @@ -557,6 +562,11 @@ build_php_all() { build_php7.0_zts_c } +build_php_all() { + build_php_all_32 + build_php_compatibility +} + # Note: travis currently does not support testing more than one language so the # .travis.yml cheats and claims to only be cpp. If they add multiple language # support, this should probably get updated to install steps and/or @@ -595,6 +605,7 @@ Usage: $0 { cpp | php5.6_c | php7.0 | php7.0_c | + php_compatibility | php_all) " exit 1 -- cgit v1.2.3 From 82e50ba5c311f26786bb1dffa64c3e9ff6e957d7 Mon Sep 17 00:00:00 2001 From: Łukasz Strzałkowski Date: Thu, 11 May 2017 14:04:34 -0700 Subject: Workaround the docker bug when compiling artifacts This is a workaround (https://github.com/moby/moby/issues/10180#issuecomment-190429512) the docker issue (https://github.com/moby/moby/issues/10180) which breaks protoc-artifacts build process with following error ```Rpmdb checksum is invalid: dCDPT(pkg checksums): devtoolset-1.1-elfutils.x86_64 0:0.154-6.el6 - u The command '/bin/sh -c yum clean all && yum install -y devtoolset-1.1 devtoolset-1.1-libstdc++-devel devtoolset-1.1-libstdc++-devel.i686' returned a non-zero code: 1``` https://github.com/moby/moby/issues/10180#issuecomment-190429512 --- protoc-artifacts/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protoc-artifacts/Dockerfile b/protoc-artifacts/Dockerfile index 5143b028..36b547a2 100644 --- a/protoc-artifacts/Dockerfile +++ b/protoc-artifacts/Dockerfile @@ -30,7 +30,7 @@ RUN wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo -P /etc/yum RUN bash -c 'echo "enabled=1" >> /etc/yum.repos.d/devtools-1.1.repo' RUN bash -c "sed -e 's/\$basearch/i386/g' /etc/yum.repos.d/devtools-1.1.repo > /etc/yum.repos.d/devtools-i386-1.1.repo" RUN sed -e 's/testing-/testing-i386-/g' -i /etc/yum.repos.d/devtools-i386-1.1.repo -RUN yum install -y devtoolset-1.1 \ +RUN rpm --rebuilddb && yum install -y devtoolset-1.1 \ devtoolset-1.1-libstdc++-devel \ devtoolset-1.1-libstdc++-devel.i686 -- cgit v1.2.3 From ad203bcb2be17e06909ab6d67ab2475673673bbc Mon Sep 17 00:00:00 2001 From: Andreas Eger Date: Sun, 11 Dec 2016 03:30:08 +0100 Subject: fix floating point accuracy problem in Timestamp#to_f `.quo` return the most exact devision which fixes accuracy problems for the timestamp coercion --- ruby/lib/google/protobuf/well_known_types.rb | 2 +- ruby/tests/well_known_types_test.rb | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ruby/lib/google/protobuf/well_known_types.rb b/ruby/lib/google/protobuf/well_known_types.rb index 547de874..921ddbc0 100644 --- a/ruby/lib/google/protobuf/well_known_types.rb +++ b/ruby/lib/google/protobuf/well_known_types.rb @@ -80,7 +80,7 @@ module Google end def to_f - self.seconds + (self.nanos.to_f / 1_000_000_000) + self.seconds + (self.nanos.quo(1_000_000_000)) end end diff --git a/ruby/tests/well_known_types_test.rb b/ruby/tests/well_known_types_test.rb index 9b46632b..ad8531d9 100644 --- a/ruby/tests/well_known_types_test.rb +++ b/ruby/tests/well_known_types_test.rb @@ -13,10 +13,15 @@ class TestWellKnownTypes < Test::Unit::TestCase assert_equal Time.at(12345), ts.to_time assert_equal 12345, ts.to_i - ts.from_time(Time.at(123456, 654321)) + time = Time.at(123456, 654321) + ts.from_time(time) assert_equal 123456, ts.seconds assert_equal 654321000, ts.nanos - assert_equal Time.at(123456.654321), ts.to_time + assert_equal time, ts.to_time + + time = Time.now + ts.from_time(time) + assert_equal time.to_f, ts.to_time.to_f end def test_duration -- cgit v1.2.3 From 78cb804063716767966cdcd86c66500df342ad33 Mon Sep 17 00:00:00 2001 From: Andreas Eger Date: Sat, 13 May 2017 22:20:45 +0200 Subject: change test for nanosecond accurate timestamps --- ruby/tests/well_known_types_test.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ruby/tests/well_known_types_test.rb b/ruby/tests/well_known_types_test.rb index ad8531d9..bd24c328 100644 --- a/ruby/tests/well_known_types_test.rb +++ b/ruby/tests/well_known_types_test.rb @@ -13,15 +13,18 @@ class TestWellKnownTypes < Test::Unit::TestCase assert_equal Time.at(12345), ts.to_time assert_equal 12345, ts.to_i + # millisecond accuracy time = Time.at(123456, 654321) ts.from_time(time) assert_equal 123456, ts.seconds assert_equal 654321000, ts.nanos assert_equal time, ts.to_time - time = Time.now + # nanosecond accuracy + time = Time.at(123456, Rational(654321321, 1000)) ts.from_time(time) - assert_equal time.to_f, ts.to_time.to_f + assert_equal 654321321, ts.nanos + assert_equal time, ts.to_time end def test_duration -- cgit v1.2.3 From 49e4ba6098ae4c01f4af35183f9b6f5e6739fb52 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Wed, 17 May 2017 13:38:51 -0400 Subject: Fix ExtensionRegistry copying and add tests. - Fix up -copyWithZone: to not leave the two registries sharing some of the storage by using -addExtensions:. - Improve -addExtensions: to clone the sub dict when there is nothing to merge into. - A ExtensionRegistry unittests. - Update project schemes to not have extra things in perf scheme. --- Makefile.am | 1 + objectivec/GPBExtensionRegistry.m | 37 +++--- .../ProtocolBuffers_OSX.xcodeproj/project.pbxproj | 8 +- .../xcschemes/PerformanceTests.xcscheme | 9 ++ .../ProtocolBuffers_iOS.xcodeproj/project.pbxproj | 8 +- .../xcschemes/PerformanceTests.xcscheme | 9 ++ objectivec/Tests/GPBExtensionRegistryTest.m | 138 +++++++++++++++++++++ 7 files changed, 187 insertions(+), 23 deletions(-) create mode 100644 objectivec/Tests/GPBExtensionRegistryTest.m diff --git a/Makefile.am b/Makefile.am index 04b4f4a6..023afa40 100644 --- a/Makefile.am +++ b/Makefile.am @@ -535,6 +535,7 @@ objectivec_EXTRA_DIST= \ objectivec/Tests/GPBDictionaryTests+UInt64.m \ objectivec/Tests/GPBDictionaryTests.m \ objectivec/Tests/GPBDictionaryTests.pddm \ + objectivec/Tests/GPBExtensionRegistryTest.m \ objectivec/Tests/GPBMessageTests+Merge.m \ objectivec/Tests/GPBMessageTests+Runtime.m \ objectivec/Tests/GPBMessageTests+Serialization.m \ diff --git a/objectivec/GPBExtensionRegistry.m b/objectivec/GPBExtensionRegistry.m index 65534b67..b056a52d 100644 --- a/objectivec/GPBExtensionRegistry.m +++ b/objectivec/GPBExtensionRegistry.m @@ -57,14 +57,16 @@ - (instancetype)copyWithZone:(NSZone *)zone { GPBExtensionRegistry *result = [[[self class] allocWithZone:zone] init]; - if (result && mutableClassMap_.count) { - [result->mutableClassMap_ addEntriesFromDictionary:mutableClassMap_]; - } + [result addExtensions:self]; return result; } -- (CFMutableDictionaryRef)extensionMapForContainingMessageClass: - (Class)containingMessageClass { +- (void)addExtension:(GPBExtensionDescriptor *)extension { + if (extension == nil) { + return; + } + + Class containingMessageClass = extension.containingMessageClass; CFMutableDictionaryRef extensionMap = (CFMutableDictionaryRef) [mutableClassMap_ objectForKey:containingMessageClass]; if (extensionMap == nil) { @@ -74,18 +76,9 @@ &kCFTypeDictionaryValueCallBacks); [mutableClassMap_ setObject:(id)extensionMap forKey:(id)containingMessageClass]; + CFRelease(extensionMap); } - return extensionMap; -} -- (void)addExtension:(GPBExtensionDescriptor *)extension { - if (extension == nil) { - return; - } - - Class containingMessageClass = extension.containingMessageClass; - CFMutableDictionaryRef extensionMap = - [self extensionMapForContainingMessageClass:containingMessageClass]; ssize_t key = extension.fieldNumber; CFDictionarySetValue(extensionMap, (const void *)key, extension); } @@ -119,10 +112,16 @@ static void CopyKeyValue(const void *key, const void *value, void *context) { Class containingMessageClass = key; CFMutableDictionaryRef otherExtensionMap = (CFMutableDictionaryRef)value; - CFMutableDictionaryRef extensionMap = - [self extensionMapForContainingMessageClass:containingMessageClass]; - - CFDictionaryApplyFunction(otherExtensionMap, CopyKeyValue, extensionMap); + CFMutableDictionaryRef extensionMap = (CFMutableDictionaryRef) + [mutableClassMap_ objectForKey:containingMessageClass]; + if (extensionMap == nil) { + extensionMap = CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, otherExtensionMap); + [mutableClassMap_ setObject:(id)extensionMap + forKey:(id)containingMessageClass]; + CFRelease(extensionMap); + } else { + CFDictionaryApplyFunction(otherExtensionMap, CopyKeyValue, extensionMap); + } }]; } diff --git a/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj b/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj index 919d0076..cd7fcc9e 100644 --- a/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj +++ b/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj @@ -52,6 +52,7 @@ F4487C751AADF7F500531423 /* GPBMessageTests+Runtime.m in Sources */ = {isa = PBXBuildFile; fileRef = F4487C741AADF7F500531423 /* GPBMessageTests+Runtime.m */; }; F4487C7F1AAF62CD00531423 /* GPBMessageTests+Serialization.m in Sources */ = {isa = PBXBuildFile; fileRef = F4487C7E1AAF62CD00531423 /* GPBMessageTests+Serialization.m */; }; F4487C831AAF6AB300531423 /* GPBMessageTests+Merge.m in Sources */ = {isa = PBXBuildFile; fileRef = F4487C821AAF6AB300531423 /* GPBMessageTests+Merge.m */; }; + F4584D821ECCB52A00803AB6 /* GPBExtensionRegistryTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F4584D7E1ECCB38900803AB6 /* GPBExtensionRegistryTest.m */; }; F45C69CC16DFD08D0081955B /* GPBExtensionInternals.m in Sources */ = {isa = PBXBuildFile; fileRef = F45C69CB16DFD08D0081955B /* GPBExtensionInternals.m */; }; F45E57C71AE6DC6A000B7D99 /* text_format_map_unittest_data.txt in Resources */ = {isa = PBXBuildFile; fileRef = F45E57C61AE6DC6A000B7D99 /* text_format_map_unittest_data.txt */; }; F47476E51D21A524007C7B1A /* Duration.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248D41A92826400BC1EC6 /* Duration.pbobjc.m */; }; @@ -180,6 +181,7 @@ F4487C821AAF6AB300531423 /* GPBMessageTests+Merge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GPBMessageTests+Merge.m"; sourceTree = ""; }; F44929001C866B1900C2548A /* GPBCodedOutputStream_PackagePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBCodedOutputStream_PackagePrivate.h; sourceTree = ""; }; F451D3F51A8AAE8700B8A22C /* GPBProtocolBuffers_RuntimeSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBProtocolBuffers_RuntimeSupport.h; sourceTree = ""; }; + F4584D7E1ECCB38900803AB6 /* GPBExtensionRegistryTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBExtensionRegistryTest.m; sourceTree = ""; }; F45C69CB16DFD08D0081955B /* GPBExtensionInternals.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBExtensionInternals.m; sourceTree = ""; }; F45E57C61AE6DC6A000B7D99 /* text_format_map_unittest_data.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = text_format_map_unittest_data.txt; sourceTree = ""; }; F4AC9E1D1A8BEB3500BD6E83 /* unittest_cycle.proto */ = {isa = PBXFileReference; lastKnownFileType = text; path = unittest_cycle.proto; sourceTree = ""; }; @@ -403,6 +405,7 @@ F4353D301AC06F10005A6198 /* GPBDictionaryTests+String.m */, F4353D311AC06F10005A6198 /* GPBDictionaryTests+UInt32.m */, F4353D321AC06F10005A6198 /* GPBDictionaryTests+UInt64.m */, + F4584D7E1ECCB38900803AB6 /* GPBExtensionRegistryTest.m */, 7461B6A30F94FDF800A0C422 /* GPBMessageTests.m */, F4487C821AAF6AB300531423 /* GPBMessageTests+Merge.m */, F4487C741AADF7F500531423 /* GPBMessageTests+Runtime.m */, @@ -418,8 +421,8 @@ 7461B6BA0F94FDF900A0C422 /* GPBUtilitiesTests.m */, 8B4248DB1A92933A00BC1EC6 /* GPBWellKnownTypesTest.m */, 7461B6BC0F94FDF900A0C422 /* GPBWireFormatTests.m */, - F43C88CF191D77FC009E917D /* text_format_unittest_data.txt */, F45E57C61AE6DC6A000B7D99 /* text_format_map_unittest_data.txt */, + F43C88CF191D77FC009E917D /* text_format_unittest_data.txt */, 8B7E6A7414893DBA00F8884A /* unittest_custom_options.proto */, F4AC9E1D1A8BEB3500BD6E83 /* unittest_cycle.proto */, 8B7E6A7514893DBA00F8884A /* unittest_embed_optimize_for.proto */, @@ -429,8 +432,8 @@ 8BBD9DB016DD1DC8008E1EC1 /* unittest_lite.proto */, 8B7E6A7B14893DBC00F8884A /* unittest_mset.proto */, 8B7E6A7C14893DBC00F8884A /* unittest_no_generic_services.proto */, - 8B09AAF614B663A7007B4184 /* unittest_objc.proto */, F4CF31701B162ED800BD9B06 /* unittest_objc_startup.proto */, + 8B09AAF614B663A7007B4184 /* unittest_objc.proto */, 8B7E6A7D14893DBC00F8884A /* unittest_optimize_for.proto */, F4487C781AADFB3100531423 /* unittest_runtime_proto2.proto */, F4487C791AADFB3200531423 /* unittest_runtime_proto3.proto */, @@ -669,6 +672,7 @@ F4F8D8831D789FD9002CE128 /* GPBUnittestProtos2.m in Sources */, F4353D1D1AB8822D005A6198 /* GPBDescriptorTests.m in Sources */, 8B4248BB1A8C256A00BC1EC6 /* GPBSwiftTests.swift in Sources */, + F4584D821ECCB52A00803AB6 /* GPBExtensionRegistryTest.m in Sources */, 5102DABC1891A073002037B6 /* GPBConcurrencyTests.m in Sources */, F4487C751AADF7F500531423 /* GPBMessageTests+Runtime.m in Sources */, F4353D351AC06F10005A6198 /* GPBDictionaryTests+Int32.m in Sources */, diff --git a/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme b/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme index 2f618131..2883109c 100644 --- a/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme +++ b/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme @@ -50,6 +50,12 @@ + + + + @@ -89,6 +95,9 @@ + + diff --git a/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj b/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj index 64fc45c0..2211cb37 100644 --- a/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj +++ b/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj @@ -60,6 +60,7 @@ F4487C771AADF84900531423 /* GPBMessageTests+Runtime.m in Sources */ = {isa = PBXBuildFile; fileRef = F4487C761AADF84900531423 /* GPBMessageTests+Runtime.m */; }; F4487C811AAF62FC00531423 /* GPBMessageTests+Serialization.m in Sources */ = {isa = PBXBuildFile; fileRef = F4487C801AAF62FC00531423 /* GPBMessageTests+Serialization.m */; }; F4487C851AAF6AC500531423 /* GPBMessageTests+Merge.m in Sources */ = {isa = PBXBuildFile; fileRef = F4487C841AAF6AC500531423 /* GPBMessageTests+Merge.m */; }; + F4584D831ECCB53600803AB6 /* GPBExtensionRegistryTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F4584D801ECCB39E00803AB6 /* GPBExtensionRegistryTest.m */; }; F45C69CC16DFD08D0081955B /* GPBExtensionInternals.m in Sources */ = {isa = PBXBuildFile; fileRef = F45C69CB16DFD08D0081955B /* GPBExtensionInternals.m */; }; F45E57C91AE6DC98000B7D99 /* text_format_map_unittest_data.txt in Resources */ = {isa = PBXBuildFile; fileRef = F45E57C81AE6DC98000B7D99 /* text_format_map_unittest_data.txt */; }; F47476E91D21A537007C7B1A /* Duration.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248DE1A929C7D00BC1EC6 /* Duration.pbobjc.m */; }; @@ -202,6 +203,7 @@ F4487C841AAF6AC500531423 /* GPBMessageTests+Merge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GPBMessageTests+Merge.m"; sourceTree = ""; }; F44929021C866B3B00C2548A /* GPBCodedOutputStream_PackagePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBCodedOutputStream_PackagePrivate.h; sourceTree = ""; }; F451D3F61A8AAEA600B8A22C /* GPBProtocolBuffers_RuntimeSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBProtocolBuffers_RuntimeSupport.h; sourceTree = ""; }; + F4584D801ECCB39E00803AB6 /* GPBExtensionRegistryTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GPBExtensionRegistryTest.m; path = Tests/GPBExtensionRegistryTest.m; sourceTree = SOURCE_ROOT; }; F45C69CB16DFD08D0081955B /* GPBExtensionInternals.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBExtensionInternals.m; sourceTree = ""; }; F45E57C81AE6DC98000B7D99 /* text_format_map_unittest_data.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = text_format_map_unittest_data.txt; sourceTree = ""; }; F4AC9E1C1A8BEB1000BD6E83 /* unittest_cycle.proto */ = {isa = PBXFileReference; lastKnownFileType = text; path = unittest_cycle.proto; sourceTree = ""; }; @@ -441,6 +443,7 @@ F4353D3E1AC06F31005A6198 /* GPBDictionaryTests+String.m */, F4353D3F1AC06F31005A6198 /* GPBDictionaryTests+UInt32.m */, F4353D401AC06F31005A6198 /* GPBDictionaryTests+UInt64.m */, + F4584D801ECCB39E00803AB6 /* GPBExtensionRegistryTest.m */, 7461B6A30F94FDF800A0C422 /* GPBMessageTests.m */, F4487C841AAF6AC500531423 /* GPBMessageTests+Merge.m */, F4487C761AADF84900531423 /* GPBMessageTests+Runtime.m */, @@ -456,8 +459,8 @@ 7461B6BA0F94FDF900A0C422 /* GPBUtilitiesTests.m */, 8B4248E51A929C9900BC1EC6 /* GPBWellKnownTypesTest.m */, 7461B6BC0F94FDF900A0C422 /* GPBWireFormatTests.m */, - F43C88CF191D77FC009E917D /* text_format_unittest_data.txt */, F45E57C81AE6DC98000B7D99 /* text_format_map_unittest_data.txt */, + F43C88CF191D77FC009E917D /* text_format_unittest_data.txt */, 8B7E6A7414893DBA00F8884A /* unittest_custom_options.proto */, F4AC9E1C1A8BEB1000BD6E83 /* unittest_cycle.proto */, 8B7E6A7514893DBA00F8884A /* unittest_embed_optimize_for.proto */, @@ -467,8 +470,8 @@ 8BBD9DB016DD1DC8008E1EC1 /* unittest_lite.proto */, 8B7E6A7B14893DBC00F8884A /* unittest_mset.proto */, 8B7E6A7C14893DBC00F8884A /* unittest_no_generic_services.proto */, - 8B09AAF614B663A7007B4184 /* unittest_objc.proto */, F4CF31711B162EF500BD9B06 /* unittest_objc_startup.proto */, + 8B09AAF614B663A7007B4184 /* unittest_objc.proto */, 8B7E6A7D14893DBC00F8884A /* unittest_optimize_for.proto */, F4487C7A1AADFB5500531423 /* unittest_runtime_proto2.proto */, F4487C7B1AADFB5500531423 /* unittest_runtime_proto3.proto */, @@ -765,6 +768,7 @@ F4F8D8861D78A193002CE128 /* GPBUnittestProtos2.m in Sources */, F4B51B1C1BBC5C7100744318 /* GPBObjectiveCPlusPlusTest.mm in Sources */, 8B4248B41A8BD96E00BC1EC6 /* GPBSwiftTests.swift in Sources */, + F4584D831ECCB53600803AB6 /* GPBExtensionRegistryTest.m in Sources */, 5102DABC1891A073002037B6 /* GPBConcurrencyTests.m in Sources */, F4487C771AADF84900531423 /* GPBMessageTests+Runtime.m in Sources */, F4353D431AC06F31005A6198 /* GPBDictionaryTests+Int32.m in Sources */, diff --git a/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme b/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme index be31c308..1ba3a329 100644 --- a/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme +++ b/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme @@ -50,6 +50,12 @@ + + + + @@ -89,6 +95,9 @@ + + diff --git a/objectivec/Tests/GPBExtensionRegistryTest.m b/objectivec/Tests/GPBExtensionRegistryTest.m new file mode 100644 index 00000000..b1168826 --- /dev/null +++ b/objectivec/Tests/GPBExtensionRegistryTest.m @@ -0,0 +1,138 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2017 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// 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. + +#import "GPBTestUtilities.h" + +#import "GPBExtensionRegistry.h" +#import "google/protobuf/Unittest.pbobjc.h" + +@interface GPBExtensionRegistryTest : GPBTestCase +@end + +@implementation GPBExtensionRegistryTest + +- (void)testBasics { + GPBExtensionRegistry *reg = [[[GPBExtensionRegistry alloc] init] autorelease]; + XCTAssertNotNil(reg); + + XCTAssertNil([reg extensionForDescriptor:[TestAllExtensions descriptor] + fieldNumber:1]); + XCTAssertNil([reg extensionForDescriptor:[TestAllTypes descriptor] + fieldNumber:1]); + + [reg addExtension:[UnittestRoot optionalInt32Extension]]; + [reg addExtension:[UnittestRoot packedInt64Extension]]; + + XCTAssertTrue([reg extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:1] == + [UnittestRoot optionalInt32Extension]); // ptr equality + XCTAssertNil([reg extensionForDescriptor:[TestAllTypes descriptor] + fieldNumber:1]); + XCTAssertTrue([reg extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:91] == + [UnittestRoot packedInt64Extension]); // ptr equality +} + +- (void)testCopy { + GPBExtensionRegistry *reg1 = [[[GPBExtensionRegistry alloc] init] autorelease]; + [reg1 addExtension:[UnittestRoot optionalInt32Extension]]; + + GPBExtensionRegistry *reg2 = [[reg1 copy] autorelease]; + XCTAssertNotNil(reg2); + + XCTAssertTrue([reg1 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:1] == + [UnittestRoot optionalInt32Extension]); // ptr equality + XCTAssertTrue([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:1] == + [UnittestRoot optionalInt32Extension]); // ptr equality + + // Message class that had registered extension(s) at the -copy time. + + [reg1 addExtension:[UnittestRoot optionalBoolExtension]]; + [reg2 addExtension:[UnittestRoot optionalStringExtension]]; + + XCTAssertTrue([reg1 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:13] == + [UnittestRoot optionalBoolExtension]); // ptr equality + XCTAssertNil([reg1 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:14]); + XCTAssertNil([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:13]); + XCTAssertTrue([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:14] == + [UnittestRoot optionalStringExtension]); // ptr equality + + // Message class that did not have any registered extensions at the -copy time. + + [reg1 addExtension:[UnittestRoot packedInt64Extension]]; + [reg2 addExtension:[UnittestRoot packedSint32Extension]]; + + XCTAssertTrue([reg1 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:91] == + [UnittestRoot packedInt64Extension]); // ptr equality + XCTAssertNil([reg1 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:94]); + XCTAssertNil([reg2 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:91]); + XCTAssertTrue([reg2 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:94] == + [UnittestRoot packedSint32Extension]); // ptr equality + +} + +- (void)testAddExtensions { + GPBExtensionRegistry *reg1 = [[[GPBExtensionRegistry alloc] init] autorelease]; + [reg1 addExtension:[UnittestRoot optionalInt32Extension]]; + + GPBExtensionRegistry *reg2 = [[[GPBExtensionRegistry alloc] init] autorelease]; + + XCTAssertNil([reg2 extensionForDescriptor:[TestAllExtensions descriptor] + fieldNumber:1]); + + [reg2 addExtensions:reg1]; + + XCTAssertTrue([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:1] == + [UnittestRoot optionalInt32Extension]); // ptr equality + + // Confirm adding to the first doesn't add to the second. + + [reg1 addExtension:[UnittestRoot optionalBoolExtension]]; + [reg1 addExtension:[UnittestRoot packedInt64Extension]]; + + XCTAssertTrue([reg1 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:13] == + [UnittestRoot optionalBoolExtension]); // ptr equality + XCTAssertTrue([reg1 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:91] == + [UnittestRoot packedInt64Extension]); // ptr equality + XCTAssertNil([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:13]); + XCTAssertNil([reg2 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:91]); + + // Confirm adding to the second doesn't add to the first. + + [reg2 addExtension:[UnittestRoot optionalStringExtension]]; + [reg2 addExtension:[UnittestRoot packedSint32Extension]]; + + XCTAssertNil([reg1 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:14]); + XCTAssertNil([reg1 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:94]); + XCTAssertTrue([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:14] == + [UnittestRoot optionalStringExtension]); // ptr equality + XCTAssertTrue([reg2 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:94] == + [UnittestRoot packedSint32Extension]); // ptr equality +} + +@end -- cgit v1.2.3 From 3b227611d5c5b216fd323908b0c6c4af19777a52 Mon Sep 17 00:00:00 2001 From: Dennis Cappendijk Date: Mon, 22 May 2017 16:21:48 +0200 Subject: show help if protoc is called without any arguments, pre-empts -h and --help to show a useful message instead of just 'Missing input file.' --- src/google/protobuf/compiler/command_line_interface.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index 7fcd0083..df03907d 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -1012,6 +1012,12 @@ CommandLineInterface::ParseArguments(int argc, const char* const argv[]) { arguments.push_back(argv[i]); } + // if no arguments are given, show help + if(arguments.empty()) { + PrintHelpText(); + return PARSE_ARGUMENT_DONE_AND_EXIT; // Exit without running compiler. + } + // Iterate through all arguments and parse them. for (int i = 0; i < arguments.size(); ++i) { string name, value; -- cgit v1.2.3 From 979107ec7a257cbb6a0fa221956a9b2ada03b7ad Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Thu, 18 May 2017 20:24:04 +0200 Subject: Improve fix for https://github.com/google/protobuf/issues/295 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Requiring the legacy ‘cl’ library unconditionally pollutes the namespace. Instead, require it only when compiling and in known-broken versions. This is almost the same patch that opoplawski suggested, except that I removed the test for ‘emacs-repository-version’, which isn’t defined in Emacs 24.3. --- editors/protobuf-mode.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/editors/protobuf-mode.el b/editors/protobuf-mode.el index 1cef4137..d3bdcded 100644 --- a/editors/protobuf-mode.el +++ b/editors/protobuf-mode.el @@ -64,9 +64,11 @@ ;;; Code: (require 'cc-mode) -(require 'cl) (eval-when-compile + (and (= emacs-major-version 24) + (>= emacs-minor-version 4) + (require 'cl)) (require 'cc-langs) (require 'cc-fonts)) -- cgit v1.2.3 From 677557009ca500291bb67b144c5492e6d2ce5cac Mon Sep 17 00:00:00 2001 From: Misha Brukman Date: Tue, 23 May 2017 10:33:03 -0400 Subject: Fix Markdown formatting in README. Fix indentation to enable code formatting for sample command lines to set them visually apart from the surrounding text, and make it easy to copy-paste. Add code formatting for env vars, paths, binary and library names for readability. Hide URLs behind text for readability and conciseness. --- python/README.md | 83 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 45 insertions(+), 38 deletions(-) diff --git a/python/README.md b/python/README.md index 8f3db785..4c194297 100644 --- a/python/README.md +++ b/python/README.md @@ -32,77 +32,84 @@ Installation 1) Make sure you have Python 2.6 or newer. If in doubt, run: - $ python -V + $ python -V 2) If you do not have setuptools installed, note that it will be - downloaded and installed automatically as soon as you run setup.py. + downloaded and installed automatically as soon as you run `setup.py`. If you would rather install it manually, you may do so by following - the instructions on this page: + the instructions on [this page](https://packaging.python.org/en/latest/installing.html#setup-for-installing-packages). - https://packaging.python.org/en/latest/installing.html#setup-for-installing-packages - -3) Build the C++ code, or install a binary distribution of protoc. If +3) Build the C++ code, or install a binary distribution of `protoc`. If you install a binary distribution, make sure that it is the same version as this package. If in doubt, run: - $ protoc --version + $ protoc --version 4) Build and run the tests: - $ python setup.py build - $ python setup.py test + $ python setup.py build + $ python setup.py test + + To build, test, and use the C++ implementation, you must first compile + `libprotobuf.so`: + + $ (cd .. && make) + + On OS X: + + If you are running a Homebrew-provided Python, you must make sure another + version of protobuf is not already installed, as Homebrew's Python will + search `/usr/local/lib` for `libprotobuf.so` before it searches + `../src/.libs`. - To build, test, and use the C++ implementation, you must first compile - libprotobuf.so: + You can either unlink Homebrew's protobuf or install the `libprotobuf` you + built earlier: - $ (cd .. && make) + $ brew unlink protobuf - On OS X: + or - If you are running a homebrew-provided python, you must make sure another - version of protobuf is not already installed, as homebrew's python will - search /usr/local/lib for libprotobuf.so before it searches ../src/.libs - You can either unlink homebrew's protobuf or install the libprotobuf you - built earlier: + $ (cd .. && make install) - $ brew unlink protobuf - or - $ (cd .. && make install) + On other *nix: - On other *nix: + You must make `libprotobuf.so` dynamically available. You can either + install libprotobuf you built earlier, or set `LD_LIBRARY_PATH`: - You must make libprotobuf.so dynamically available. You can either - install libprotobuf you built earlier, or set LD_LIBRARY_PATH: + $ export LD_LIBRARY_PATH=../src/.libs - $ export LD_LIBRARY_PATH=../src/.libs - or - $ (cd .. && make install) + or - To build the C++ implementation run: - $ python setup.py build --cpp_implementation + $ (cd .. && make install) - Then run the tests like so: - $ python setup.py test --cpp_implementation + To build the C++ implementation run: + + $ python setup.py build --cpp_implementation + + Then run the tests like so: + + $ python setup.py test --cpp_implementation If some tests fail, this library may not work correctly on your system. Continue at your own risk. Please note that there is a known problem with some versions of Python on Cygwin which causes the tests to fail after printing the - error: "sem_init: Resource temporarily unavailable". This appears - to be a bug either in Cygwin or in Python: - http://www.cygwin.com/ml/cygwin/2005-07/msg01378.html + error: `sem_init: Resource temporarily unavailable`. This appears + to be a [bug either in Cygwin or in + Python](http://www.cygwin.com/ml/cygwin/2005-07/msg01378.html). + We do not know if or when it might be fixed. We also do not know how likely it is that this bug will affect users in practice. 5) Install: - $ python setup.py install + $ python setup.py install - or: + or: - $ (cd .. && make install) - $ python setup.py install --cpp_implementation + $ (cd .. && make install) + $ python setup.py install --cpp_implementation This step may require superuser privileges. NOTE: To use C++ implementation, you need to export an environment -- cgit v1.2.3 From 2465ae7e23771109e5710d32e2cf548ba0d1c083 Mon Sep 17 00:00:00 2001 From: Sergio Campama Date: Wed, 17 May 2017 12:05:00 -0400 Subject: Adds serial and parallel parsing tests to check if parallel parsing is faster than serial parsing, which it should --- objectivec/Tests/GPBPerfTests.m | 106 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/objectivec/Tests/GPBPerfTests.m b/objectivec/Tests/GPBPerfTests.m index 1259d146..8dd0ffc5 100644 --- a/objectivec/Tests/GPBPerfTests.m +++ b/objectivec/Tests/GPBPerfTests.m @@ -64,6 +64,112 @@ static const uint32_t kRepeatedCount = 100; }]; } +- (void)testMessageSerialParsingPerformance { + // This and the next test are meant to monitor that the parsing functionality of protos does not + // lock across threads when parsing different instances. The Serial version of the test should run + // around ~2 times slower than the Parallel version since it's parsing the protos in the same + // thread. + TestAllTypes *allTypesMessage = [TestAllTypes message]; + [self setAllFields:allTypesMessage repeatedCount:2]; + NSData *allTypesData = allTypesMessage.data; + + [self measureBlock:^{ + for (int i = 0; i < 500; ++i) { + [TestAllTypes parseFromData:allTypesData error:NULL]; + [TestAllTypes parseFromData:allTypesData error:NULL]; + } + }]; +} + +- (void)testMessageParallelParsingPerformance { + // This and the previous test are meant to monitor that the parsing functionality of protos does + // not lock across threads when parsing different instances. The Serial version of the test should + // run around ~2 times slower than the Parallel version since it's parsing the protos in the same + // thread. + TestAllTypes *allTypesMessage = [TestAllTypes message]; + [self setAllFields:allTypesMessage repeatedCount:2]; + NSData *allTypesData = allTypesMessage.data; + + dispatch_queue_t concurrentQueue = dispatch_queue_create("perfQueue", DISPATCH_QUEUE_CONCURRENT); + + [self measureBlock:^{ + for (int i = 0; i < 500; ++i) { + dispatch_group_t group = dispatch_group_create(); + + dispatch_group_async(group, concurrentQueue, ^{ + [TestAllTypes parseFromData:allTypesData error:NULL]; + }); + + dispatch_group_async(group, concurrentQueue, ^{ + [TestAllTypes parseFromData:allTypesData error:NULL]; + }); + + dispatch_group_notify(group, concurrentQueue, ^{}); + + dispatch_release(group); + } + }]; + + dispatch_release(concurrentQueue); +} + +- (void)testMessageSerialExtensionsParsingPerformance { + // This and the next test are meant to monitor that the parsing functionality of protos does not + // lock across threads when parsing different instances when using extensions. The Serial version + // of the test should run around ~2 times slower than the Parallel version since it's parsing the + // protos in the same thread. + TestAllExtensions *allExtensionsMessage = [TestAllExtensions message]; + [self setAllExtensions:allExtensionsMessage repeatedCount:2]; + NSData *allExtensionsData = allExtensionsMessage.data; + + [self measureBlock:^{ + for (int i = 0; i < 500; ++i) { + [TestAllExtensions parseFromData:allExtensionsData + extensionRegistry:[self extensionRegistry] + error:NULL]; + [TestAllExtensions parseFromData:allExtensionsData + extensionRegistry:[self extensionRegistry] + error:NULL]; + } + }]; +} + +- (void)testMessageParallelExtensionsParsingPerformance { + // This and the previous test are meant to monitor that the parsing functionality of protos does + // not lock across threads when parsing different instances when using extensions. The Serial + // version of the test should run around ~2 times slower than the Parallel version since it's + // parsing the protos in the same thread. + TestAllExtensions *allExtensionsMessage = [TestAllExtensions message]; + [self setAllExtensions:allExtensionsMessage repeatedCount:2]; + NSData *allExtensionsData = allExtensionsMessage.data; + + dispatch_queue_t concurrentQueue = dispatch_queue_create("perfQueue", DISPATCH_QUEUE_CONCURRENT); + + [self measureBlock:^{ + for (int i = 0; i < 500; ++i) { + dispatch_group_t group = dispatch_group_create(); + + dispatch_group_async(group, concurrentQueue, ^{ + [TestAllExtensions parseFromData:allExtensionsData + extensionRegistry:[UnittestRoot extensionRegistry] + error:NULL]; + }); + + dispatch_group_async(group, concurrentQueue, ^{ + [TestAllExtensions parseFromData:allExtensionsData + extensionRegistry:[UnittestRoot extensionRegistry] + error:NULL]; + }); + + dispatch_group_notify(group, concurrentQueue, ^{}); + + dispatch_release(group); + } + }]; + + dispatch_release(concurrentQueue); +} + - (void)testExtensionsPerformance { [self measureBlock:^{ for (int i = 0; i < 200; ++i) { -- cgit v1.2.3 From 40da1ed572d60e9c7cc2fe1ca4175e30682f5a9d Mon Sep 17 00:00:00 2001 From: brian-peloton Date: Tue, 23 May 2017 16:22:57 -0700 Subject: Removing undefined behavior and compiler warnings (#1315) * Comment out unused arguments. These last few are all that's needed to compile with -Wunused-arguments. * Fix missing struct field initializer. With this fix, everything compiles with -Wmissing-field-initializers. * Add support for disabling unaligned memory accesses on x86 too. ubsan doesn't like these because they are technically undefined behavior, so -DGOOGLE_PROTOBUF_DONT_USE_UNALIGNED will disable them easily. * Avoid undefined integer overflow. ubsan catches all of these. --- src/google/protobuf/arena.h | 6 ++-- src/google/protobuf/compiler/parser.cc | 2 +- src/google/protobuf/io/tokenizer_unittest.cc | 2 +- src/google/protobuf/message.h | 6 ++-- src/google/protobuf/stubs/port.h | 10 ++++-- src/google/protobuf/util/message_differencer.h | 42 +++++++++++++------------- src/google/protobuf/wire_format_lite.h | 2 +- 7 files changed, 38 insertions(+), 32 deletions(-) diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h index b6a375ac..0ffc6004 100644 --- a/src/google/protobuf/arena.h +++ b/src/google/protobuf/arena.h @@ -829,13 +829,13 @@ class LIBPROTOBUF_EXPORT Arena { } template static void CreateInArenaStorageInternal( - T* ptr, Arena* arena, google::protobuf::internal::false_type) { + T* ptr, Arena* /* arena */, google::protobuf::internal::false_type) { new (ptr) T(); } template static void RegisterDestructorInternal( - T* ptr, Arena* arena, google::protobuf::internal::true_type) {} + T* /* ptr */, Arena* /* arena */, google::protobuf::internal::true_type) {} template static void RegisterDestructorInternal( T* ptr, Arena* arena, google::protobuf::internal::false_type) { @@ -870,7 +870,7 @@ class LIBPROTOBUF_EXPORT Arena { } template GOOGLE_ATTRIBUTE_ALWAYS_INLINE - static ::google::protobuf::Arena* GetArenaInternal(const T* value, ...) { + static ::google::protobuf::Arena* GetArenaInternal(const T* /* value */, ...) { return NULL; } diff --git a/src/google/protobuf/compiler/parser.cc b/src/google/protobuf/compiler/parser.cc index 7a03d42b..1a409566 100644 --- a/src/google/protobuf/compiler/parser.cc +++ b/src/google/protobuf/compiler/parser.cc @@ -1373,7 +1373,7 @@ bool Parser::ParseOption(Message* options, value_location.AddPath( UninterpretedOption::kNegativeIntValueFieldNumber); uninterpreted_option->set_negative_int_value( - -static_cast(value)); + static_cast(-value)); } else { value_location.AddPath( UninterpretedOption::kPositiveIntValueFieldNumber); diff --git a/src/google/protobuf/io/tokenizer_unittest.cc b/src/google/protobuf/io/tokenizer_unittest.cc index cadeb696..e55288e2 100644 --- a/src/google/protobuf/io/tokenizer_unittest.cc +++ b/src/google/protobuf/io/tokenizer_unittest.cc @@ -341,7 +341,7 @@ inline std::ostream& operator<<(std::ostream& out, MultiTokenCase kMultiTokenCases[] = { // Test empty input. { "", { - { Tokenizer::TYPE_END , "" , 0, 0 }, + { Tokenizer::TYPE_END , "" , 0, 0, 0 }, }}, // Test all token types at the same time. diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h index 68acb5b1..c155cbd6 100644 --- a/src/google/protobuf/message.h +++ b/src/google/protobuf/message.h @@ -753,7 +753,7 @@ class LIBPROTOBUF_EXPORT Reflection { // TODO(tmarek): Make virtual after all subclasses have been // updated. virtual void AddAllocatedMessage(Message* /* message */, - const FieldDescriptor* /*field */, + const FieldDescriptor* /* field */, Message* /* new_entry */) const {} @@ -961,7 +961,7 @@ class LIBPROTOBUF_EXPORT Reflection { // TODO(jieluo) - make the map APIs pure virtual after updating // all the subclasses. // Returns true if key is in map. Returns false if key is not in map field. - virtual bool ContainsMapKey(const Message& /* message*/, + virtual bool ContainsMapKey(const Message& /* message */, const FieldDescriptor* /* field */, const MapKey& /* key */) const { return false; @@ -979,7 +979,7 @@ class LIBPROTOBUF_EXPORT Reflection { // Delete and returns true if key is in the map field. Returns false // otherwise. - virtual bool DeleteMapValue(Message* /* mesage */, + virtual bool DeleteMapValue(Message* /* message */, const FieldDescriptor* /* field */, const MapKey& /* key */) const { return false; diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h index 6ec5e001..0afd55d7 100644 --- a/src/google/protobuf/stubs/port.h +++ b/src/google/protobuf/stubs/port.h @@ -252,9 +252,15 @@ static const uint64 kuint64max = GOOGLE_ULONGLONG(0xFFFFFFFFFFFFFFFF); #define GOOGLE_GUARDED_BY(x) #define GOOGLE_ATTRIBUTE_COLD +#ifdef GOOGLE_PROTOBUF_DONT_USE_UNALIGNED +# define GOOGLE_PROTOBUF_USE_UNALIGNED 0 +#else // x86 and x86-64 can perform unaligned loads/stores directly. -#if defined(_M_X64) || defined(__x86_64__) || \ - defined(_M_IX86) || defined(__i386__) +# define GOOGLE_PROTOBUF_USE_UNALIGNED defined(_M_X64) || \ + defined(__x86_64__) || defined(_M_IX86) || defined(__i386__) +#endif + +#if GOOGLE_PROTOBUF_USE_UNALIGNED #define GOOGLE_UNALIGNED_LOAD16(_p) (*reinterpret_cast(_p)) #define GOOGLE_UNALIGNED_LOAD32(_p) (*reinterpret_cast(_p)) diff --git a/src/google/protobuf/util/message_differencer.h b/src/google/protobuf/util/message_differencer.h index d99223cb..192266b6 100644 --- a/src/google/protobuf/util/message_differencer.h +++ b/src/google/protobuf/util/message_differencer.h @@ -241,18 +241,18 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { // mutually exclusive. If a field has been both moved and modified, then // only ReportModified will be called. virtual void ReportMoved( - const Message& message1, - const Message& message2, - const std::vector& field_path) { } + const Message& /* message1 */, + const Message& /* message2 */, + const std::vector& /* field_path */) { } // Reports that two fields match. Useful for doing side-by-side diffs. // This function is mutually exclusive with ReportModified and ReportMoved. // Note that you must call set_report_matches(true) before calling Compare // to make use of this function. virtual void ReportMatched( - const Message& message1, - const Message& message2, - const std::vector& field_path) { } + const Message& /* message1 */, + const Message& /* message2 */, + const std::vector& /* field_path */) { } // Reports that two fields would have been compared, but the // comparison has been skipped because the field was marked as @@ -274,16 +274,16 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { // the fields are equal or not (perhaps with a second call to // Compare()), if it cares. virtual void ReportIgnored( - const Message& message1, - const Message& message2, - const std::vector& field_path) { } + const Message& /* message1 */, + const Message& /* message2 */, + const std::vector& /* field_path */) { } // Report that an unknown field is ignored. (see comment above). // Note this is a different function since the last SpecificField in field // path has a null field. This could break existing Reporter. virtual void ReportUnknownFieldIgnored( - const Message& message1, const Message& message2, - const std::vector& field_path) {} + const Message& /* message1 */, const Message& /* message2 */, + const std::vector& /* field_path */) {} private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Reporter); @@ -297,9 +297,9 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { virtual ~MapKeyComparator(); virtual bool IsMatch( - const Message& message1, - const Message& message2, - const std::vector& parent_fields) const { + const Message& /* message1 */, + const Message& /* message2 */, + const std::vector& /* parent_fields */) const { GOOGLE_CHECK(false) << "IsMatch() is not implemented."; return false; } @@ -321,18 +321,18 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { // Returns true if the field should be ignored. virtual bool IsIgnored( - const Message& message1, - const Message& message2, - const FieldDescriptor* field, - const std::vector& parent_fields) = 0; + const Message& /* message1 */, + const Message& /* message2 */, + const FieldDescriptor* /* field */, + const std::vector& /* parent_fields */) = 0; // Returns true if the unknown field should be ignored. // Note: This will be called for unknown fields as well in which case // field.field will be null. virtual bool IsUnknownFieldIgnored( - const Message& message1, const Message& message2, - const SpecificField& field, - const std::vector& parent_fields) { + const Message& /* message1 */, const Message& /* message2 */, + const SpecificField& /* field */, + const std::vector& /* parent_fields */) { return false; } }; diff --git a/src/google/protobuf/wire_format_lite.h b/src/google/protobuf/wire_format_lite.h index 18b38eae..ce55f266 100644 --- a/src/google/protobuf/wire_format_lite.h +++ b/src/google/protobuf/wire_format_lite.h @@ -197,7 +197,7 @@ class LIBPROTOBUF_EXPORT WireFormatLite { // type-safe, though, so prefer it if possible. #define GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(FIELD_NUMBER, TYPE) \ static_cast( \ - ((FIELD_NUMBER) << ::google::protobuf::internal::WireFormatLite::kTagTypeBits) \ + (static_cast(FIELD_NUMBER) << ::google::protobuf::internal::WireFormatLite::kTagTypeBits) \ | (TYPE)) // These are the tags for the old MessageSet format, which was defined as: -- cgit v1.2.3 From f26e8c2ae0a490399f7e77d96193f2851b185b56 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Thu, 4 May 2017 08:51:46 +0100 Subject: Convert C# projects to MSBuild (csproj) format This has one important packaging change: the netstandard version now depends (implicitly) on netstandard1.6.1 rather than on individual packages. This is the preferred style of dependency, and shouldn't affect any users - see http://stackoverflow.com/questions/42946951 for details. The tests are still NUnit, but NUnit doesn't support "dotnet test" yet; the test project is now an executable using NUnitLite. (When NUnit supports dotnet test, we can adapt to it.) Note that the project will now only work in Visual Studio 2017 (and Visual Studio Code, and from the command line with the .NET Core 1.0.0 SDK); Visual Studio 2015 does *not* support this project file format. --- .travis.yml | 3 + Makefile.am | 21 +++---- appveyor.bat | 8 ++- appveyor.yml | 3 +- csharp/build_packages.bat | 4 +- csharp/buildall.sh | 5 +- .../Google.Protobuf.Test.csproj | 30 ++++++++++ .../Google.Protobuf.Test.xproj | 19 ------- .../v3.0.0/src/Google.Protobuf.Test/Program.cs | 47 ++++++++++++++++ .../v3.0.0/src/Google.Protobuf.Test/project.json | 44 --------------- csharp/compatibility_tests/v3.0.0/test.sh | 8 ++- csharp/global.json | 5 ++ csharp/src/AddressBook/AddressBook.csproj | 14 +++++ csharp/src/AddressBook/AddressBook.xproj | 19 ------- csharp/src/AddressBook/project.json | 20 ------- .../Google.Protobuf.Conformance.csproj | 14 +++++ .../Google.Protobuf.Conformance.xproj | 19 ------- .../src/Google.Protobuf.Conformance/project.json | 21 ------- .../Google.Protobuf.JsonDump.csproj | 13 +++++ .../Google.Protobuf.JsonDump.xproj | 19 ------- csharp/src/Google.Protobuf.JsonDump/project.json | 19 ------- .../Google.Protobuf.Test.csproj | 30 ++++++++++ .../Google.Protobuf.Test.xproj | 21 ------- csharp/src/Google.Protobuf.Test/Program.cs | 44 +++++++++++++++ csharp/src/Google.Protobuf.Test/project.json | 45 --------------- csharp/src/Google.Protobuf.sln | 16 +++--- csharp/src/Google.Protobuf/Google.Protobuf.csproj | 32 +++++++++++ csharp/src/Google.Protobuf/Google.Protobuf.xproj | 19 ------- csharp/src/Google.Protobuf/project.json | 65 ---------------------- csharp/src/global.json | 5 -- csharp/src/packages/repositories.config | 4 -- jenkins/docker/Dockerfile | 2 +- tests.sh | 19 +------ 33 files changed, 269 insertions(+), 388 deletions(-) create mode 100644 csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj delete mode 100644 csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj create mode 100644 csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Program.cs delete mode 100644 csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/project.json create mode 100644 csharp/global.json create mode 100644 csharp/src/AddressBook/AddressBook.csproj delete mode 100644 csharp/src/AddressBook/AddressBook.xproj delete mode 100644 csharp/src/AddressBook/project.json create mode 100644 csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj delete mode 100644 csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.xproj delete mode 100644 csharp/src/Google.Protobuf.Conformance/project.json create mode 100644 csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj delete mode 100644 csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.xproj delete mode 100644 csharp/src/Google.Protobuf.JsonDump/project.json create mode 100644 csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj delete mode 100644 csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj create mode 100644 csharp/src/Google.Protobuf.Test/Program.cs delete mode 100644 csharp/src/Google.Protobuf.Test/project.json create mode 100644 csharp/src/Google.Protobuf/Google.Protobuf.csproj delete mode 100644 csharp/src/Google.Protobuf/Google.Protobuf.xproj delete mode 100644 csharp/src/Google.Protobuf/project.json delete mode 100644 csharp/src/global.json delete mode 100644 csharp/src/packages/repositories.config diff --git a/.travis.yml b/.travis.yml index 8f6f90de..d49e0a71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,7 +55,10 @@ matrix: # autogenerated matrix. - os: linux env: CONFIG=csharp + language: csharp dist: trusty + dotnet: 1.0.1 + mono: none # This test is kept on travis because it doesn't play nicely with other # tests on jenkins running in parallel. - os: linux diff --git a/Makefile.am b/Makefile.am index 023afa40..3c3ca13d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -57,6 +57,7 @@ csharp_EXTRA_DIST= \ csharp/build_tools.sh \ csharp/buildall.sh \ csharp/generate_protos.sh \ + csharp/global.json \ csharp/keys/Google.Protobuf.public.snk \ csharp/keys/Google.Protobuf.snk \ csharp/keys/README.md \ @@ -64,18 +65,15 @@ csharp_EXTRA_DIST= \ csharp/protos/unittest_issues.proto \ csharp/src/AddressBook/AddPerson.cs \ csharp/src/AddressBook/Addressbook.cs \ - csharp/src/AddressBook/AddressBook.xproj \ + csharp/src/AddressBook/AddressBook.csproj \ csharp/src/AddressBook/ListPeople.cs \ csharp/src/AddressBook/Program.cs \ csharp/src/AddressBook/SampleUsage.cs \ - csharp/src/AddressBook/project.json \ csharp/src/Google.Protobuf.Conformance/Conformance.cs \ - csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.xproj \ + csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj \ csharp/src/Google.Protobuf.Conformance/Program.cs \ - csharp/src/Google.Protobuf.Conformance/project.json \ - csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.xproj \ + csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj \ csharp/src/Google.Protobuf.JsonDump/Program.cs \ - csharp/src/Google.Protobuf.JsonDump/project.json \ csharp/src/Google.Protobuf.Test/ByteStringTest.cs \ csharp/src/Google.Protobuf.Test/CodedInputStreamExtensions.cs \ csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs \ @@ -89,11 +87,12 @@ csharp_EXTRA_DIST= \ csharp/src/Google.Protobuf.Test/EqualityTester.cs \ csharp/src/Google.Protobuf.Test/FieldCodecTest.cs \ csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs \ - csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj \ + csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj \ csharp/src/Google.Protobuf.Test/IssuesTest.cs \ csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs \ csharp/src/Google.Protobuf.Test/JsonParserTest.cs \ csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs \ + csharp/src/Google.Protobuf.Test/Program.cs \ csharp/src/Google.Protobuf.Test/Reflection/CustomOptionsTest.cs \ csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs \ csharp/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs \ @@ -115,7 +114,6 @@ csharp_EXTRA_DIST= \ csharp/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs \ csharp/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs \ csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs \ - csharp/src/Google.Protobuf.Test/project.json \ csharp/src/Google.Protobuf.sln \ csharp/src/Google.Protobuf/ByteArray.cs \ csharp/src/Google.Protobuf/ByteString.cs \ @@ -130,7 +128,7 @@ csharp_EXTRA_DIST= \ csharp/src/Google.Protobuf/Compatibility/TypeExtensions.cs \ csharp/src/Google.Protobuf/FieldCodec.cs \ csharp/src/Google.Protobuf/FrameworkPortability.cs \ - csharp/src/Google.Protobuf/Google.Protobuf.xproj \ + csharp/src/Google.Protobuf/Google.Protobuf.csproj \ csharp/src/Google.Protobuf/ICustomDiagnosticMessage.cs \ csharp/src/Google.Protobuf/IDeepCloneable.cs \ csharp/src/Google.Protobuf/IMessage.cs \ @@ -190,10 +188,7 @@ csharp_EXTRA_DIST= \ csharp/src/Google.Protobuf/WellKnownTypes/ValuePartial.cs \ csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs \ csharp/src/Google.Protobuf/WellKnownTypes/WrappersPartial.cs \ - csharp/src/Google.Protobuf/WireFormat.cs \ - csharp/src/Google.Protobuf/project.json \ - csharp/src/global.json \ - csharp/src/packages/repositories.config + csharp/src/Google.Protobuf/WireFormat.cs java_EXTRA_DIST= \ java/README.md \ diff --git a/appveyor.bat b/appveyor.bat index 916f4434..ca88b25c 100644 --- a/appveyor.bat +++ b/appveyor.bat @@ -19,11 +19,15 @@ goto :EOF :build_csharp echo Building C# cd csharp\src +REM The platform environment variable is implicitly used by msbuild; +REM we don't want it. +set platform= dotnet restore -dotnet build -c %configuration% Google.Protobuf Google.Protobuf.Test Google.Protobuf.Conformance || goto error +dotnet build -c %configuration% || goto error echo Testing C# -dotnet test -c %configuration% Google.Protobuf.Test || goto error +dotnet run -c %configuration% -f netcoreapp1.0 -p Google.Protobuf.Test\Google.Protobuf.Test.csproj || goto error +dotnet run -c %configuration% -f net451 -p Google.Protobuf.Test\Google.Protobuf.Test.csproj || goto error goto :EOF diff --git a/appveyor.yml b/appveyor.yml index 08d087b6..8b440b63 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -14,6 +14,7 @@ environment: UNICODE: ON - language: csharp + image: Visual Studio 2017 # Our build scripts run tests automatically; we don't want AppVeyor # to try to detect them itself. @@ -29,8 +30,6 @@ install: - del /Q release-1.7.0.zip - rename googletest-release-1.7.0 gtest - move gtest gmock - - curl -L -o dotnetsdk.exe "https://go.microsoft.com/fwlink/?LinkID=809122" - - dotnetsdk.exe /install /quiet /norestart before_build: - if %platform%==Win32 set generator=Visual Studio 12 diff --git a/csharp/build_packages.bat b/csharp/build_packages.bat index 37732e7c..d7205659 100644 --- a/csharp/build_packages.bat +++ b/csharp/build_packages.bat @@ -1,7 +1,7 @@ @rem Builds Google.Protobuf NuGet packages -dotnet restore src -dotnet pack -c Release src\Google.Protobuf || goto :error +dotnet restore src/Google.Protobuf.sln +dotnet pack -c Release src/Google.Protobuf.sln || goto :error goto :EOF diff --git a/csharp/buildall.sh b/csharp/buildall.sh index cab32229..dd4b463d 100755 --- a/csharp/buildall.sh +++ b/csharp/buildall.sh @@ -6,11 +6,12 @@ SRC=$(dirname $0)/src set -ex echo Building relevant projects. -dotnet build -c $CONFIG $SRC/Google.Protobuf $SRC/Google.Protobuf.Test $SRC/Google.Protobuf.Conformance +dotnet restore $SRC/Google.Protobuf.sln +dotnet build -c $CONFIG $SRC/Google.Protobuf.sln echo Running tests. # Only test netcoreapp1.0, which uses the .NET Core runtime. # If we want to test the .NET 4.5 version separately, we could # run Mono explicitly. However, we don't have any differences between # the .NET 4.5 and netstandard1.0 assemblies. -dotnet test -c $CONFIG -f netcoreapp1.0 $SRC/Google.Protobuf.Test +dotnet run -c $CONFIG -f netcoreapp1.0 -p $SRC/Google.Protobuf.Test/Google.Protobuf.Test.csproj diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj new file mode 100644 index 00000000..06d07b9f --- /dev/null +++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj @@ -0,0 +1,30 @@ + + + + Exe + net451;netcoreapp1.0 + ../../keys/Google.Protobuf.snk + true + true + False + + + + + + + + + + + + + + netcoreapp1.0 + + + diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj deleted file mode 100644 index a9a1cc04..00000000 --- a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 580eb013-d3c7-4578-b845-015f4a3b0591 - Google.Protobuf.Test - .\obj - .\bin\ - - - - 2.0 - - - \ No newline at end of file diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Program.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Program.cs new file mode 100644 index 00000000..9078e59b --- /dev/null +++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Program.cs @@ -0,0 +1,47 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2017 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// 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 NUnitLite; +using System.Reflection; + +// Note: this file wasn't in the actual 3.0, but is required due to build +// system changes + +namespace Google.Protobuf.Test +{ + class Program + { + public static int Main(string[] args) + { + return new AutoRun(typeof(Program).GetTypeInfo().Assembly).Execute(args); + } + } +} \ No newline at end of file diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/project.json b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/project.json deleted file mode 100644 index 87b732c9..00000000 --- a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/project.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "buildOptions": { - "debugType": "portable", - "keyFile": "../../keys/Google.Protobuf.snk" - }, - - "configurations": { - "Debug": { - "buildOptions": { - "define": [ "DEBUG", "TRACE" ] - } - }, - "Release": { - "buildOptions": { - "define": [ "RELEASE", "TRACE" ], - "optimize": true - } - } - }, - - "dependencies": { - "Google.Protobuf": { "target": "project" }, - "NUnit": "3.4.0", - "dotnet-test-nunit": "3.4.0-alpha-2", - }, - - "testRunner": "nunit", - - "frameworks": { - "netcoreapp1.0": { - "imports" : [ "dnxcore50", "netcoreapp1.0", "portable-net45+win8" ], - "buildOptions": { - "define": [ "PCL" ] - }, - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.0.0", - "type": "platform" - }, - "System.Console": "4.0.0" - } - } - } -} \ No newline at end of file diff --git a/csharp/compatibility_tests/v3.0.0/test.sh b/csharp/compatibility_tests/v3.0.0/test.sh index bb04fc2c..54d28dfc 100755 --- a/csharp/compatibility_tests/v3.0.0/test.sh +++ b/csharp/compatibility_tests/v3.0.0/test.sh @@ -18,8 +18,11 @@ function run_test() { protos/src/google/protobuf/map_unittest_proto3.proto # Build and test. - dotnet build -c release src/Google.Protobuf src/Google.Protobuf.Test - dotnet test -c release -f netcoreapp1.0 src/Google.Protobuf.Test + dotnet restore src/Google.Protobuf/Google.Protobuf.csproj + dotnet restore src/Google.Protobuf.Test/Google.Protobuf.Test.csproj + dotnet build -c Release src/Google.Protobuf/Google.Protobuf.csproj + dotnet build -c Release src/Google.Protobuf.Test/Google.Protobuf.Test.csproj + dotnet run -c Release -f netcoreapp1.0 -p src/Google.Protobuf.Test/Google.Protobuf.Test.csproj } set -ex @@ -72,7 +75,6 @@ chmod +x old_protoc # Copy the new runtime and keys. cp ../../src/Google.Protobuf src/Google.Protobuf -r cp ../../keys . -r -dotnet restore # Test A.1: # proto set 1: use old version diff --git a/csharp/global.json b/csharp/global.json new file mode 100644 index 00000000..3622b564 --- /dev/null +++ b/csharp/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "1.0.0" + } +} diff --git a/csharp/src/AddressBook/AddressBook.csproj b/csharp/src/AddressBook/AddressBook.csproj new file mode 100644 index 00000000..6edfdcab --- /dev/null +++ b/csharp/src/AddressBook/AddressBook.csproj @@ -0,0 +1,14 @@ + + + + netcoreapp1.0 + Exe + Google.Protobuf.Examples.AddressBook.Program + False + + + + + + + diff --git a/csharp/src/AddressBook/AddressBook.xproj b/csharp/src/AddressBook/AddressBook.xproj deleted file mode 100644 index 4c9925e8..00000000 --- a/csharp/src/AddressBook/AddressBook.xproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - afb63919-1e05-43b4-802a-8fb8c9b2f463 - AddressBook - .\obj - .\bin\ - - - - 2.0 - - - \ No newline at end of file diff --git a/csharp/src/AddressBook/project.json b/csharp/src/AddressBook/project.json deleted file mode 100644 index c500bdc2..00000000 --- a/csharp/src/AddressBook/project.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "buildOptions": { - "debugType": "portable", - "emitEntryPoint": true, - "additionalArguments": [ "/main:Google.Protobuf.Examples.AddressBook.Program" ] - }, - "dependencies": { - "Google.Protobuf": { "target": "project" } - }, - "frameworks": { - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.0" - } - } - } - } -} diff --git a/csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj b/csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj new file mode 100644 index 00000000..b654c0b2 --- /dev/null +++ b/csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj @@ -0,0 +1,14 @@ + + + + netcoreapp1.0 + Exe + False + + + + + + + + diff --git a/csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.xproj b/csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.xproj deleted file mode 100644 index 99ff1465..00000000 --- a/csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.xproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - dddc055b-e185-4181-bab0-072f0f984569 - Google.Protobuf.Conformance - .\obj - .\bin\ - - - - 2.0 - - - \ No newline at end of file diff --git a/csharp/src/Google.Protobuf.Conformance/project.json b/csharp/src/Google.Protobuf.Conformance/project.json deleted file mode 100644 index 4cf05231..00000000 --- a/csharp/src/Google.Protobuf.Conformance/project.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "buildOptions": { - "debugType": "portable", - "emitEntryPoint": true - }, - "dependencies": { - "Google.Protobuf": { "target": "project" }, - "Google.Protobuf.Test": { "target": "project" } - }, - "frameworks": { - "netcoreapp1.0": { - "imports": [ "dnxcore50", "netcoreapp1.0", "portable-net45+win8" ], - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.0" - } - } - } - } -} diff --git a/csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj b/csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj new file mode 100644 index 00000000..4eda641a --- /dev/null +++ b/csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj @@ -0,0 +1,13 @@ + + + + netcoreapp1.0 + Exe + False + + + + + + + diff --git a/csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.xproj b/csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.xproj deleted file mode 100644 index 27095be5..00000000 --- a/csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.xproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 9695e08f-9829-497d-b95c-b38f28d48690 - Google.Protobuf.JsonDump - .\obj - .\bin\ - - - - 2.0 - - - \ No newline at end of file diff --git a/csharp/src/Google.Protobuf.JsonDump/project.json b/csharp/src/Google.Protobuf.JsonDump/project.json deleted file mode 100644 index 84b23c45..00000000 --- a/csharp/src/Google.Protobuf.JsonDump/project.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "buildOptions": { - "debugType": "portable", - "emitEntryPoint": true - }, - "dependencies": { - "Google.Protobuf": { "target": "project" } - }, - "frameworks": { - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.0" - } - } - } - } -} diff --git a/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj b/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj new file mode 100644 index 00000000..06d07b9f --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj @@ -0,0 +1,30 @@ + + + + Exe + net451;netcoreapp1.0 + ../../keys/Google.Protobuf.snk + true + true + False + + + + + + + + + + + + + + netcoreapp1.0 + + + diff --git a/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj b/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj deleted file mode 100644 index 6370441e..00000000 --- a/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 580eb013-d3c7-4578-b845-015f4a3b0591 - Google.Protobuf.Test - .\obj - .\bin\ - - - 2.0 - - - - - - \ No newline at end of file diff --git a/csharp/src/Google.Protobuf.Test/Program.cs b/csharp/src/Google.Protobuf.Test/Program.cs new file mode 100644 index 00000000..6e4daac9 --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/Program.cs @@ -0,0 +1,44 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2017 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// 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 NUnitLite; +using System.Reflection; + +namespace Google.Protobuf.Test +{ + class Program + { + public static int Main(string[] args) + { + return new AutoRun(typeof(Program).GetTypeInfo().Assembly).Execute(args); + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf.Test/project.json b/csharp/src/Google.Protobuf.Test/project.json deleted file mode 100644 index dff0ab73..00000000 --- a/csharp/src/Google.Protobuf.Test/project.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "buildOptions": { - "debugType": "portable", - "keyFile": "../../keys/Google.Protobuf.snk" - }, - - "configurations": { - "Debug": { - "buildOptions": { - "define": [ "DEBUG", "TRACE" ] - } - }, - "Release": { - "buildOptions": { - "define": [ "RELEASE", "TRACE" ], - "optimize": true - } - } - }, - - "dependencies": { - "Google.Protobuf": { "target": "project" }, - "dotnet-test-nunit": "3.4.0-beta-3", - "NUnit": "3.6.0" - }, - - "testRunner": "nunit", - - "frameworks": { - "net451": {}, - "netcoreapp1.0": { - "imports" : [ "dnxcore50", "netcoreapp1.0", "portable-net45+win8" ], - "buildOptions": { - "define": [ "PCL" ] - }, - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.0.0", - "type": "platform" - }, - "System.Console": "4.0.0" - } - } - } -} diff --git a/csharp/src/Google.Protobuf.sln b/csharp/src/Google.Protobuf.sln index 3c62bba3..443ee3e9 100644 --- a/csharp/src/Google.Protobuf.sln +++ b/csharp/src/Google.Protobuf.sln @@ -1,16 +1,16 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 -MinimumVisualStudioVersion = 14.0.24720.0 -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AddressBook", "AddressBook\AddressBook.xproj", "{AFB63919-1E05-43B4-802A-8FB8C9B2F463}" +# Visual Studio 15 +VisualStudioVersion = 15.0.26114.2 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddressBook", "AddressBook\AddressBook.csproj", "{AFB63919-1E05-43B4-802A-8FB8C9B2F463}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Google.Protobuf", "Google.Protobuf\Google.Protobuf.xproj", "{9B576380-726D-4142-8238-60A43AB0E35A}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Google.Protobuf", "Google.Protobuf\Google.Protobuf.csproj", "{9B576380-726D-4142-8238-60A43AB0E35A}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Google.Protobuf.Test", "Google.Protobuf.Test\Google.Protobuf.Test.xproj", "{580EB013-D3C7-4578-B845-015F4A3B0591}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Google.Protobuf.Test", "Google.Protobuf.Test\Google.Protobuf.Test.csproj", "{580EB013-D3C7-4578-B845-015F4A3B0591}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Google.Protobuf.Conformance", "Google.Protobuf.Conformance\Google.Protobuf.Conformance.xproj", "{DDDC055B-E185-4181-BAB0-072F0F984569}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Google.Protobuf.Conformance", "Google.Protobuf.Conformance\Google.Protobuf.Conformance.csproj", "{DDDC055B-E185-4181-BAB0-072F0F984569}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Google.Protobuf.JsonDump", "Google.Protobuf.JsonDump\Google.Protobuf.JsonDump.xproj", "{9695E08F-9829-497D-B95C-B38F28D48690}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Google.Protobuf.JsonDump", "Google.Protobuf.JsonDump\Google.Protobuf.JsonDump.csproj", "{9695E08F-9829-497D-B95C-B38F28D48690}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj new file mode 100644 index 00000000..cf30e4a8 --- /dev/null +++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj @@ -0,0 +1,32 @@ + + + + C# runtime library for Protocol Buffers - Google's data interchange format. + Copyright 2015, Google Inc. + Google Protocol Buffers + 3.3.0 + Google Inc. + netstandard1.0;net451 + true + ../../keys/Google.Protobuf.snk + true + true + Protocol;Buffers;Binary;Serialization;Format;Google;proto;proto3 + C# proto3 support + https://github.com/google/protobuf + https://github.com/google/protobuf/blob/master/LICENSE + git + https://github.com/nodatime/nodatime.git + true + + + + + netstandard1.0 + + + diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.xproj b/csharp/src/Google.Protobuf/Google.Protobuf.xproj deleted file mode 100644 index c68e0db3..00000000 --- a/csharp/src/Google.Protobuf/Google.Protobuf.xproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 9b576380-726d-4142-8238-60a43ab0e35a - Google.Protobuf - .\obj - .\bin\ - - - - 2.0 - - - \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/project.json b/csharp/src/Google.Protobuf/project.json deleted file mode 100644 index f4376238..00000000 --- a/csharp/src/Google.Protobuf/project.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "version": "3.3.0", - "title": "Google Protocol Buffers", - "description": "See project site for more info.", - "authors": [ "Google Inc." ], - "copyright": "Copyright 2015, Google Inc.", - - "packOptions": { - "summary": "C# runtime library for Protocol Buffers - Google's data interchange format.", - "tags": [ "Protocol", "Buffers", "Binary", "Serialization", "Format", "Google", "proto", "proto3" ], - "owners": [ "protobuf-packages" ], - "licenseUrl": "https://github.com/google/protobuf/blob/master/LICENSE", - "projectUrl": "https://github.com/google/protobuf", - "releaseNotes": "C# proto3 support", - "requireLicenseAcceptance": false, - "repository": { - "url": "https://github.com/nodatime/nodatime.git" - } - }, - - "buildOptions": { - "debugType": "portable", - "keyFile": "../../keys/Google.Protobuf.snk", - "xmlDoc": true - }, - - "configurations": { - "Debug": { - "buildOptions": { - "define": [ "DEBUG", "TRACE" ] - } - }, - "Release": { - "buildOptions": { - "define": [ "RELEASE", "TRACE" ], - "optimize": true - } - } - }, - - "frameworks": { - // This target allows the package to be installed in a .NET 4.5+ - // project without asking for myriad other dependencies. - "net45": { - }, - "netstandard1.0": { - "dependencies": { - "System.Collections": "4.0.11", - "System.Diagnostics.Debug": "4.0.11", - "System.Globalization": "4.0.11", - "System.IO": "4.1.0", - "System.Linq": "4.1.0", - "System.Linq.Expressions": "4.1.0", - "System.ObjectModel": "4.0.12", - "System.Reflection": "4.1.0", - "System.Reflection.Extensions": "4.0.1", - "System.Runtime": "4.1.0", - "System.Runtime.Extensions": "4.1.0", - "System.Text.Encoding": "4.0.11", - "System.Text.RegularExpressions": "4.1.0", - "System.Threading": "4.0.11" - } - } - } -} diff --git a/csharp/src/global.json b/csharp/src/global.json deleted file mode 100644 index 9d5558b1..00000000 --- a/csharp/src/global.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "sdk": { - "version": "1.0.0-preview2-003131" - } -} diff --git a/csharp/src/packages/repositories.config b/csharp/src/packages/repositories.config deleted file mode 100644 index 70379412..00000000 --- a/csharp/src/packages/repositories.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/jenkins/docker/Dockerfile b/jenkins/docker/Dockerfile index 9c9ee56b..6a9e7e47 100644 --- a/jenkins/docker/Dockerfile +++ b/jenkins/docker/Dockerfile @@ -30,7 +30,7 @@ RUN echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu trusty main" | tee /etc # Install dotnet SDK based on https://www.microsoft.com/net/core#debian # (Ubuntu instructions need apt to support https) RUN apt-get update && apt-get install -y --force-yes curl libunwind8 gettext && \ - curl -sSL -o dotnet.tar.gz https://go.microsoft.com/fwlink/?LinkID=809130 && \ + curl -sSL -o dotnet.tar.gz https://go.microsoft.com/fwlink/?LinkID=847105 && \ mkdir -p /opt/dotnet && tar zxf dotnet.tar.gz -C /opt/dotnet && \ ln -s /opt/dotnet/dotnet /usr/local/bin diff --git a/tests.sh b/tests.sh index 96550cb9..710389bc 100755 --- a/tests.sh +++ b/tests.sh @@ -93,30 +93,17 @@ build_csharp() { internal_build_cpp NUGET=/usr/local/bin/nuget.exe - if [ "$TRAVIS" == "true" ]; then - # Install latest version of Mono - sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF - sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1397BC53640DB551 - echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list - sudo apt-get update -qq - sudo apt-get install -qq mono-devel referenceassemblies-pcl nunit - - # Then install the dotnet SDK as per Ubuntu 14.04 instructions on dot.net. - sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list' - sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893 - sudo apt-get update -qq - sudo apt-get install -qq dotnet-dev-1.0.0-preview2-003121 - fi - # Perform "dotnet new" once to get the setup preprocessing out of the # way. That spews a lot of output (including backspaces) into logs # otherwise, and can cause problems. It doesn't matter if this step # is performed multiple times; it's cheap after the first time anyway. + # (It also doesn't matter if it's unnecessary, which it will be on some + # systems. It's necessary on Jenkins in order to avoid unprintable + # characters appearing in the JUnit output.) mkdir dotnettmp (cd dotnettmp; dotnet new > /dev/null) rm -rf dotnettmp - (cd csharp/src; dotnet restore) csharp/buildall.sh cd conformance && make test_csharp && cd .. -- cgit v1.2.3 From 0b07d7eb9e15d897bfd3f3d569e0a66b2bb48d18 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 24 May 2017 06:41:03 +0100 Subject: Add IncludeSource in csproj as per review comments --- csharp/src/Google.Protobuf/Google.Protobuf.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index cf30e4a8..4eebd99e 100644 --- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj +++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj @@ -18,6 +18,7 @@ git https://github.com/nodatime/nodatime.git true + true