Compare commits

...

5 Commits

Author SHA1 Message Date
Michael Niksa
abcb3f3aa4 C26443, Overriding destructor shouldn't use specifiers. (c.128) 2019-12-11 15:39:50 -08:00
Michael Niksa
2370c0034a C26496, mark variables used once as const (con.4) 2019-12-11 15:36:42 -08:00
Michael Niksa
7ac3fde2d8 Enable audit for RendererBase 2019-12-11 15:36:31 -08:00
Michael Niksa
a923077e60 Fix noexcept based warnings on WinRT utils library. 2019-12-11 15:28:48 -08:00
Michael Niksa
8759b44c49 Add WinRTUtils to audit, disable wil path globally from auditing. 2019-12-11 15:23:42 -08:00
9 changed files with 22 additions and 18 deletions

View File

@@ -408,8 +408,8 @@ Global
{1CF55140-EF6A-4736-A403-957E4F7430BB}.Release|x86.Build.0 = Release|Win32 {1CF55140-EF6A-4736-A403-957E4F7430BB}.Release|x86.Build.0 = Release|Win32
{AF0A096A-8B3A-4949-81EF-7DF8F0FEE91F}.AuditMode|Any CPU.ActiveCfg = AuditMode|Win32 {AF0A096A-8B3A-4949-81EF-7DF8F0FEE91F}.AuditMode|Any CPU.ActiveCfg = AuditMode|Win32
{AF0A096A-8B3A-4949-81EF-7DF8F0FEE91F}.AuditMode|ARM64.ActiveCfg = Release|ARM64 {AF0A096A-8B3A-4949-81EF-7DF8F0FEE91F}.AuditMode|ARM64.ActiveCfg = Release|ARM64
{AF0A096A-8B3A-4949-81EF-7DF8F0FEE91F}.AuditMode|x64.ActiveCfg = Release|x64 {AF0A096A-8B3A-4949-81EF-7DF8F0FEE91F}.AuditMode|x64.ActiveCfg = AuditMode|x64
{AF0A096A-8B3A-4949-81EF-7DF8F0FEE91F}.AuditMode|x64.Build.0 = Release|x64 {AF0A096A-8B3A-4949-81EF-7DF8F0FEE91F}.AuditMode|x64.Build.0 = AuditMode|x64
{AF0A096A-8B3A-4949-81EF-7DF8F0FEE91F}.AuditMode|x86.ActiveCfg = Release|Win32 {AF0A096A-8B3A-4949-81EF-7DF8F0FEE91F}.AuditMode|x86.ActiveCfg = Release|Win32
{AF0A096A-8B3A-4949-81EF-7DF8F0FEE91F}.Debug|Any CPU.ActiveCfg = Debug|Win32 {AF0A096A-8B3A-4949-81EF-7DF8F0FEE91F}.Debug|Any CPU.ActiveCfg = Debug|Win32
{AF0A096A-8B3A-4949-81EF-7DF8F0FEE91F}.Debug|ARM64.ActiveCfg = Debug|ARM64 {AF0A096A-8B3A-4949-81EF-7DF8F0FEE91F}.Debug|ARM64.ActiveCfg = Debug|ARM64
@@ -1229,7 +1229,8 @@ Global
{48D21369-3D7B-4431-9967-24E81292CF63}.Release|x86.Build.0 = Release|Win32 {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|Any CPU.ActiveCfg = Release|x64
{CA5CAD1A-039A-4929-BA2A-8BEB2E4106FE}.AuditMode|ARM64.ActiveCfg = Release|ARM64 {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}.AuditMode|x86.ActiveCfg = Release|Win32
{CA5CAD1A-039A-4929-BA2A-8BEB2E4106FE}.Debug|Any CPU.ActiveCfg = Debug|Win32 {CA5CAD1A-039A-4929-BA2A-8BEB2E4106FE}.Debug|Any CPU.ActiveCfg = Debug|Win32
{CA5CAD1A-039A-4929-BA2A-8BEB2E4106FE}.Debug|ARM64.ActiveCfg = Debug|ARM64 {CA5CAD1A-039A-4929-BA2A-8BEB2E4106FE}.Debug|ARM64.ActiveCfg = Debug|ARM64

View File

@@ -76,7 +76,8 @@ static void EnsureAllResourcesArePresent(const ScopedResourceLoader& loader)
#endif #endif
static ScopedResourceLoader GetLibraryResourceLoader() UTILS_NONDEBUG_NOEXCEPT static ScopedResourceLoader GetLibraryResourceLoader()
try
{ {
ScopedResourceLoader loader{ g_WinRTUtilsLibraryResourceScope }; ScopedResourceLoader loader{ g_WinRTUtilsLibraryResourceScope };
#ifdef _DEBUG #ifdef _DEBUG
@@ -84,9 +85,12 @@ static ScopedResourceLoader GetLibraryResourceLoader() UTILS_NONDEBUG_NOEXCEPT
#endif #endif
return loader; 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() }; static auto loader{ GetLibraryResourceLoader() };
return loader.GetLocalizedString(key); 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. // - Gets the resource map associated with the scoped resource subcompartment.
// Return Value: // Return Value:
// - the resource map associated with the scoped resource subcompartment. // - the resource map associated with the scoped resource subcompartment.
ResourceMap ScopedResourceLoader::GetResourceMap() const ResourceMap ScopedResourceLoader::GetResourceMap() const noexcept
{ {
return _resourceMap; return _resourceMap;
} }

View File

@@ -7,7 +7,7 @@ class ScopedResourceLoader
{ {
public: public:
ScopedResourceLoader(const std::wstring_view resourceLocatorBase); 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; winrt::hstring GetLocalizedString(const std::wstring_view resourceName) const;
bool HasResourceWithName(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; \ return pRes->resourceKey; \
}()) }())
#define RS_(x) GetLibraryResourceString(USES_RESOURCE(x)) #define RS_(x) GetLibraryResourceString(USES_RESOURCE(x))
#define UTILS_NONDEBUG_NOEXCEPT
#else // _DEBUG #else // _DEBUG
@@ -57,11 +56,10 @@ namespace Microsoft::Console::Utils
#define USES_RESOURCE(x) (x) #define USES_RESOURCE(x) (x)
#define RS_(x) GetLibraryResourceString((x)) #define RS_(x) GetLibraryResourceString((x))
#define UTILS_NONDEBUG_NOEXCEPT noexcept
#endif #endif
#define UTILS_DEFINE_LIBRARY_RESOURCE_SCOPE(x) \ #define UTILS_DEFINE_LIBRARY_RESOURCE_SCOPE(x) \
__declspec(selectany) extern const wchar_t* g_WinRTUtilsLibraryResourceScope{ (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> <CodeAnalysisRuleSet>$(SolutionDir)\src\StaticAnalysis.ruleset</CodeAnalysisRuleSet>
<EnableCppCoreCheck>true</EnableCppCoreCheck> <EnableCppCoreCheck>true</EnableCppCoreCheck>
<RunCodeAnalysis>true</RunCodeAnalysis> <RunCodeAnalysis>true</RunCodeAnalysis>
<CAExcludePath>$(SolutionDir)\dep</CAExcludePath>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='AuditMode'"> <ItemDefinitionGroup Condition="'$(Configuration)'=='AuditMode'">
<ClCompile> <ClCompile>

View File

@@ -268,7 +268,7 @@ void Renderer::TriggerTeardown()
for (IRenderEngine* const pEngine : _rgpEngines) for (IRenderEngine* const pEngine : _rgpEngines)
{ {
bool fEngineRequestsRepaint = false; bool fEngineRequestsRepaint = false;
HRESULT hr = pEngine->PrepareForTeardown(&fEngineRequestsRepaint); const auto hr = pEngine->PrepareForTeardown(&fEngineRequestsRepaint);
LOG_IF_FAILED(hr); LOG_IF_FAILED(hr);
if (SUCCEEDED(hr) && fEngineRequestsRepaint) if (SUCCEEDED(hr) && fEngineRequestsRepaint)
@@ -372,7 +372,7 @@ void Renderer::TriggerCircling()
for (IRenderEngine* const pEngine : _rgpEngines) for (IRenderEngine* const pEngine : _rgpEngines)
{ {
bool fEngineRequestsRepaint = false; bool fEngineRequestsRepaint = false;
HRESULT hr = pEngine->InvalidateCircling(&fEngineRequestsRepaint); const auto hr = pEngine->InvalidateCircling(&fEngineRequestsRepaint);
LOG_IF_FAILED(hr); LOG_IF_FAILED(hr);
if (SUCCEEDED(hr) && fEngineRequestsRepaint) if (SUCCEEDED(hr) && fEngineRequestsRepaint)
@@ -716,7 +716,7 @@ void Renderer::_PaintBufferOutputGridLineHelper(_In_ IRenderEngine* const pEngin
const COLORREF rgb = _pData->GetForegroundColor(textAttribute); const COLORREF rgb = _pData->GetForegroundColor(textAttribute);
// Convert console grid line representations into rendering engine enum representations. // Convert console grid line representations into rendering engine enum representations.
IRenderEngine::GridLines lines = Renderer::s_GetGridlines(textAttribute); const auto lines = Renderer::s_GetGridlines(textAttribute);
// Draw the lines // Draw the lines
LOG_IF_FAILED(pEngine->PaintBufferGridLines(lines, rgb, cchLine, coordTarget)); LOG_IF_FAILED(pEngine->PaintBufferGridLines(lines, rgb, cchLine, coordTarget));
@@ -738,8 +738,8 @@ void Renderer::_PaintCursor(_In_ IRenderEngine* const pEngine)
Viewport view = _pData->GetViewport(); Viewport view = _pData->GetViewport();
view.ConvertToOrigin(&coordCursor); view.ConvertToOrigin(&coordCursor);
COLORREF cursorColor = _pData->GetCursorColor(); const auto cursorColor = _pData->GetCursorColor();
bool useColor = cursorColor != INVALID_COLOR; const auto useColor = cursorColor != INVALID_COLOR;
// Build up the cursor parameters including position, color, and drawing options // Build up the cursor parameters including position, color, and drawing options
IRenderEngine::CursorOptions options; IRenderEngine::CursorOptions options;
@@ -840,7 +840,7 @@ void Renderer::_PaintSelection(_In_ IRenderEngine* const pEngine)
{ {
try try
{ {
SMALL_RECT srDirty = pEngine->GetDirtyRectInChars(); const auto srDirty = pEngine->GetDirtyRectInChars();
Viewport dirtyView = Viewport::FromInclusive(srDirty); Viewport dirtyView = Viewport::FromInclusive(srDirty);
// Get selection rectangles // Get selection rectangles

View File

@@ -43,7 +43,7 @@ namespace Microsoft::Console::Render
[[nodiscard]] static HRESULT s_CreateInstance(IRenderData* pData, [[nodiscard]] static HRESULT s_CreateInstance(IRenderData* pData,
_Outptr_result_nullonfailure_ Renderer** const ppRenderer); _Outptr_result_nullonfailure_ Renderer** const ppRenderer);
virtual ~Renderer() override; ~Renderer();
[[nodiscard]] HRESULT PaintFrame(); [[nodiscard]] HRESULT PaintFrame();

View File

@@ -23,7 +23,7 @@ namespace Microsoft::Console::Render
{ {
public: public:
RenderThread(); RenderThread();
virtual ~RenderThread() override; ~RenderThread();
[[nodiscard]] HRESULT Initialize(_In_ IRenderer* const pRendererParent) noexcept; [[nodiscard]] HRESULT Initialize(_In_ IRenderer* const pRendererParent) noexcept;