Walk through current class fields before walking the base class
authorIgor Kulaychuk <i.kulaychuk@samsung.com>
Fri, 21 Jul 2017 02:02:48 +0000 (05:02 +0300)
committerIgor Kulaychuk <i.kulaychuk@samsung.com>
Mon, 13 Nov 2017 19:22:40 +0000 (22:22 +0300)
src/debug/netcoredbg/valuewalk.cpp
src/debug/netcoredbg/varobj.cpp

index 0d66f2f..58fbb91 100644 (file)
@@ -200,19 +200,6 @@ static HRESULT WalkMembers(ICorDebugValue *pInputValue, ICorDebugILFrame *pILFra
     IfFailRet(pModule->GetMetaDataInterface(IID_IMetaDataImport, &pMDUnknown));
     IfFailRet(pMDUnknown->QueryInterface(IID_IMetaDataImport, (LPVOID*) &pMD));
 
-    std::string baseTypeName;
-    ToRelease<ICorDebugType> pBaseType;
-    if(SUCCEEDED(pType->GetBase(&pBaseType)) && pBaseType != NULL && SUCCEEDED(TypePrinter::GetTypeOfValue(pBaseType, baseTypeName)))
-    {
-        if(baseTypeName == "System.Enum")
-            return S_OK;
-        else if(baseTypeName != "System.Object"  && baseTypeName != "System.ValueType")
-        {
-            // Add fields of base class
-            IfFailRet(WalkMembers(pInputValue, pILFrame, pBaseType, cb));
-        }
-    }
-
     std::string className;
     TypePrinter::GetTypeOfValue(pType, className);
     if (className == "decimal") // TODO: implement mechanism for walking over custom type fields
@@ -323,6 +310,19 @@ static HRESULT WalkMembers(ICorDebugValue *pInputValue, ICorDebugILFrame *pILFra
     }
     pMD->CloseEnum(propEnum);
 
+    std::string baseTypeName;
+    ToRelease<ICorDebugType> pBaseType;
+    if(SUCCEEDED(pType->GetBase(&pBaseType)) && pBaseType != NULL && SUCCEEDED(TypePrinter::GetTypeOfValue(pBaseType, baseTypeName)))
+    {
+        if(baseTypeName == "System.Enum")
+            return S_OK;
+        else if(baseTypeName != "System.Object"  && baseTypeName != "System.ValueType")
+        {
+            // Add fields of base class
+            IfFailRet(WalkMembers(pInputValue, pILFrame, pBaseType, cb));
+        }
+    }
+
     return S_OK;
 }
 
index 9b6cf6c..8f9c972 100644 (file)
@@ -263,12 +263,12 @@ static HRESULT FetchFieldsAndProperties(ICorDebugValue *pInputValue,
 static void FixupInheritedFieldNames(std::vector<VarObjValue> &members)
 {
     std::unordered_set<std::string> names;
-    for (auto it = members.rbegin(); it != members.rend(); ++it)
+    for (auto &it : members)
     {
-        auto r = names.insert(it->name);
+        auto r = names.insert(it.name);
         if (!r.second)
         {
-            it->name += " (" + it->owningType + ")";
+            it.name += " (" + it.owningType + ")";
         }
     }
 }