diff --git a/natvis/cppwinrtvisualizer.vcxproj b/natvis/cppwinrtvisualizer.vcxproj index cc7080289..6fb317345 100644 --- a/natvis/cppwinrtvisualizer.vcxproj +++ b/natvis/cppwinrtvisualizer.vcxproj @@ -205,10 +205,10 @@ - - + + @@ -238,9 +238,7 @@ Designer - - - + Designer diff --git a/natvis/object_visualizer.cpp b/natvis/object_visualizer.cpp index 31cd5d0f3..b26e91080 100644 --- a/natvis/object_visualizer.cpp +++ b/natvis/object_visualizer.cpp @@ -347,6 +347,7 @@ struct property_type }; void GetInterfaceData( + Microsoft::VisualStudio::Debugger::DkmProcess* process, coded_index index, _Inout_ std::vector& propertyData, _Out_ bool& isStringable @@ -370,7 +371,7 @@ void GetInterfaceData( continue; } - PropertyCategory propCategory; + std::optional propCategory; std::wstring propAbiType; std::wstring propDisplayType; @@ -378,12 +379,17 @@ void GetInterfaceData( std::visit(overloaded{ [&](ElementType type) { - if ((type < ElementType::Boolean) || (type > ElementType::String)) + if ((ElementType::Boolean <= type) && (type <= ElementType::String)) { - return; + propCategory = (PropertyCategory)(static_cast::type>(type) - + static_cast::type>(ElementType::Boolean)); + } + else if (type == ElementType::Object) + { + //propDisplayType = L"winrt::Windows::Foundation::IInspectable"; + //propCategory = PropertyCategory::Class; + //propAbiType = L"winrt::impl::inspectable_abi*"; } - propCategory = (PropertyCategory)(static_cast::type>(type) - - static_cast::type>(ElementType::Boolean)); }, [&](coded_index const& index) { @@ -443,21 +449,24 @@ void GetInterfaceData( }, [&](GenericTypeIndex /*var*/) { - throw_invalid("Generics are not yet supported"); + NatvisDiagnostic(process, L"Generics not yet supported", NatvisDiagnosticLevel::Warning); }, [&](GenericMethodTypeIndex /*var*/) { - throw_invalid("Generic methods not supported."); + NatvisDiagnostic(process, L"Generics not yet supported", NatvisDiagnosticLevel::Warning); }, [&](GenericTypeInstSig const& /*type*/) { - throw_invalid("Generics are not yet supported"); + NatvisDiagnostic(process, L"Generics not yet supported", NatvisDiagnosticLevel::Warning); } }, retType.Type().Type()); - auto propName = method.Name().substr(4); - std::wstring propDisplayName(propName.cbegin(), propName.cend()); - propertyData.push_back({ propIid, propIndex, propCategory, propAbiType, propDisplayType, propDisplayName }); + if (propCategory) + { + auto propName = method.Name().substr(4); + std::wstring propDisplayName(propName.cbegin(), propName.cend()); + propertyData.push_back({ propIid, propIndex, *propCategory, propAbiType, propDisplayType, propDisplayName }); + } } } @@ -498,7 +507,7 @@ void object_visualizer::GetTypeProperties(Microsoft::VisualStudio::Debugger::Dkm auto impls = type.InterfaceImpl(); for (auto&& impl : impls) { - GetInterfaceData(impl.Interface(), m_propertyData, m_isStringable); + GetInterfaceData(process, impl.Interface(), m_propertyData, m_isStringable); } } else if (get_category(type) == category::interface_type) @@ -506,9 +515,9 @@ void object_visualizer::GetTypeProperties(Microsoft::VisualStudio::Debugger::Dkm auto impls = type.InterfaceImpl(); for (auto&& impl : impls) { - GetInterfaceData(impl.Interface(), m_propertyData, m_isStringable); + GetInterfaceData(process, impl.Interface(), m_propertyData, m_isStringable); } - GetInterfaceData(type.coded_index(), m_propertyData, m_isStringable); + GetInterfaceData(process, type.coded_index(), m_propertyData, m_isStringable); } } @@ -574,22 +583,25 @@ HRESULT object_visualizer::GetChildren( ) { // Ignore metadata errors to ensure that Raw Data is always available - try + if (m_propertyData.empty()) { - GetPropertyData(); - } - catch (std::invalid_argument const& e) - { - std::string_view message(e.what()); - NatvisDiagnostic(m_pVisualizedExpression.get(), - std::wstring(L"Exception in object_visualizer::GetPropertyData: ") + + try + { + GetPropertyData(); + } + catch (std::invalid_argument const& e) + { + std::string_view message(e.what()); + NatvisDiagnostic(m_pVisualizedExpression.get(), + std::wstring(L"Exception in object_visualizer::GetPropertyData: ") + std::wstring(message.begin(), message.end()), - NatvisDiagnosticLevel::Error, to_hresult()); - } - catch (...) - { - NatvisDiagnostic(m_pVisualizedExpression.get(), - L"Exception in object_visualizer::GetPropertyData", NatvisDiagnosticLevel::Error, to_hresult()); + NatvisDiagnosticLevel::Error, to_hresult()); + } + catch (...) + { + NatvisDiagnostic(m_pVisualizedExpression.get(), + L"Exception in object_visualizer::GetPropertyData", NatvisDiagnosticLevel::Error, to_hresult()); + } } com_ptr pEnumContext;