From d4b92e015daa77c0ab9c014eca2594029737f1a9 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 26 Sep 2021 15:39:14 -0700 Subject: [PATCH 1/2] [UWP] Fix risky cast in `GenerateElementProjection()` Fixes #6394 --- .../uwp/AdaptiveCardsObjectModel/lib/ObjectModelUtil.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/uwp/AdaptiveCardsObjectModel/lib/ObjectModelUtil.cpp b/source/uwp/AdaptiveCardsObjectModel/lib/ObjectModelUtil.cpp index 62f58b15b7..7e95e8ee94 100644 --- a/source/uwp/AdaptiveCardsObjectModel/lib/ObjectModelUtil.cpp +++ b/source/uwp/AdaptiveCardsObjectModel/lib/ObjectModelUtil.cpp @@ -307,13 +307,17 @@ winrt::AdaptiveCards::ObjectModel::Uwp::IAdaptiveCardElement GenerateElementProj case CardElementType::Table: return winrt::make( std::AdaptivePointerCast(baseElement)); - break; case CardElementType::Custom: return std::AdaptivePointerCast<::AdaptiveCards::ObjectModel::Uwp::CustomElementWrapper>(baseElement)->GetWrappedElement(); case CardElementType::Unknown: - default: return winrt::make( std::AdaptivePointerCast(baseElement)); + default: + // It should not be possible for an element represented by a CardElementType to not have a matching case here. + // Either a new element has been introduced in the shared model without full support here in UWP, or there's a + // bug in the shared model (see https://github.com/microsoft/AdaptiveCards/issues/6393). + + throw winrt::hresult_error(); } } From cfbe6dc82acf202d87f03d828de14d9faa53391d Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 28 Sep 2021 12:19:27 -0700 Subject: [PATCH 2/2] Fix PR feedback --- source/uwp/AdaptiveCardsObjectModel/lib/ObjectModelUtil.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/uwp/AdaptiveCardsObjectModel/lib/ObjectModelUtil.cpp b/source/uwp/AdaptiveCardsObjectModel/lib/ObjectModelUtil.cpp index 7e95e8ee94..55215e9b72 100644 --- a/source/uwp/AdaptiveCardsObjectModel/lib/ObjectModelUtil.cpp +++ b/source/uwp/AdaptiveCardsObjectModel/lib/ObjectModelUtil.cpp @@ -317,7 +317,7 @@ winrt::AdaptiveCards::ObjectModel::Uwp::IAdaptiveCardElement GenerateElementProj // Either a new element has been introduced in the shared model without full support here in UWP, or there's a // bug in the shared model (see https://github.com/microsoft/AdaptiveCards/issues/6393). - throw winrt::hresult_error(); + throw winrt::hresult_error(E_UNEXPECTED, L"CardElementType not supported"); } }