Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UWP] /w4 /wx, control guard and attendant fixes #3120

Merged
merged 4 commits into from
Jul 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions source/uwp/ObjectModelProjection/ObjectModelProjection.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -207,22 +207,11 @@
<CompileAsWinRT>false</CompileAsWinRT>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>..\shared\cpp\ObjectModel;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">stdcpp17</LanguageStandard>
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">stdcpp17</LanguageStandard>
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">stdcpp17</LanguageStandard>
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">stdcpp17</LanguageStandard>
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">stdcpp17</LanguageStandard>
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">stdcpp17</LanguageStandard>
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">stdcpp17</LanguageStandard>
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Release|x64'">stdcpp17</LanguageStandard>
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">/bigobj %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">/bigobj %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">/bigobj %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">/bigobj %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">/bigobj %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">/bigobj %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">/bigobj %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">/bigobj %(AdditionalOptions)</AdditionalOptions>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<DisableSpecificWarnings>4702</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand All @@ -233,4 +222,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
17 changes: 6 additions & 11 deletions source/uwp/Renderer/AdaptiveCardRenderer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,17 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions Condition="'$(Configuration)'=='Debug'">_WINRT_DLL;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)'=='Release'">_WINRT_DLL;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_WINRT_DLL;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
..\..;
..\..\shared\cpp\ObjectModel;
..\..\shared\cpp\ObjectModel\json;
%(AdditionalIncludeDirectories)
</AdditionalIncludeDirectories>
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">stdcpp17</LanguageStandard>
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">stdcpp17</LanguageStandard>
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">stdcpp17</LanguageStandard>
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">stdcpp17</LanguageStandard>
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">stdcpp17</LanguageStandard>
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">stdcpp17</LanguageStandard>
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">stdcpp17</LanguageStandard>
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Release|x64'">stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp17</LanguageStandard>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down Expand Up @@ -372,4 +367,4 @@
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
</Project>
</Project>
6 changes: 3 additions & 3 deletions source/uwp/Renderer/lib/AdaptiveInputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ namespace AdaptiveNamespace
return outStream.str();
}

HRESULT AdaptiveInputs::AsValueSet(_COM_Outptr_ IPropertySet** value)
HRESULT AdaptiveInputs::AsValueSet(_COM_Outptr_ IPropertySet** valueSetOut)
{
*value = nullptr;
*valueSetOut = nullptr;
ComPtr<IPropertySet> valueSet;
RETURN_IF_FAILED(ActivateInstance(HStringReference(RuntimeClass_Windows_Foundation_Collections_ValueSet).Get(), &valueSet));
ComPtr<IMap<HSTRING, IInspectable*>> propertySetMap;
Expand Down Expand Up @@ -94,6 +94,6 @@ namespace AdaptiveNamespace
boolean replaced;
RETURN_IF_FAILED(propertySetMap->Insert(key.Get(), propVal.Get(), &replaced));
}
return valueSet.CopyTo(value);
return valueSet.CopyTo(valueSetOut);
}
}
10 changes: 5 additions & 5 deletions source/uwp/Renderer/lib/ErrorHandling.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
#define RETURN_IF_FAILED(statement) \
do \
{ \
HRESULT hr = statement; \
if (FAILED(hr)) \
HRESULT __hr = statement; \
if (FAILED(__hr)) \
{ \
return hr; \
return __hr; \
} \
} while (0, 0)
#define THROW_IF_FAILED(hr) \
#define THROW_IF_FAILED(__hr) \
do \
{ \
if (FAILED(hr)) \
if (FAILED(__hr)) \
{ \
throw new std::exception(); \
} \
Expand Down
6 changes: 3 additions & 3 deletions source/uwp/Renderer/lib/MediaHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,13 @@ void GetMediaSource(_In_ IAdaptiveHostConfig* hostConfig,
ComPtr<IAdaptiveMediaSource> currentSource;
THROW_IF_FAILED(sourceIterator->get_Current(&currentSource));

HString mimeType;
THROW_IF_FAILED(currentSource->get_MimeType(mimeType.GetAddressOf()));
HString currentMimeType;
THROW_IF_FAILED(currentSource->get_MimeType(currentMimeType.GetAddressOf()));

INT32 isSupported;
for (UINT i = 0; i < ARRAYSIZE(supportedMimeTypes); i++)
{
THROW_IF_FAILED(WindowsCompareStringOrdinal(mimeType.Get(), HStringReference(supportedMimeTypes[i]).Get(), &isSupported));
THROW_IF_FAILED(WindowsCompareStringOrdinal(currentMimeType.Get(), HStringReference(supportedMimeTypes[i]).Get(), &isSupported));

if (isSupported == 0)
{
Expand Down
9 changes: 4 additions & 5 deletions source/uwp/Renderer/lib/RenderedAdaptiveCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,12 @@ namespace AdaptiveNamespace

for (auto& showCardEntry : m_showCards)
{
InternalId showCardId = showCardEntry.first;
InternalId actionSetId = showCardEntry.second.first;
ComPtr<IUIElement> showCardUIElement = showCardEntry.second.second;

const InternalId showCardId = showCardEntry.first;
const InternalId actionSetId = showCardEntry.second.first;
if ((actionSetToToggle == actionSetId) && (showCardToToggle != showCardId))
{
RETURN_IF_FAILED(showCardUIElement->put_Visibility(Visibility_Collapsed));
ComPtr<IUIElement> showCardUIElementCurrent = showCardEntry.second.second;
RETURN_IF_FAILED(showCardUIElementCurrent->put_Visibility(Visibility_Collapsed));
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions source/uwp/Renderer/lib/TextHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ HRESULT SetXamlInlines(_In_ ABI::AdaptiveNamespace::IAdaptiveTextElement* adapti
ComPtr<ABI::Windows::Data::Xml::Dom::IXmlDocumentIO> xmlDocumentIO;
RETURN_IF_FAILED(xmlDocument.As(&xmlDocumentIO));

HRESULT hr = xmlDocumentIO->LoadXml(htmlHString.Get());
if (SUCCEEDED(hr))
if (SUCCEEDED(xmlDocumentIO->LoadXml(htmlHString.Get())))
{
ComPtr<ABI::Windows::Data::Xml::Dom::IXmlNode> xmlDocumentAsNode;
RETURN_IF_FAILED(xmlDocument.As(&xmlDocumentAsNode));
Expand Down
8 changes: 4 additions & 4 deletions source/uwp/Renderer/lib/TileControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ namespace AdaptiveNamespace
virtual HRESULT STDMETHODCALLTYPE ArrangeOverride(_In_ Size arrangeBounds, _Out_ Size* pReturnValue);

// not implemented
virtual HRESULT STDMETHODCALLTYPE get_BackgroundImage(_Outptr_ IAdaptiveBackgroundImage** value) { return E_NOTIMPL; }
virtual HRESULT STDMETHODCALLTYPE get_RootElement(_Outptr_ IFrameworkElement** value) { return E_NOTIMPL; }
virtual HRESULT STDMETHODCALLTYPE put_ResolvedImage(_In_ IUIElement* value) { return E_NOTIMPL; }
virtual HRESULT STDMETHODCALLTYPE get_ImageSize(_Out_ ABI::Windows::Foundation::Size* value)
virtual HRESULT STDMETHODCALLTYPE get_BackgroundImage(_Outptr_ IAdaptiveBackgroundImage** /*value*/) { return E_NOTIMPL; }
virtual HRESULT STDMETHODCALLTYPE get_RootElement(_Outptr_ IFrameworkElement** /*value*/) { return E_NOTIMPL; }
virtual HRESULT STDMETHODCALLTYPE put_ResolvedImage(_In_ IUIElement* /*value*/) { return E_NOTIMPL; }
virtual HRESULT STDMETHODCALLTYPE get_ImageSize(_Out_ ABI::Windows::Foundation::Size* /*value*/)
{
return E_NOTIMPL;
}
Expand Down
6 changes: 3 additions & 3 deletions source/uwp/Renderer/lib/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1454,9 +1454,9 @@ Color GenerateLighterColor(const Color& originalColor)

Color lighterColor;
lighterColor.A = originalColor.A;
lighterColor.R = originalColor.R + static_cast<int>((255 - originalColor.R) * lightIncrement);
lighterColor.G = originalColor.G + static_cast<int>((255 - originalColor.G) * lightIncrement);
lighterColor.B = originalColor.B + static_cast<int>((255 - originalColor.B) * lightIncrement);
lighterColor.R = originalColor.R + static_cast<BYTE>((255 - originalColor.R) * lightIncrement);
lighterColor.G = originalColor.G + static_cast<BYTE>((255 - originalColor.G) * lightIncrement);
lighterColor.B = originalColor.B + static_cast<BYTE>((255 - originalColor.B) * lightIncrement);
return lighterColor;
}

Expand Down
13 changes: 5 additions & 8 deletions source/uwp/Renderer/lib/WholeItemsPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,7 @@ namespace AdaptiveNamespace
{
ComPtr<ITextBlock> spTextBlock;

HRESULT hr = pUIElement->QueryInterface(spTextBlock.GetAddressOf());
if (SUCCEEDED(hr))
if (SUCCEEDED(pUIElement->QueryInterface(spTextBlock.GetAddressOf())))
{
HString hText;
RETURN_IF_FAILED(spTextBlock->get_Text(hText.GetAddressOf()));
Expand All @@ -526,8 +525,7 @@ namespace AdaptiveNamespace
}

ComPtr<IWholeItemsPanel> spWholeItemsPanel;
hr = pUIElement->QueryInterface(spWholeItemsPanel.GetAddressOf());
if (SUCCEEDED(hr))
if (SUCCEEDED(pUIElement->QueryInterface(spWholeItemsPanel.GetAddressOf())))
{
// This cast is safe because WinRT only does aggregation
WholeItemsPanel* pPanelNoRef = reinterpret_cast<WholeItemsPanel*>(spWholeItemsPanel.Get());
Expand All @@ -536,8 +534,7 @@ namespace AdaptiveNamespace
}

ComPtr<IImage> spImage;
hr = pUIElement->QueryInterface(spImage.GetAddressOf());
if (SUCCEEDED(hr))
if (SUCCEEDED(pUIElement->QueryInterface(spImage.GetAddressOf())))
{
HString hAltText;
RETURN_IF_FAILED(GetAltAsString(pUIElement, hAltText.GetAddressOf()));
Expand All @@ -547,9 +544,9 @@ namespace AdaptiveNamespace
}
return S_OK;
}

ComPtr<IShape> spShape;
hr = pUIElement->QueryInterface(spShape.GetAddressOf());
if (SUCCEEDED(hr))
if (SUCCEEDED(pUIElement->QueryInterface(spShape.GetAddressOf())))
{
HString hAltText;
RETURN_IF_FAILED(GetAltAsString(pUIElement, hAltText.GetAddressOf()));
Expand Down
2 changes: 1 addition & 1 deletion source/uwp/Renderer/lib/XamlBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,7 @@ namespace AdaptiveNamespace
ComPtr<IUIElement> toggleElementAsUIElement;
RETURN_IF_FAILED(toggleElement.As(&toggleElementAsUIElement));

Visibility visibilityToSet;
Visibility visibilityToSet = Visibility_Visible;
if (toggle == ABI::AdaptiveNamespace::IsVisible_IsVisibleTrue)
{
visibilityToSet = Visibility_Visible;
Expand Down
4 changes: 2 additions & 2 deletions source/uwp/Renderer/lib/XamlHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ namespace AdaptiveNamespace::XamlHelpers
ComPtr<IWholeItemsPanel> wholeItemsPanel;
if (SUCCEEDED(spPanel.As(&wholeItemsPanel)))
{
ComPtr<WholeItemsPanel> panel = PeekInnards<WholeItemsPanel>(wholeItemsPanel);
panel->AddElementToStretchablesList(elementToAppend.Get());
ComPtr<WholeItemsPanel> wholeItemsPanelObj = PeekInnards<WholeItemsPanel>(wholeItemsPanel);
wholeItemsPanelObj->AddElementToStretchablesList(elementToAppend.Get());
}
}
}
Expand Down