diff --git a/src/buffer/out/CharRowCell.cpp b/src/buffer/out/CharRowCell.cpp index 38da6a1720..d8cdeff429 100644 --- a/src/buffer/out/CharRowCell.cpp +++ b/src/buffer/out/CharRowCell.cpp @@ -8,13 +8,13 @@ // default glyph value, used for reseting the character data portion of a cell static constexpr wchar_t DefaultValue = UNICODE_SPACE; -CharRowCell::CharRowCell() noexcept: +CharRowCell::CharRowCell() noexcept : _wch{ DefaultValue }, _attr{} { } -CharRowCell::CharRowCell(const wchar_t wch, const DbcsAttribute attr) noexcept: +CharRowCell::CharRowCell(const wchar_t wch, const DbcsAttribute attr) noexcept : _wch{ wch }, _attr{ attr } { diff --git a/src/buffer/out/CharRowCellReference.cpp b/src/buffer/out/CharRowCellReference.cpp index caf6979fbe..41357320f5 100644 --- a/src/buffer/out/CharRowCellReference.cpp +++ b/src/buffer/out/CharRowCellReference.cpp @@ -92,7 +92,7 @@ CharRowCellReference::const_iterator CharRowCellReference::begin() const // Return Value: // - end iterator of the glyph data #pragma warning(push) -#pragma warning(disable:26481) +#pragma warning(disable : 26481) // TODO: eliminate using pointers raw as begin/end markers in this class CharRowCellReference::const_iterator CharRowCellReference::end() const { diff --git a/src/buffer/out/OutputCellIterator.cpp b/src/buffer/out/OutputCellIterator.cpp index a709c1c3ce..ebc7e5e004 100644 --- a/src/buffer/out/OutputCellIterator.cpp +++ b/src/buffer/out/OutputCellIterator.cpp @@ -117,7 +117,7 @@ OutputCellIterator::OutputCellIterator(const std::wstring_view utf16Text, const // NOTE: This one internally casts to wchar_t because Razzle sees WORD and wchar_t as the same type // despite that Visual Studio build can tell the difference. #pragma warning(push) -#pragma warning(suppress:26490) +#pragma warning(suppress : 26490) // Suppresses reinterpret_cast. We're only doing this because Windows doesn't understand the type difference between wchar_t and DWORD. // It is not worth trying to separate that out further or risking performance over this particular warning here. OutputCellIterator::OutputCellIterator(const std::basic_string_view legacyAttrs, const bool /*unused*/) noexcept : diff --git a/src/buffer/out/OutputCellView.cpp b/src/buffer/out/OutputCellView.cpp index 6380e1f788..57a9449889 100644 --- a/src/buffer/out/OutputCellView.cpp +++ b/src/buffer/out/OutputCellView.cpp @@ -15,7 +15,7 @@ OutputCellView::OutputCellView(const std::wstring_view view, const DbcsAttribute dbcsAttr, const TextAttribute textAttr, - const TextAttributeBehavior behavior) noexcept: + const TextAttributeBehavior behavior) noexcept : _view(view), _dbcsAttr(dbcsAttr), _textAttr(textAttr), @@ -28,8 +28,7 @@ OutputCellView::OutputCellView(const std::wstring_view view, // Return Value: // - Reference to UTF-16 character data // C26445 - suppressed to enable the `TextBufferTextIterator::operator->` method which needs a non-temporary memory location holding the wstring_view. -[[gsl::suppress(26445)]] -const std::wstring_view& OutputCellView::Chars() const noexcept +[[gsl::suppress(26445)]] const std::wstring_view& OutputCellView::Chars() const noexcept { return _view; } diff --git a/src/buffer/out/cursor.cpp b/src/buffer/out/cursor.cpp index 7362478475..0b2f461be4 100644 --- a/src/buffer/out/cursor.cpp +++ b/src/buffer/out/cursor.cpp @@ -11,7 +11,7 @@ // - Constructor to set default properties for Cursor // Arguments: // - ulSize - The height of the cursor within this buffer -Cursor::Cursor(const ULONG ulSize, TextBuffer& parentBuffer) noexcept: +Cursor::Cursor(const ULONG ulSize, TextBuffer& parentBuffer) noexcept : _parentBuffer{ parentBuffer }, _cPosition{ 0 }, _fHasMoved(false), diff --git a/src/buffer/out/textBuffer.cpp b/src/buffer/out/textBuffer.cpp index cf37993f4b..d61d25d0bc 100644 --- a/src/buffer/out/textBuffer.cpp +++ b/src/buffer/out/textBuffer.cpp @@ -1002,6 +1002,8 @@ const TextBuffer::TextAndColor TextBuffer::GetTextForClipboard(const bool lineSe selectionBkAttr.push_back(CellBkAttr); } } +#pragma warning(suppress : 26444) + // TODO: figure out why there's custom construction/destruction happening here it++; } diff --git a/src/buffer/out/textBufferTextIterator.cpp b/src/buffer/out/textBufferTextIterator.cpp index 7e7ed7acd2..c0cc3ad088 100644 --- a/src/buffer/out/textBufferTextIterator.cpp +++ b/src/buffer/out/textBufferTextIterator.cpp @@ -16,7 +16,7 @@ using namespace Microsoft::Console::Types; // - Narrows the view of a cell iterator into a text only iterator. // Arguments: // - A cell iterator -TextBufferTextIterator::TextBufferTextIterator(const TextBufferCellIterator& cellIt) noexcept: +TextBufferTextIterator::TextBufferTextIterator(const TextBufferCellIterator& cellIt) noexcept : TextBufferCellIterator(cellIt) { } @@ -25,8 +25,7 @@ TextBufferTextIterator::TextBufferTextIterator(const TextBufferCellIterator& cel // - Returns the text information from the text buffer position addressed by this iterator. // Return Value: // - Read only UTF-16 text data -[[gsl::suppress(26434)]] -const std::wstring_view TextBufferTextIterator::operator*() const noexcept +[[gsl::suppress(26434)]] const std::wstring_view TextBufferTextIterator::operator*() const noexcept { return _view.Chars(); } @@ -35,8 +34,7 @@ const std::wstring_view TextBufferTextIterator::operator*() const noexcept // - Returns the text information from the text buffer position addressed by this iterator. // Return Value: // - Read only UTF-16 text data -[[gsl::suppress(26434)]] -const std::wstring_view* TextBufferTextIterator::operator->() const noexcept +[[gsl::suppress(26434)]] const std::wstring_view* TextBufferTextIterator::operator->() const noexcept { return &_view.Chars(); } diff --git a/src/inc/DefaultSettings.h b/src/inc/DefaultSettings.h index 2a16dd88ea..22dd95d0f4 100644 --- a/src/inc/DefaultSettings.h +++ b/src/inc/DefaultSettings.h @@ -28,7 +28,7 @@ constexpr COLORREF POWERSHELL_BLUE = RGB(1, 36, 86); constexpr short DEFAULT_HISTORY_SIZE = 9001; #pragma warning(push) -#pragma warning(disable:26426) +#pragma warning(disable : 26426) const std::wstring DEFAULT_FONT_FACE{ L"Consolas" }; constexpr int DEFAULT_FONT_SIZE = 10; diff --git a/src/renderer/dx/DxRenderer.cpp b/src/renderer/dx/DxRenderer.cpp index 17d0a0976d..982e666a8d 100644 --- a/src/renderer/dx/DxRenderer.cpp +++ b/src/renderer/dx/DxRenderer.cpp @@ -24,6 +24,8 @@ using namespace Microsoft::Console::Types; // Routine Description: // - Constructs a DirectX-based renderer for console text // which primarily uses DirectWrite on a Direct2D surface +#pragma warning(suppress : 26455) +// TODO: The default constructor should not throw. DxEngine::DxEngine() : RenderEngineBase(), _isInvalidUsed{ false }, @@ -268,7 +270,7 @@ DxEngine::~DxEngine() freeOnFail.release(); // don't need to release if we made it to the bottom and everything was good. // Notify that swap chain changed. - + if (_pfn) { try @@ -393,7 +395,7 @@ void DxEngine::_ReleaseDeviceResources() noexcept gsl::narrow(stringLength), _dwriteTextFormat.Get(), gsl::narrow(_displaySizePixels.cx), - _glyphCell.cy != 0 ? _glyphCell.cy : gsl::narrow( _displaySizePixels.cy), + _glyphCell.cy != 0 ? _glyphCell.cy : gsl::narrow(_displaySizePixels.cy), ppTextLayout); } @@ -749,7 +751,7 @@ void DxEngine::_InvalidOr(RECT rc) noexcept // First, set up a complete clear of all device resources if something goes terribly wrong. auto resetDeviceResourcesOnFailure = wil::scope_exit([&]() noexcept { _ReleaseDeviceResources(); - }); + }); // Now let go of a few of the device resources that get in the way of resizing buffers in the swap chain _dxgiSurface.Reset(); @@ -1244,17 +1246,16 @@ enum class CursorPaintType [[nodiscard]] HRESULT DxEngine::UpdateFont(const FontInfoDesired& pfiFontInfoDesired, FontInfo& fiFontInfo) noexcept { RETURN_IF_FAILED(_GetProposedFont(pfiFontInfoDesired, - fiFontInfo, - _dpi, - _dwriteTextFormat, - _dwriteTextAnalyzer, - _dwriteFontFace)); + fiFontInfo, + _dpi, + _dwriteTextFormat, + _dwriteTextAnalyzer, + _dwriteFontFace)); try { const auto size = fiFontInfo.GetSize(); - _glyphCell.cx = size.X; _glyphCell.cy = size.Y; } diff --git a/src/renderer/inc/IRenderEngine.hpp b/src/renderer/inc/IRenderEngine.hpp index d172607b3c..2d32138131 100644 --- a/src/renderer/inc/IRenderEngine.hpp +++ b/src/renderer/inc/IRenderEngine.hpp @@ -70,8 +70,8 @@ namespace Microsoft::Console::Render IRenderEngine(IRenderEngine&&) = default; IRenderEngine& operator=(const IRenderEngine&) = default; IRenderEngine& operator=(IRenderEngine&&) = default; - public: + public: [[nodiscard]] virtual HRESULT StartPaint() noexcept = 0; [[nodiscard]] virtual HRESULT EndPaint() noexcept = 0; [[nodiscard]] virtual HRESULT Present() noexcept = 0; diff --git a/src/renderer/inc/IRenderTarget.hpp b/src/renderer/inc/IRenderTarget.hpp index ffc83f6e37..4fbba7fad4 100644 --- a/src/renderer/inc/IRenderTarget.hpp +++ b/src/renderer/inc/IRenderTarget.hpp @@ -24,14 +24,15 @@ namespace Microsoft::Console::Render { public: virtual ~IRenderTarget() = 0; + protected: IRenderTarget() = default; IRenderTarget(const IRenderTarget&) = default; IRenderTarget(IRenderTarget&&) = default; IRenderTarget& operator=(const IRenderTarget&) = default; IRenderTarget& operator=(IRenderTarget&&) = default; - public: + public: virtual void TriggerRedraw(const Microsoft::Console::Types::Viewport& region) = 0; virtual void TriggerRedraw(const COORD* const pcoord) = 0; virtual void TriggerRedrawCursor(const COORD* const pcoord) = 0; diff --git a/src/renderer/inc/RenderEngineBase.hpp b/src/renderer/inc/RenderEngineBase.hpp index 66f0ee1d59..eae934bc77 100644 --- a/src/renderer/inc/RenderEngineBase.hpp +++ b/src/renderer/inc/RenderEngineBase.hpp @@ -25,14 +25,15 @@ namespace Microsoft::Console::Render { public: ~RenderEngineBase() = 0; + protected: RenderEngineBase(); RenderEngineBase(const RenderEngineBase&) = default; RenderEngineBase(RenderEngineBase&&) = default; RenderEngineBase& operator=(const RenderEngineBase&) = default; RenderEngineBase& operator=(RenderEngineBase&&) = default; - public: + public: [[nodiscard]] HRESULT InvalidateTitle(const std::wstring& proposedTitle) noexcept override; [[nodiscard]] HRESULT UpdateTitle(const std::wstring& newTitle) noexcept override; diff --git a/src/types/CodepointWidthDetector.cpp b/src/types/CodepointWidthDetector.cpp index aea44fe964..eb29a8af48 100644 --- a/src/types/CodepointWidthDetector.cpp +++ b/src/types/CodepointWidthDetector.cpp @@ -316,7 +316,6 @@ CodepointWidthDetector::CodepointWidthDetector() noexcept : _fallbackCache{}, _pfnFallbackMethod{} { - } // Routine Description: diff --git a/src/types/GlyphWidth.cpp b/src/types/GlyphWidth.cpp index 5efbaba2d9..2a7d5113e6 100644 --- a/src/types/GlyphWidth.cpp +++ b/src/types/GlyphWidth.cpp @@ -5,7 +5,7 @@ #include "inc/CodepointWidthDetector.hpp" #include "inc/GlyphWidth.hpp" -#pragma warning(suppress: 26426) +#pragma warning(suppress : 26426) static CodepointWidthDetector widthDetector; // Function Description: diff --git a/src/types/IBaseData.h b/src/types/IBaseData.h index cabcaf9a77..453dbae771 100644 --- a/src/types/IBaseData.h +++ b/src/types/IBaseData.h @@ -24,12 +24,14 @@ namespace Microsoft::Console::Types { public: virtual ~IBaseData() = 0; + protected: IBaseData() = default; IBaseData(const IBaseData&) = default; IBaseData(IBaseData&&) = default; IBaseData& operator=(const IBaseData&) = default; IBaseData& operator=(IBaseData&&) = default; + public: virtual Microsoft::Console::Types::Viewport GetViewport() noexcept = 0; virtual const TextBuffer& GetTextBuffer() noexcept = 0; diff --git a/src/types/IUiaData.h b/src/types/IUiaData.h index 7b2ef08b1b..6fbb2f513e 100644 --- a/src/types/IUiaData.h +++ b/src/types/IUiaData.h @@ -24,14 +24,15 @@ namespace Microsoft::Console::Types { public: ~IUiaData() = 0; + protected: IUiaData() = default; IUiaData(const IUiaData&) = default; IUiaData(IUiaData&&) = default; IUiaData& operator=(const IUiaData&) = default; IUiaData& operator=(IUiaData&&) = default; - public: + public: virtual const bool IsSelectionActive() const = 0; virtual void ClearSelection() = 0; virtual void SelectNewRegion(const COORD coordStart, const COORD coordEnd) = 0; diff --git a/src/types/UiaTextRangeBase.cpp b/src/types/UiaTextRangeBase.cpp index 1ac0ed5ca4..bf0418e9b7 100644 --- a/src/types/UiaTextRangeBase.cpp +++ b/src/types/UiaTextRangeBase.cpp @@ -290,7 +290,7 @@ IFACEMETHODIMP UiaTextRangeBase::Compare(_In_opt_ ITextRangeProvider* pRange, _O _pData->LockConsole(); auto Unlock = wil::scope_exit([&]() noexcept { _pData->UnlockConsole(); - }); + }); RETURN_HR_IF(E_INVALIDARG, pRetVal == nullptr); *pRetVal = FALSE; @@ -352,7 +352,7 @@ IFACEMETHODIMP UiaTextRangeBase::ExpandToEnclosingUnit(_In_ TextUnit unit) _pData->LockConsole(); auto Unlock = wil::scope_exit([&]() noexcept { _pData->UnlockConsole(); - }); + }); ApiMsgExpandToEnclosingUnit apiMsg; apiMsg.Unit = unit; @@ -428,7 +428,7 @@ IFACEMETHODIMP UiaTextRangeBase::GetBoundingRectangles(_Outptr_result_maybenull_ _pData->LockConsole(); auto Unlock = wil::scope_exit([&]() noexcept { _pData->UnlockConsole(); - }); + }); RETURN_HR_IF(E_INVALIDARG, ppRetVal == nullptr); *ppRetVal = nullptr; @@ -499,7 +499,7 @@ IFACEMETHODIMP UiaTextRangeBase::GetText(_In_ int maxLength, _Out_ BSTR* pRetVal _pData->LockConsole(); auto Unlock = wil::scope_exit([&]() noexcept { _pData->UnlockConsole(); - }); + }); RETURN_HR_IF(E_INVALIDARG, pRetVal == nullptr); *pRetVal = nullptr; @@ -602,7 +602,7 @@ IFACEMETHODIMP UiaTextRangeBase::Move(_In_ TextUnit unit, _pData->LockConsole(); auto Unlock = wil::scope_exit([&]() noexcept { _pData->UnlockConsole(); - }); + }); RETURN_HR_IF(E_INVALIDARG, pRetVal == nullptr); *pRetVal = 0; @@ -674,7 +674,7 @@ IFACEMETHODIMP UiaTextRangeBase::MoveEndpointByUnit(_In_ TextPatternRangeEndpoin _pData->LockConsole(); auto Unlock = wil::scope_exit([&]() noexcept { _pData->UnlockConsole(); - }); + }); RETURN_HR_IF(E_INVALIDARG, pRetVal == nullptr); *pRetVal = 0; @@ -741,7 +741,7 @@ IFACEMETHODIMP UiaTextRangeBase::MoveEndpointByRange(_In_ TextPatternRangeEndpoi _pData->LockConsole(); auto Unlock = wil::scope_exit([&]() noexcept { _pData->UnlockConsole(); - }); + }); const UiaTextRangeBase* range = static_cast(pTargetRange); if (range == nullptr) @@ -843,7 +843,7 @@ IFACEMETHODIMP UiaTextRangeBase::Select() _pData->LockConsole(); auto Unlock = wil::scope_exit([&]() noexcept { _pData->UnlockConsole(); - }); + }); if (_degenerate) { @@ -886,11 +886,10 @@ IFACEMETHODIMP UiaTextRangeBase::ScrollIntoView(_In_ BOOL alignToTop) _pData->LockConsole(); auto Unlock = wil::scope_exit([&]() noexcept { _pData->UnlockConsole(); - }); + }); try { - const auto oldViewport = _pData->GetViewport().ToInclusive(); const auto viewportHeight = _getViewportHeight(oldViewport); // range rows @@ -1168,7 +1167,7 @@ const bool UiaTextRangeBase::_isScreenInfoRowInViewport(const ScreenInfoRow row, { const ViewportRow viewportRow = _screenInfoRowToViewportRow(row, viewport); return viewportRow >= 0 && - viewportRow < gsl::narrow(_getViewportHeight(viewport)); + viewportRow < gsl::narrow(_getViewportHeight(viewport)); } // Routine Description: @@ -1513,8 +1512,8 @@ std::pair UiaTextRangeBase::_moveByLine(gsl::not_null 0 && moveState.Increment == MovementIncrement::Forward))); + ((moveCount < 0 && moveState.Increment == MovementIncrement::Backward) || + (moveCount > 0 && moveState.Increment == MovementIncrement::Forward))); if (moveCount != 0 && !illegalMovement) { diff --git a/src/types/UiaTextRangeBase.hpp b/src/types/UiaTextRangeBase.hpp index 3028dd7f0f..aaba89e791 100644 --- a/src/types/UiaTextRangeBase.hpp +++ b/src/types/UiaTextRangeBase.hpp @@ -303,7 +303,7 @@ namespace Microsoft::Console::Types static const ViewportRow _screenInfoRowToViewportRow(gsl::not_null pData, const ScreenInfoRow row) noexcept; static constexpr const ViewportRow _screenInfoRowToViewportRow(const ScreenInfoRow row, - const SMALL_RECT viewport) noexcept; + const SMALL_RECT viewport) noexcept; static const bool _isScreenInfoRowInViewport(gsl::not_null pData, const ScreenInfoRow row) noexcept; diff --git a/src/types/WindowUiaProviderBase.hpp b/src/types/WindowUiaProviderBase.hpp index 2a4634a696..3cd68b1a2f 100644 --- a/src/types/WindowUiaProviderBase.hpp +++ b/src/types/WindowUiaProviderBase.hpp @@ -33,12 +33,14 @@ namespace Microsoft::Console::Types { public: virtual ~WindowUiaProviderBase() = default; + protected: WindowUiaProviderBase() = default; WindowUiaProviderBase(const WindowUiaProviderBase&) = default; WindowUiaProviderBase(WindowUiaProviderBase&&) = default; WindowUiaProviderBase& operator=(const WindowUiaProviderBase&) = default; WindowUiaProviderBase& operator=(WindowUiaProviderBase&&) = default; + public: [[nodiscard]] virtual HRESULT Signal(_In_ EVENTID id) = 0; [[nodiscard]] virtual HRESULT SetTextAreaFocus() = 0;