Enable Audit Mode for WinRTUtils (#3923)

## Summary of the Pull Request
Turns on Audit for WinRTUtils, fixes audit failures.

## PR Checklist
* [x] I work here
* [x] Still builds
* [x] Am core contributor.

## Validation Steps Performed
Built it.
This commit is contained in:
Michael Niksa 2019-12-12 05:28:32 -08:00 committed by msftbot[bot]
parent c227066a82
commit 9cae3c439e
6 changed files with 12 additions and 8 deletions

View File

@ -1229,7 +1229,8 @@ Global
{48D21369-3D7B-4431-9967-24E81292CF63}.Release|x86.Build.0 = Release|Win32
{CA5CAD1A-039A-4929-BA2A-8BEB2E4106FE}.AuditMode|Any CPU.ActiveCfg = Release|x64
{CA5CAD1A-039A-4929-BA2A-8BEB2E4106FE}.AuditMode|ARM64.ActiveCfg = Release|ARM64
{CA5CAD1A-039A-4929-BA2A-8BEB2E4106FE}.AuditMode|x64.ActiveCfg = Release|x64
{CA5CAD1A-039A-4929-BA2A-8BEB2E4106FE}.AuditMode|x64.ActiveCfg = AuditMode|x64
{CA5CAD1A-039A-4929-BA2A-8BEB2E4106FE}.AuditMode|x64.Build.0 = AuditMode|x64
{CA5CAD1A-039A-4929-BA2A-8BEB2E4106FE}.AuditMode|x86.ActiveCfg = Release|Win32
{CA5CAD1A-039A-4929-BA2A-8BEB2E4106FE}.Debug|Any CPU.ActiveCfg = Debug|Win32
{CA5CAD1A-039A-4929-BA2A-8BEB2E4106FE}.Debug|ARM64.ActiveCfg = Debug|ARM64

View File

@ -76,7 +76,8 @@ static void EnsureAllResourcesArePresent(const ScopedResourceLoader& loader)
#endif
static ScopedResourceLoader GetLibraryResourceLoader() UTILS_NONDEBUG_NOEXCEPT
static ScopedResourceLoader GetLibraryResourceLoader()
try
{
ScopedResourceLoader loader{ g_WinRTUtilsLibraryResourceScope };
#ifdef _DEBUG
@ -84,9 +85,12 @@ static ScopedResourceLoader GetLibraryResourceLoader() UTILS_NONDEBUG_NOEXCEPT
#endif
return loader;
}
CATCH_FAIL_FAST()
winrt::hstring GetLibraryResourceString(const std::wstring_view key) UTILS_NONDEBUG_NOEXCEPT
winrt::hstring GetLibraryResourceString(const std::wstring_view key)
try
{
static auto loader{ GetLibraryResourceLoader() };
return loader.GetLocalizedString(key);
}
CATCH_FAIL_FAST()

View File

@ -17,7 +17,7 @@ ScopedResourceLoader::ScopedResourceLoader(const std::wstring_view resourceLocat
// - Gets the resource map associated with the scoped resource subcompartment.
// Return Value:
// - the resource map associated with the scoped resource subcompartment.
ResourceMap ScopedResourceLoader::GetResourceMap() const
ResourceMap ScopedResourceLoader::GetResourceMap() const noexcept
{
return _resourceMap;
}

View File

@ -7,7 +7,7 @@ class ScopedResourceLoader
{
public:
ScopedResourceLoader(const std::wstring_view resourceLocatorBase);
winrt::Windows::ApplicationModel::Resources::Core::ResourceMap GetResourceMap() const;
winrt::Windows::ApplicationModel::Resources::Core::ResourceMap GetResourceMap() const noexcept;
winrt::hstring GetLocalizedString(const std::wstring_view resourceName) const;
bool HasResourceWithName(const std::wstring_view resourceName) const;

View File

@ -49,7 +49,6 @@ namespace Microsoft::Console::Utils
return pRes->resourceKey; \
}())
#define RS_(x) GetLibraryResourceString(USES_RESOURCE(x))
#define UTILS_NONDEBUG_NOEXCEPT
#else // _DEBUG
@ -57,11 +56,10 @@ namespace Microsoft::Console::Utils
#define USES_RESOURCE(x) (x)
#define RS_(x) GetLibraryResourceString((x))
#define UTILS_NONDEBUG_NOEXCEPT noexcept
#endif
#define UTILS_DEFINE_LIBRARY_RESOURCE_SCOPE(x) \
__declspec(selectany) extern const wchar_t* g_WinRTUtilsLibraryResourceScope{ (x) };
winrt::hstring GetLibraryResourceString(const std::wstring_view key) UTILS_NONDEBUG_NOEXCEPT;
winrt::hstring GetLibraryResourceString(const std::wstring_view key);

View File

@ -146,6 +146,7 @@
<CodeAnalysisRuleSet>$(SolutionDir)\src\StaticAnalysis.ruleset</CodeAnalysisRuleSet>
<EnableCppCoreCheck>true</EnableCppCoreCheck>
<RunCodeAnalysis>true</RunCodeAnalysis>
<CAExcludePath>$(SolutionDir)\dep</CAExcludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='AuditMode'">
<ClCompile>