소스 검색

Add reflection of the json name to the property ordering

- Current approach of mapping property names is not fully
  compatible with JSON serializing. This causes many design
  issues especially with the field aliases. So the explicit JSON
  reflection is the only suitable solution for this.
- Update tests.
Alexey Edelev 3 년 전
부모
커밋
47b1807ae1

+ 1 - 1
CMakeLists.txt

@@ -126,7 +126,7 @@ endif()
 if(QT_PROTOBUF_MAKE_TESTS)
     find_package(WrapGTest)
     find_package(${QT_VERSIONED_PREFIX} OPTIONAL_COMPONENTS Test QuickTest CONFIG)
-    if(GTest_FOUND AND TARGET ${QT_VERSIONED_PREFIX}::Test)
+    if(WrapGTest_FOUND AND TARGET ${QT_VERSIONED_PREFIX}::Test)
         enable_testing()
         add_subdirectory("tests")
     else()

+ 2 - 1
src/generator/messagedefinitionprinter.cpp

@@ -99,7 +99,8 @@ void MessageDefinitionPrinter::printFieldsOrdering() {
         //property_number is incremented by 1 because user properties stating from 1.
         //Property with index 0 is "objectName"
         mPrinter->Print({{"field_number", std::to_string(field->number())},
-                         {"property_number", std::to_string(i + 1)}}, Templates::FieldOrderTemplate);
+                         {"property_number", std::to_string(i + 1)},
+                         {"json_name", field->json_name()}}, Templates::FieldOrderTemplate);
     }
     Outdent();
     mPrinter->Print(Templates::SemicolonBlockEnclosureTemplate);

+ 1 - 1
src/generator/templates.cpp

@@ -242,7 +242,7 @@ const char *Templates::SignalTemplate = "void $property_name$Changed();\n";
 
 const char *Templates::FieldsOrderingContainerTemplate = "const QtProtobuf::QProtobufMetaObject $type$::protobufMetaObject = QtProtobuf::QProtobufMetaObject($type$::staticMetaObject, $type$::propertyOrdering);\n"
                                                          "const QtProtobuf::QProtobufPropertyOrdering $type$::propertyOrdering = {";
-const char *Templates::FieldOrderTemplate = "{$field_number$, $property_number$}";
+const char *Templates::FieldOrderTemplate = "{$field_number$, {$property_number$, \"$json_name$\"}}";
 
 const char *Templates::EnumTemplate = "$type$";
 

+ 13 - 7
src/protobuf/qprotobufjsonserializer.cpp

@@ -174,7 +174,7 @@ public:
     }
 
     QByteArray serializeProperty(const QVariant &propertyValue, const QProtobufMetaProperty &metaProperty) {
-        return QByteArray("\"") + metaProperty.protoPropertyName().toUtf8() + "\":" + serializeValue(propertyValue, metaProperty);
+        return QByteArray("\"") + metaProperty.jsonPropertyName().toUtf8() + "\":" + serializeValue(propertyValue, metaProperty);
     }
 
     QByteArray serializeObject(const QObject *object, const QProtobufMetaObject &metaObject) {
@@ -186,7 +186,9 @@ public:
             QMetaProperty metaProperty = metaObject.staticMetaObject.property(propertyIndex);
             const char *propertyName = metaProperty.name();
             const QVariant &propertyValue = object->property(propertyName);
-            result.append(serializeProperty(propertyValue, QProtobufMetaProperty(metaProperty, fieldIndex)));
+            result.append(serializeProperty(propertyValue, QProtobufMetaProperty(metaProperty,
+                                                                                 fieldIndex,
+                                                                                 field.second)));
             result.append(",");
         }
         result.resize(result.size() - 1);//Remove trailing `,`
@@ -335,19 +337,23 @@ public:
 
         for (auto &property : obj) {
             auto name = property.first;
-            int propertyIndex = metaObject.staticMetaObject.indexOfProperty(name.data());
-            if (propertyIndex >= 0) {
-                QMetaProperty metaProperty = metaObject.staticMetaObject.property(propertyIndex);
+            auto it = std::find_if(metaObject.propertyOrdering.begin(),
+                                   metaObject.propertyOrdering.end(),
+                                   [&name](const auto &val)->bool {
+                return val.second == QString::fromStdString(name);
+            });
+            if (it != metaObject.propertyOrdering.end()) {
+                QMetaProperty metaProperty = metaObject.staticMetaObject.property(it->second);
                 auto userType = metaProperty.userType();
                 QByteArray rawValue = QByteArray::fromStdString(property.second.value);
                 if (rawValue == "null" && property.second.type == microjson::JsonObjectType) {
-                    object->setProperty(name.c_str(), QVariant());//Initialize with default value
+                    metaProperty.write(object, QVariant());
                     continue;
                 }
                 bool ok = false;
                 QVariant value = deserializeValue(userType, rawValue, property.second.type, ok);
                 if (ok) {
-                    object->setProperty(name.c_str(), value);
+                    metaProperty.write(object, value);
                 }
             }
         }

+ 10 - 32
src/protobuf/qprotobufmetaproperty.cpp

@@ -26,44 +26,22 @@
 #include "qprotobufmetaproperty.h"
 #include "qtprotobuftypes.h"
 
-#include <string>
-
-//TODO: Code under unnamed namespace should be moved to the common header that is relevant for generator and metaproperty
-namespace  {
-int constexpr constexpr_strlen(const char* str)
-{
-    return *str ? 1 + constexpr_strlen(str + 1) : 0;
-}
-const std::vector<std::string> ListOfQmlExeptions{"id", "property", "import"};
-constexpr const char *privateSuffix = "_p";
-constexpr const char *protoSuffix = "_proto";
-constexpr int privateSuffixLenght = constexpr_strlen(privateSuffix);
-constexpr int protoSuffixLenght = constexpr_strlen(protoSuffix);
-}
-
 using namespace QtProtobuf;
-QProtobufMetaProperty::QProtobufMetaProperty(const QMetaProperty &metaProperty, int fieldIndex) : QMetaProperty(metaProperty)
+QProtobufMetaProperty::QProtobufMetaProperty(const QMetaProperty &metaProperty,
+                                             int fieldIndex,
+                                             const QString &jsonName) : QMetaProperty(metaProperty)
   , m_fieldIndex(fieldIndex)
+  , m_jsonName(jsonName)
 {
 
 }
 
-QString QProtobufMetaProperty::protoPropertyName() const
+int QProtobufMetaProperty::protoFieldIndex() const
 {
-    QString protoName(name());
-    if ((userType() == qMetaTypeId<QtProtobuf::int32>()
-            || userType() == qMetaTypeId<QtProtobuf::fixed32>()
-            || userType() == qMetaTypeId<QtProtobuf::sfixed32>())
-            && protoName.endsWith(privateSuffix)) {
-        return protoName.mid(0, protoName.size() - privateSuffixLenght);
-    }
-
-    if (protoName.endsWith(protoSuffix)) {
-        auto tmpProtoName = protoName.mid(0, protoName.size() - protoSuffixLenght);
-        if (std::find(ListOfQmlExeptions.begin(), ListOfQmlExeptions.end(), protoName.toStdString()) != ListOfQmlExeptions.end()) {
-            return tmpProtoName;
-        }
-    }
+    return m_fieldIndex;
+}
 
-    return protoName;
+QString QProtobufMetaProperty::jsonPropertyName() const
+{
+    return m_jsonName;
 }

+ 7 - 4
src/protobuf/qprotobufmetaproperty.h

@@ -35,15 +35,18 @@ namespace QtProtobuf {
  * \private
  * \brief The QProtobufMetaProperty class
  */
+struct PropertyOrderingInfo;
+
 class Q_PROTOBUF_EXPORT QProtobufMetaProperty : public QMetaProperty
 {
 public:
-    QProtobufMetaProperty(const QMetaProperty &, int fieldIndex);
-    int protoFieldIndex() const { return m_fieldIndex; }
-    QString protoPropertyName() const;
+    QProtobufMetaProperty(const QMetaProperty &, int fieldIndex, const QString &jsonName);
+    int protoFieldIndex() const;
+    QString jsonPropertyName() const;
 private:
     QProtobufMetaProperty();
-    int m_fieldIndex;
+    const int m_fieldIndex;
+    const QString &m_jsonName;
 };
 
 }

+ 7 - 3
src/protobuf/qprotobufserializer.cpp

@@ -88,7 +88,9 @@ QByteArray QProtobufSerializer::serializeMessage(const QObject *object, const QP
         QMetaProperty metaProperty = metaObject.staticMetaObject.property(propertyIndex);
         const char *propertyName = metaProperty.name();
         QVariant propertyValue = object->property(propertyName);
-        result.append(dPtr->serializeProperty(propertyValue, QProtobufMetaProperty(metaProperty, fieldIndex)));
+        result.append(dPtr->serializeProperty(propertyValue, QProtobufMetaProperty(metaProperty,
+                                                                                   fieldIndex,
+                                                                                   field.second)));
     }
 
     return result;
@@ -128,7 +130,9 @@ bool QProtobufSerializer::deserializeListObject(QObject *object, const QProtobuf
 QByteArray QProtobufSerializer::serializeMapPair(const QVariant &key, const QVariant &value, const QProtobufMetaProperty &metaProperty) const
 {
     QByteArray result = QProtobufSerializerPrivate::encodeHeader(metaProperty.protoFieldIndex(), LengthDelimited);
-    result.append(QProtobufSerializerPrivate::prependLengthDelimitedSize(dPtr->serializeProperty(key, QProtobufMetaProperty(metaProperty, 1)) + dPtr->serializeProperty(value, QProtobufMetaProperty(metaProperty, 2))));
+    result.append(QProtobufSerializerPrivate::prependLengthDelimitedSize(
+                      dPtr->serializeProperty(key, QProtobufMetaProperty(metaProperty, 1, QString())) +
+                      dPtr->serializeProperty(value, QProtobufMetaProperty(metaProperty, 2, QString()))));
     return result;
 }
 
@@ -273,7 +277,7 @@ QByteArray QProtobufSerializerPrivate::serializeProperty(const QVariant &propert
         }
     } else {
         auto handler = QtProtobufPrivate::findHandler(userType);
-        handler.serializer(q_ptr, propertyValue, QProtobufMetaProperty(metaProperty, metaProperty.protoFieldIndex()), result);
+        handler.serializer(q_ptr, propertyValue, metaProperty, result);
     }
     return result;
 }

+ 21 - 1
src/protobuf/qtprotobuftypes.h

@@ -33,6 +33,7 @@
 #include <unordered_map>
 #include <functional>
 #include <list>
+#include <type_traits>
 
 namespace QtProtobuf {
 
@@ -54,7 +55,26 @@ enum WireTypes {
 };
 
 //! \private
-using QProtobufPropertyOrdering = std::unordered_map<int, int>;
+struct PropertyOrderingInfo {
+    PropertyOrderingInfo(int _qtProperty, const QString &_jsonName) : qtProperty(_qtProperty)
+      , jsonName(_jsonName) {}
+
+    int qtProperty;
+    QString jsonName;
+    template<typename T,
+             typename std::enable_if_t<std::is_integral<T>::value, int> = 0>
+    operator T() const { return qtProperty; }
+    operator QString() const { return jsonName; }
+
+    template<typename T,
+             typename std::enable_if_t<std::is_integral<T>::value, int> = 0>
+    bool operator==(const T _qtProperty) const { return _qtProperty == qtProperty; }
+    bool operator==(const QString &_jsonName) const { return _jsonName == jsonName; }
+};
+
+//! \private
+//!
+using QProtobufPropertyOrdering = std::unordered_map<int, PropertyOrderingInfo>;
 
 /*!
  * \private

+ 21 - 21
tests/test_protobuf/simpletest.cpp.inc

@@ -267,7 +267,7 @@ TEST_F(SimpleTest, SimpleLocalEnumListTest)
 {
     ASSERT_GT(SimpleEnumListMessage::staticMetaObject.enumeratorCount(), 0);
 
-    const char *propertyName = "localEnumList";
+    const char *propertyName = "localEnumListData";
     assertMessagePropertyRegistered<SimpleEnumListMessage, SimpleEnumListMessage::LocalEnumRepeated>(1,  "qtprotobufnamespace::tests::SimpleEnumListMessage::LocalEnumRepeated", propertyName);
 
     SimpleEnumListMessage::LocalEnumRepeated value({SimpleEnumListMessage::LOCAL_ENUM_VALUE2,
@@ -338,7 +338,7 @@ TEST_F(SimpleTest, SimpleEnumsTest)
 
 TEST_F(SimpleTest, SimpleFileEnumsTest)
 {
-    const char *propertyName = "globalEnumList";
+    const char *propertyName = "globalEnumListData";
     assertMessagePropertyRegistered<SimpleFileEnumMessage, TestEnumGadget::TestEnumRepeated>(2, "qtprotobufnamespace::tests::TestEnumGadget::TestEnumRepeated", propertyName);
 
     TestEnumGadget::TestEnumRepeated value{TestEnumGadget::TEST_ENUM_VALUE1,
@@ -378,7 +378,7 @@ TEST_F(SimpleTest, SimpleBytesMessageTest)
 
 TEST_F(SimpleTest, SimpleExternalComplexMessageTest)
 {
-    const char *propertyName = "localList";
+    const char *propertyName = "localListData";
     assertMessagePropertyRegistered<qtprotobufnamespace1::externaltests::SimpleExternalMessage, int32List>(
                 1, "QtProtobuf::int32List", propertyName);
 
@@ -390,7 +390,7 @@ TEST_F(SimpleTest, SimpleExternalComplexMessageTest)
 
 TEST_F(SimpleTest, RepeatedExternalComplexMessageTest)
 {
-    const char *propertyName = "testExternalComplex";
+    const char *propertyName = "testExternalComplexData";
     assertMessagePropertyRegistered<RepeatedExternalComplexMessage, qtprotobufnamespace1::externaltests::ExternalComplexMessageRepeated>(
                 1, "qtprotobufnamespace1::externaltests::ExternalComplexMessageRepeated", propertyName);
 
@@ -411,7 +411,7 @@ TEST_F(SimpleTest, RepeatedExternalComplexMessageTest)
 
 TEST_F(SimpleTest, RepeatedStringMessageTest)
 {
-    const char *propertyName = "testRepeatedString";
+    const char *propertyName = "testRepeatedStringData";
     assertMessagePropertyRegistered<RepeatedStringMessage, QStringList>(1, "QStringList", propertyName);
 
     RepeatedStringMessage test;
@@ -422,7 +422,7 @@ TEST_F(SimpleTest, RepeatedStringMessageTest)
 
 TEST_F(SimpleTest, RepeatedIntMessageTest)
 {
-    const char *propertyName = "testRepeatedInt";
+    const char *propertyName = "testRepeatedIntData";
     assertMessagePropertyRegistered<RepeatedIntMessage, int32List>(1, "QtProtobuf::int32List", propertyName);
 
     RepeatedIntMessage test;
@@ -439,7 +439,7 @@ TEST_F(SimpleTest, RepeatedIntMessageTest)
 
 TEST_F(SimpleTest, RepeatedDoubleMessageTest)
 {
-    const char *propertyName = "testRepeatedDouble";
+    const char *propertyName = "testRepeatedDoubleData";
     assertMessagePropertyRegistered<RepeatedDoubleMessage, DoubleList>(1, "QtProtobuf::DoubleList", propertyName);
 
     RepeatedDoubleMessage test;
@@ -456,7 +456,7 @@ TEST_F(SimpleTest, RepeatedDoubleMessageTest)
 
 TEST_F(SimpleTest, RepeatedFloatMessageTest)
 {
-    const char *propertyName = "testRepeatedFloat";
+    const char *propertyName = "testRepeatedFloatData";
     assertMessagePropertyRegistered<RepeatedFloatMessage, FloatList>(1, "QtProtobuf::FloatList", propertyName);
 
     RepeatedFloatMessage test;
@@ -473,7 +473,7 @@ TEST_F(SimpleTest, RepeatedFloatMessageTest)
 
 TEST_F(SimpleTest, RepeatedBytesMessageTest)
 {
-    const char *propertyName = "testRepeatedBytes";
+    const char *propertyName = "testRepeatedBytesData";
     assertMessagePropertyRegistered<RepeatedBytesMessage, QByteArrayList>(1, "QByteArrayList", propertyName);
 
     QByteArrayList bList;
@@ -496,7 +496,7 @@ TEST_F(SimpleTest, RepeatedBytesMessageTest)
 
 TEST_F(SimpleTest, RepeatedSIntMessageTest)
 {
-    const char *propertyName = "testRepeatedInt";
+    const char *propertyName = "testRepeatedIntData";
     assertMessagePropertyRegistered<RepeatedSIntMessage, sint32List>(1, "QtProtobuf::sint32List", propertyName);
 
     RepeatedSIntMessage test;
@@ -513,7 +513,7 @@ TEST_F(SimpleTest, RepeatedSIntMessageTest)
 
 TEST_F(SimpleTest, RepeatedUIntMessageTest)
 {
-    const char *propertyName = "testRepeatedInt";
+    const char *propertyName = "testRepeatedIntData";
     assertMessagePropertyRegistered<RepeatedUIntMessage, uint32List>(1, "QtProtobuf::uint32List", propertyName);
 
     RepeatedUIntMessage test;
@@ -530,7 +530,7 @@ TEST_F(SimpleTest, RepeatedUIntMessageTest)
 
 TEST_F(SimpleTest, RepeatedInt64MessageTest)
 {
-    const char *propertyName = "testRepeatedInt";
+    const char *propertyName = "testRepeatedIntData";
     assertMessagePropertyRegistered<RepeatedInt64Message, int64List>(1, "QtProtobuf::int64List", propertyName);
 
     RepeatedInt64Message test;
@@ -547,7 +547,7 @@ TEST_F(SimpleTest, RepeatedInt64MessageTest)
 
 TEST_F(SimpleTest, RepeatedSInt64MessageTest)
 {
-    const char *propertyName = "testRepeatedInt";
+    const char *propertyName = "testRepeatedIntData";
     assertMessagePropertyRegistered<RepeatedSInt64Message, sint64List>(1, "QtProtobuf::sint64List", propertyName);
 
     RepeatedSInt64Message test;
@@ -564,7 +564,7 @@ TEST_F(SimpleTest, RepeatedSInt64MessageTest)
 
 TEST_F(SimpleTest, RepeatedUInt64MessageTest)
 {
-    const char *propertyName = "testRepeatedInt";
+    const char *propertyName = "testRepeatedIntData";
     assertMessagePropertyRegistered<RepeatedUInt64Message, uint64List>(1, "QtProtobuf::uint64List", propertyName);
 
     RepeatedUInt64Message test;
@@ -581,7 +581,7 @@ TEST_F(SimpleTest, RepeatedUInt64MessageTest)
 
 TEST_F(SimpleTest, RepeatedFixedIntMessageTest)
 {
-    const char *propertyName = "testRepeatedInt";
+    const char *propertyName = "testRepeatedIntData";
     assertMessagePropertyRegistered<RepeatedFixedIntMessage, fixed32List>(1, "QtProtobuf::fixed32List", propertyName);
 
     RepeatedFixedIntMessage test;
@@ -598,7 +598,7 @@ TEST_F(SimpleTest, RepeatedFixedIntMessageTest)
 
 TEST_F(SimpleTest, RepeatedFixedInt64MessageTest)
 {
-    const char *propertyName = "testRepeatedInt";
+    const char *propertyName = "testRepeatedIntData";
     assertMessagePropertyRegistered<RepeatedFixedInt64Message, fixed64List>(1, "QtProtobuf::fixed64List", propertyName);
 
     RepeatedFixedInt64Message test;
@@ -615,7 +615,7 @@ TEST_F(SimpleTest, RepeatedFixedInt64MessageTest)
 
 TEST_F(SimpleTest, RepeatedSFixedIntMessageTest)
 {
-    const char *propertyName = "testRepeatedInt";
+    const char *propertyName = "testRepeatedIntData";
     assertMessagePropertyRegistered<RepeatedSFixedIntMessage, sfixed32List>(1, "QtProtobuf::sfixed32List", propertyName);
 
     RepeatedSFixedIntMessage test;
@@ -632,7 +632,7 @@ TEST_F(SimpleTest, RepeatedSFixedIntMessageTest)
 
 TEST_F(SimpleTest, RepeatedSFixedInt64MessageTest)
 {
-    const char *propertyName = "testRepeatedInt";
+    const char *propertyName = "testRepeatedIntData";
     assertMessagePropertyRegistered<RepeatedSFixedInt64Message, QtProtobuf::sfixed64List>(1, "QtProtobuf::sfixed64List", propertyName);
 
     RepeatedSFixedInt64Message test;
@@ -660,7 +660,7 @@ TEST_F(SimpleTest, StepChildEnumMessageTest)
 
 TEST_F(SimpleTest, StepChildEnumListMessageTest)
 {
-    const char *propertyName = "localStepChildList";
+    const char *propertyName = "localStepChildListData";
     assertMessagePropertyRegistered<StepChildEnumMessage, SimpleEnumMessage::LocalEnumRepeated>(2, "qtprotobufnamespace::tests::SimpleEnumMessage::LocalEnumRepeated", propertyName);
 
     SimpleEnumMessage::LocalEnumRepeated value({SimpleEnumMessage::LOCAL_ENUM_VALUE2,
@@ -765,7 +765,7 @@ TEST_F(SimpleTest, MoveOperatorTest)
 
 TEST_F(SimpleTest, MoveOperatorRepeatedTest)
 {
-    const char *propertyName = "testRepeatedInt";
+    const char *propertyName = "testRepeatedIntData";
     RepeatedIntMessage test;
     RepeatedIntMessage test2{{55,44,11,33}};
 
@@ -876,7 +876,7 @@ TEST_F(SimpleTest, LowerCaseEnumTest)
 
 TEST_F(SimpleTest, MapRepeatedFieldSequenceTest)
 {
-    assertMessagePropertyRegistered<sequence::RepeatedFieldSequence, sequence::RepeatedFieldSequence2Repeated>(1, "qtprotobufnamespace::tests::sequence::RepeatedFieldSequence2Repeated", "testField");
+    assertMessagePropertyRegistered<sequence::RepeatedFieldSequence, sequence::RepeatedFieldSequence2Repeated>(1, "qtprotobufnamespace::tests::sequence::RepeatedFieldSequence2Repeated", "testFieldData");
     assertMessagePropertyRegistered<sequence::MapFieldSequence, sequence::MapFieldSequence::TestFieldEntry>(1, "qtprotobufnamespace::tests::sequence::MapFieldSequence::TestFieldEntry", "testField");
 }
 

+ 13 - 13
tests/test_wellknowntypes/simpletest.cpp

@@ -78,11 +78,11 @@ TEST_F(WellknowntypesTest, ApiTest)
     ASSERT_GT(qMetaTypeId<Api>(), 0);
 
     assertMessagePropertyRegistered<Api, QString>(1, "QString", "name");
-    assertMessagePropertyRegistered<Api, MethodRepeated>(2, "google::protobuf::MethodRepeated", "methods");
-    assertMessagePropertyRegistered<Api, OptionRepeated>(3, "google::protobuf::OptionRepeated", "options");
+    assertMessagePropertyRegistered<Api, MethodRepeated>(2, "google::protobuf::MethodRepeated", "methodsData");
+    assertMessagePropertyRegistered<Api, OptionRepeated>(3, "google::protobuf::OptionRepeated", "optionsData");
     assertMessagePropertyRegistered<Api, QString>(4, "QString", "version");
     assertMessagePropertyRegistered<Api, SourceContext>(5, "google::protobuf::SourceContext*", "sourceContext", true);
-    assertMessagePropertyRegistered<Api, MixinRepeated>(6, "google::protobuf::MixinRepeated", "mixins");
+    assertMessagePropertyRegistered<Api, MixinRepeated>(6, "google::protobuf::MixinRepeated", "mixinsData");
     assertMessagePropertyRegistered<Api, SyntaxGadget::Syntax>(7, "google::protobuf::SyntaxGadget::Syntax", "syntax");
 }
 
@@ -94,7 +94,7 @@ TEST_F(WellknowntypesTest, MethodTest)
     assertMessagePropertyRegistered<Method, bool>(3, "bool", "requestStreaming");
     assertMessagePropertyRegistered<Method, QString>(4, "QString", "responseTypeUrl");
     assertMessagePropertyRegistered<Method, bool>(5, "bool", "responseStreaming");
-    assertMessagePropertyRegistered<Method, OptionRepeated>(6, "google::protobuf::OptionRepeated", "options");
+    assertMessagePropertyRegistered<Method, OptionRepeated>(6, "google::protobuf::OptionRepeated", "optionsData");
     assertMessagePropertyRegistered<Method, SyntaxGadget::Syntax>(7, "google::protobuf::SyntaxGadget::Syntax", "syntax");
 }
 
@@ -120,7 +120,7 @@ TEST_F(WellknowntypesTest, EmptyTest)
 TEST_F(WellknowntypesTest, FieldMaskTest)
 {
     ASSERT_GT(qMetaTypeId<FieldMask>(), 0);
-    assertMessagePropertyRegistered<FieldMask, QStringList>(1, "QStringList", "paths");
+    assertMessagePropertyRegistered<FieldMask, QStringList>(1, "QStringList", "pathsData");
 }
 
 TEST_F(WellknowntypesTest, SourceContextTest)
@@ -149,7 +149,7 @@ TEST_F(WellknowntypesTest, ValueTest)
 TEST_F(WellknowntypesTest, ListValueTest)
 {
     ASSERT_GT(qMetaTypeId<ListValue>(), 0);
-    assertMessagePropertyRegistered<ListValue, ValueRepeated>(1, "google::protobuf::ValueRepeated", "values");
+    assertMessagePropertyRegistered<ListValue, ValueRepeated>(1, "google::protobuf::ValueRepeated", "valuesData");
 }
 
 TEST_F(WellknowntypesTest, TimestampTest)
@@ -165,9 +165,9 @@ TEST_F(WellknowntypesTest, TypeTest)
     Q_PROPERTY(QStringList oneofs READ oneofs WRITE setOneofs NOTIFY oneofsChanged)
 
     assertMessagePropertyRegistered<Type, QString>(1, "QString", "name");
-    assertMessagePropertyRegistered<Type, FieldRepeated>(2, "google::protobuf::FieldRepeated", "fields");
-    assertMessagePropertyRegistered<Type, QStringList>(3, "QStringList", "oneofs");
-    assertMessagePropertyRegistered<Type, OptionRepeated>(4, "google::protobuf::OptionRepeated", "options");
+    assertMessagePropertyRegistered<Type, FieldRepeated>(2, "google::protobuf::FieldRepeated", "fieldsData");
+    assertMessagePropertyRegistered<Type, QStringList>(3, "QStringList", "oneofsData");
+    assertMessagePropertyRegistered<Type, OptionRepeated>(4, "google::protobuf::OptionRepeated", "optionsData");
     assertMessagePropertyRegistered<Type, SourceContext *>(5, "google::protobuf::SourceContext*", "sourceContext", true);
     assertMessagePropertyRegistered<Type, SyntaxGadget::Syntax>(6, "google::protobuf::SyntaxGadget::Syntax", "syntax");
 }
@@ -183,7 +183,7 @@ TEST_F(WellknowntypesTest, FieldTest)
     assertMessagePropertyRegistered<Field, QString>(6, "QString", "typeUrl");
     assertMessagePropertyRegistered<Field, QtProtobuf::int32>(7, "QtProtobuf::int32", "oneofIndex_p");
     assertMessagePropertyRegistered<Field, bool>(8, "bool", "packed");
-    assertMessagePropertyRegistered<Field, OptionRepeated>(9, "google::protobuf::OptionRepeated", "options");
+    assertMessagePropertyRegistered<Field, OptionRepeated>(9, "google::protobuf::OptionRepeated", "optionsData");
     assertMessagePropertyRegistered<Field, QString>(10, "QString", "jsonName");
     assertMessagePropertyRegistered<Field, QString>(11, "QString", "defaultValue");
 }
@@ -192,8 +192,8 @@ TEST_F(WellknowntypesTest, EnumTest)
 {
     ASSERT_GT(qMetaTypeId<Enum>(), 0);
     assertMessagePropertyRegistered<Enum, QString>(1, "QString", "name");
-    assertMessagePropertyRegistered<Enum, EnumValueRepeated>(2, "google::protobuf::EnumValueRepeated", "enumvalue");
-    assertMessagePropertyRegistered<Enum, OptionRepeated>(3, "google::protobuf::OptionRepeated", "options");
+    assertMessagePropertyRegistered<Enum, EnumValueRepeated>(2, "google::protobuf::EnumValueRepeated", "enumvalueData");
+    assertMessagePropertyRegistered<Enum, OptionRepeated>(3, "google::protobuf::OptionRepeated", "optionsData");
     assertMessagePropertyRegistered<Enum, SourceContext *>(4, "google::protobuf::SourceContext*", "sourceContext", true);
     assertMessagePropertyRegistered<Enum, SyntaxGadget::Syntax>(5, "google::protobuf::SyntaxGadget::Syntax", "syntax");
 }
@@ -203,7 +203,7 @@ TEST_F(WellknowntypesTest, EnumValueTest)
     ASSERT_GT(qMetaTypeId<EnumValue>(), 0);
     assertMessagePropertyRegistered<EnumValue, QString>(1, "QString", "name");
     assertMessagePropertyRegistered<EnumValue, QtProtobuf::int32>(2, "QtProtobuf::int32", "number_p");
-    assertMessagePropertyRegistered<EnumValue, OptionRepeated>(3, "google::protobuf::OptionRepeated", "options");
+    assertMessagePropertyRegistered<EnumValue, OptionRepeated>(3, "google::protobuf::OptionRepeated", "optionsData");
 }
 
 TEST_F(WellknowntypesTest, OptionTest)

+ 1 - 1
tests/testscommon.h

@@ -37,7 +37,7 @@ static void assertMessagePropertyRegistered(int fieldIndex, const char *property
 {
     // TODO: there should be(?) a mapping avaialble: PropertyType -> propertyTypeName
 
-    const int propertyNumber = MessageType::propertyOrdering.at(fieldIndex);
+    const int propertyNumber = MessageType::propertyOrdering.at(fieldIndex).qtProperty;
     ASSERT_STREQ(MessageType::staticMetaObject.property(propertyNumber).typeName(), propertyTypeName);
     if (!skipMetatypeCheck) {
         ASSERT_EQ(MessageType::staticMetaObject.property(propertyNumber).userType(), qMetaTypeId<PropertyType>());