diff --git a/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FontCollectionLoader.h b/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FontCollectionLoader.h index a236b1a75de..9933942abf0 100644 --- a/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FontCollectionLoader.h +++ b/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FontCollectionLoader.h @@ -25,7 +25,7 @@ namespace MS { namespace Internal { namespace Text { namespace TextInterface public: - FontCollectionLoader() { Debug::Assert(false); } + FontCollectionLoader() { Debug::Assert(false, "Assertion failed"); } FontCollectionLoader( IFontSourceCollectionFactory^ fontSourceCollectionFactory, diff --git a/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FontFileEnumerator.h b/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FontFileEnumerator.h index f55149b458d..884227aae75 100644 --- a/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FontFileEnumerator.h +++ b/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FontFileEnumerator.h @@ -27,7 +27,7 @@ namespace MS { namespace Internal { namespace Text { namespace TextInterface public: - FontFileEnumerator() { Debug::Assert(false); } + FontFileEnumerator() { Debug::Assert(false, "Assertion failed"); } FontFileEnumerator( IEnumerable^ fontSourceCollection, diff --git a/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FontFileLoader.h b/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FontFileLoader.h index dbf72593691..771fb1c93f6 100644 --- a/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FontFileLoader.h +++ b/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FontFileLoader.h @@ -22,7 +22,7 @@ namespace MS { namespace Internal { namespace Text { namespace TextInterface public: - FontFileLoader() { Debug::Assert(false); } + FontFileLoader() { Debug::Assert(false, "Assertion failed"); } FontFileLoader(IFontSourceFactory^ fontSourceFactory); diff --git a/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FontFileStream.h b/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FontFileStream.h index 49cf479b0b4..3e0bb35b8d3 100644 --- a/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FontFileStream.h +++ b/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FontFileStream.h @@ -29,7 +29,7 @@ namespace MS { namespace Internal { namespace Text { namespace TextInterface /// Asserts false because COM convention requires us to have a default constructor /// but we are the only entity that can construct these objects, and we use the /// other constructor. - FontFileStream() { Debug::Assert(false); } + FontFileStream() { Debug::Assert(false, "Assertion failed"); } /// /// ctor. diff --git a/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/inc/GDIExporter/gdirt.h b/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/inc/GDIExporter/gdirt.h index a6911534e21..b86483db638 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/inc/GDIExporter/gdirt.h +++ b/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/inc/GDIExporter/gdirt.h @@ -87,7 +87,7 @@ ref class CGDIRenderTarget : public CGDIDevice, public ILegacyDevice public: FontSimulatedStyleKey(String^ faceName, LONG lfWeight, BYTE lfItalic) { - Debug::Assert(faceName != nullptr); + Debug::Assert(faceName != nullptr, "faceName is not null."); m_faceName = faceName; m_lfWeight = lfWeight; diff --git a/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/FontInfo.cpp b/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/FontInfo.cpp index c01f7203357..87413d4cdb4 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/FontInfo.cpp +++ b/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/FontInfo.cpp @@ -16,14 +16,14 @@ // FontStreamContext FontStreamContext::FontStreamContext(GlyphTypeface^ source) { - Debug::Assert(source != nullptr); + Debug::Assert(source != nullptr, "source should not be null"); _sourceTypeface = source; } FontStreamContext::FontStreamContext(Uri^ source, int streamLength) { - Debug::Assert(source != nullptr); + Debug::Assert(source != nullptr, "Source should not be null."); _sourceUri = source; _streamLength = streamLength; @@ -129,7 +129,7 @@ bool FontStreamContext::Equals(FontStreamContext% otherContext) if (otherStream != nullptr) { - Debug::Assert(thisStream->Length == otherStream->Length); + Debug::Assert(thisStream->Length == otherStream->Length, "Length of both streams should be same."); // // Compare both streams CompareLength bytes at a time. @@ -187,7 +187,7 @@ bool FontStreamContext::Equals(FontStreamContext% otherContext) } } - Debug::Assert(eof == 2); + Debug::Assert(eof == 2, "Number of streams reaching eof should be 2."); } } @@ -197,14 +197,14 @@ bool FontStreamContext::Equals(FontStreamContext% otherContext) // FontInstallInfo FontInstallInfo::FontInstallInfo(Uri^ uri) { - Debug::Assert(uri != nullptr); + Debug::Assert(uri != nullptr, "Uri should not be null."); _uri = uri; } bool FontInstallInfo::Equals(FontStreamContext% context, FontInstallInfo^ otherFont) { - Debug::Assert(otherFont != nullptr); + Debug::Assert(otherFont != nullptr, "OtherFont should not be null."); if (_uri->Equals(otherFont->_uri)) { @@ -798,7 +798,7 @@ Object^ FontInstallInfo::Install(FontStreamContext% context, String^ % newFamily void FontInstallInfo::Uninstall(Object^ installHandle) { - Debug::Assert(installHandle != nullptr); + Debug::Assert(installHandle != nullptr, "Install handle should not be null."); String^ filename = dynamic_cast(installHandle); @@ -851,7 +851,7 @@ bool FontInfo::UsePrivate(GlyphTypeface^ typeface) // installed as private or system font, in which case we simply use one of those. // Otherwise install the GlyphTypeface font into GDI. // - Debug::Assert(typeface != nullptr); + Debug::Assert(typeface != nullptr, "GlyphTypeface should not be null"); FontStreamContext installContext(typeface); @@ -904,7 +904,7 @@ void FontInfo::UninstallPrivate() { if (_privateInstall != nullptr) { - Debug::Assert(_privateInstallHandle != nullptr); + Debug::Assert(_privateInstallHandle != nullptr, "Private font should not be installed at this point"); _privateInstall->Uninstall(_privateInstallHandle); diff --git a/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gdibitmap.cpp b/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gdibitmap.cpp index f2f348423c4..dc0991d0fc0 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gdibitmap.cpp +++ b/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gdibitmap.cpp @@ -75,7 +75,7 @@ int PaletteSorter::Search(int start, int end, COLORREF color) { for (;;) { - Debug::Assert((start >= 0) && (end < IndexUsed)); + Debug::Assert((start >= 0) && (end < IndexUsed), "Invalid index range. Start: " + start + ", End: " + end + ", IndexUsed: " + IndexUsed); // Break condition if (start > end) @@ -251,8 +251,8 @@ void CGDIBitmap::SetBits(interior_ptr bmi) // Convert to indexed bitmap HRESULT CGDIBitmap::ColorReduction() { - Debug::Assert(m_pSorter != nullptr); - Debug::Assert(m_pSorter->IndexUsed <= 256); + Debug::Assert(m_pSorter != nullptr, "m_pSorter should not be null."); + Debug::Assert(m_pSorter->IndexUsed <= 256, "IndexUsed is out of bounds. IndexUsed: " + m_pSorter->IndexUsed); int bpp = 8; @@ -284,7 +284,7 @@ HRESULT CGDIBitmap::ColorReduction() { int index = m_pSorter->Find(RGB(src[2], src[1], src[0])); - Debug::Assert(index < 2); + Debug::Assert(index < 2, "index should be less than 2."); dst[0] |= mask * index; @@ -305,7 +305,7 @@ HRESULT CGDIBitmap::ColorReduction() { int index = m_pSorter->Find(RGB(src[2], src[1], src[0])); - Debug::Assert(index < 16); + Debug::Assert(index < 16, "index should be less than 16."); if (w & 1) { @@ -322,13 +322,13 @@ HRESULT CGDIBitmap::ColorReduction() } else { - Debug::Assert(bpp == 8); + Debug::Assert(bpp == 8, "bpp should be equal to 8."); for (int w = 0; w < m_Width; w ++) { int index = m_pSorter->Find(RGB(src[2], src[1], src[0])); - Debug::Assert(index < 256); + Debug::Assert(index < 256, "index should be less than 256."); dst[0] = (BYTE) index; @@ -510,7 +510,7 @@ value class BandIterator // Gets the current band's rectangle. Int32Rect GetCurrent() { - Debug::Assert(_index < _count && _index >= 0); + Debug::Assert(_index < _count && _index >= 0, "Index out of bounds. Index: " + _index + ", Count: " + _count); return _band; } @@ -518,7 +518,7 @@ value class BandIterator // Moves to the next band. bool MoveNext() { - Debug::Assert(_index < _count && _index >= -1); + Debug::Assert(_index < _count && _index >= -1, "Index out of bounds. Index: " + _index + ", Count: " + _count); _index++; @@ -565,8 +565,8 @@ value class BandIterator HRESULT CGDIBitmap::StretchBlt(CGDIDevice ^ pDevice, const Int32Rect & dst, bool flipHoriz, bool flipVert) { - Debug::Assert(pDevice != nullptr); - Debug::Assert(IsValid()); + Debug::Assert(pDevice != nullptr, "pDevice should not be null."); + Debug::Assert(IsValid(), "Not in a valid state."); if ((m_Height > 0) && (m_Width > 0)) { @@ -682,7 +682,7 @@ CGDIBitmap::StretchBlt(CGDIDevice ^ pDevice, const Int32Rect & dst, bool flipHor HRESULT CGDIBitmap::Load(BitmapSource ^ pBitmap, array^ buffer, PixelFormat LoadFormat) { - Debug::Assert(pBitmap != nullptr); + Debug::Assert(pBitmap != nullptr, "pBitmap should not be null."); m_pBitmap = pBitmap; @@ -831,8 +831,8 @@ BitmapSource ^ CreateBitmapAndFillWithBrush( PixelFormat pixelFormat ) { - Debug::Assert(brush != nullptr); - Debug::Assert((nWidth > 0) && (nHeight > 0)); + Debug::Assert(brush != nullptr, "brush should not be null."); + Debug::Assert((nWidth > 0) && (nHeight > 0), "Width and height must be positive. Width: " + nWidth + ", Height: " + nHeight); RenderTargetBitmap ^pBitmap = gcnew RenderTargetBitmap(nWidth, nHeight, 96, 96, pixelFormat); diff --git a/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gdidevice.cpp b/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gdidevice.cpp index e80f4eeef92..27a729c1552 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gdidevice.cpp +++ b/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gdidevice.cpp @@ -306,7 +306,7 @@ HRESULT CGDIDevice::SetupForIncreasedResolution(int resolutionMultiplier, XFORM& { if (resolutionMultiplier > 1) { - Debug::Assert((GetCaps() & CAP_WorldTransform) != 0); + Debug::Assert((GetCaps() & CAP_WorldTransform) != 0, "CAP_WorldTransform flag is not set. GetCaps() returned: " + GetCaps()); // The points are greater than we want them so we need // to set a scaling transform to get them to the right size. @@ -337,7 +337,7 @@ CGDIDevice::CleanupForIncreasedResolution(int resolutionMultiplier, const XFORM& { if (resolutionMultiplier > 1) { - Debug::Assert((GetCaps() & CAP_WorldTransform) != 0); + Debug::Assert((GetCaps() & CAP_WorldTransform) != 0, "CAP_WorldTransform flag is not set. GetCaps() returned: " + GetCaps()); return ErrorCode(CNativeMethods::SetWorldTransform(m_hDC, &oldTransform)); } diff --git a/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gdipath.cpp b/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gdipath.cpp index 00235939e7e..16f860c2150 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gdipath.cpp +++ b/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gdipath.cpp @@ -247,7 +247,7 @@ ref class GdiGeometryConverter : public CapacityStreamGeometryContext } _figureStartIndex = AddPoint(point, PT_MOVETO); - Debug::Assert(_figureStartIndex != -1); + Debug::Assert(_figureStartIndex != -1, "figure start index cannot be -1."); _figureStartPoint = point; _figureHasGaps = false; @@ -403,7 +403,9 @@ ref class GdiGeometryConverter : public CapacityStreamGeometryContext if (_bezierIndex == 2 && _pointCount >= 3) { Debug::Assert((_types[_pointCount - 1] & PT_TYPEMASK) == PT_BEZIERTO && - (_types[_pointCount - 2] & PT_TYPEMASK) == PT_BEZIERTO); + (_types[_pointCount - 2] & PT_TYPEMASK) == PT_BEZIERTO, + "Last two points must be of type PT_BEZIERTO. " + "Types: " + (_types[_pointCount - 1] & PT_TYPEMASK) + ", " + (_types[_pointCount - 2] & PT_TYPEMASK)); if (Colinear(dx, dy, _pointCount - 2, _pointCount - 1) && Colinear(dx, dy, _pointCount - 3, _pointCount - 1)) @@ -436,7 +438,7 @@ ref class GdiGeometryConverter : public CapacityStreamGeometryContext // MUST be followed by adding a new point, or end geometry. void RemoveLastPoint() { - Debug::Assert(_pointCount > 0); + Debug::Assert(_pointCount > 0, "-pointCount should be greater than 0."); if ((_types[_pointCount - 1] & PT_TYPEMASK) == PT_MOVETO) { @@ -451,7 +453,8 @@ ref class GdiGeometryConverter : public CapacityStreamGeometryContext Point GetLastPoint() { - Debug::Assert(!Double::IsNaN(_lastPoint.X) && !Double::IsNaN(_lastPoint.Y)); + Debug::Assert(!Double::IsNaN(_lastPoint.X) && !Double::IsNaN(_lastPoint.Y), + "Invalid point coordinates. X: " + _lastPoint.X + ", Y: " + _lastPoint.Y); return _lastPoint; } @@ -630,7 +633,8 @@ CGDIPath::CGDIPath( bool ForFill, Pen ^ pPen) { - Debug::Assert(ForFill || pPen != nullptr); + Debug::Assert(ForFill || pPen != nullptr, + "ForFill is false and pPen is null. ForFill: " + ForFill + ", pPen: " + (pPen == nullptr ? "null" : "not null")); // get path GDI fill mode m_PathFillMode = (geometry.GetFillRule() == FillRule::EvenOdd) ? ALTERNATE : WINDING; @@ -757,7 +761,8 @@ void CGDIPath::ProcessPolygon(int count, bool ForFill, int figureCount) } // add polygon count for previous polygon - Debug::Assert((iPoint - iStartPoint) >= 2); + Debug::Assert((iPoint - iStartPoint) >= 2, "Insufficient points for polygon. Points: " + (iPoint - iStartPoint)); + m_PolyCounts[iPolygon] = iPoint - iStartPoint; } @@ -770,7 +775,7 @@ void CGDIPath::ProcessPolygon(int count, bool ForFill, int figureCount) default: // invalid type - Debug::Assert(0); + Debug::Assert(0, "Unexpected assertion reached. This is a placeholder for an invalid type check."); // FALLTHRU case PT_LINETO: @@ -838,7 +843,7 @@ void CGDIPath::ProcessCurve(int count, bool ForFill) // Get the actual device bounds of the transformed points void CGDIPath::GetDeviceBounds(array^ p, int count) { - Debug::Assert(count >= 1); + Debug::Assert(count >= 1, "Count should be greater than or equal to 1."); int minX, minY, maxX, maxY; @@ -875,8 +880,8 @@ void CGDIPath::GetDeviceBounds(array^ p, int count) // !!! This is a problem if there is already a path opened or defined HRESULT CGDIPath::Fill(CGDIDevice ^ dc, GdiSafeHandle^ brush) { - Debug::Assert(IsValid()); - Debug::Assert(brush != nullptr); + Debug::Assert(IsValid(), "Not in a valid state."); + Debug::Assert(brush != nullptr, "brush should not be null."); HRESULT hr = S_OK; @@ -964,8 +969,8 @@ HRESULT CGDIPath::Fill(CGDIDevice ^ dc, GdiSafeHandle^ brush) HRESULT CGDIPath::Draw(CGDIDevice ^ dc, GdiSafeHandle ^ pen) { - Debug::Assert(IsValid()); - Debug::Assert(pen != nullptr); + Debug::Assert(IsValid(), "Not in a valid state."); + Debug::Assert(pen != nullptr, "pen should not be null."); HRESULT hr = S_OK; @@ -1005,7 +1010,7 @@ HRESULT CGDIPath::Draw(CGDIDevice ^ dc, GdiSafeHandle ^ pen) // The polygons are generated through our API and // should have been verified above. - Debug::Assert(count > 0); + Debug::Assert(count > 0, "Count should be greater than 0."); if ((m_Points[offset].x == m_Points[offset + count - 1].x) && (m_Points[offset].y == m_Points[offset + count - 1].y)) @@ -1068,7 +1073,7 @@ HRESULT CGDIPath::Draw(CGDIDevice ^ dc, GdiSafeHandle ^ pen) HRESULT CGDIPath::SelectClip(CGDIDevice ^ dc, int mode) { - Debug::Assert(IsValid()); + Debug::Assert(IsValid(), "Not in a valid state."); HRESULT hr = S_OK; @@ -1154,7 +1159,7 @@ double CGDIPath::MaxCos(void) { // close of figure. // figure is from this point and last PT_MOVETO inclusive. - Debug::Assert(lastMoveTo != -1); + Debug::Assert(lastMoveTo != -1, "last PT_MOVETO is not initialized."); figureStartClose->Add(lastMoveTo); figureStartClose->Add(i); @@ -1343,7 +1348,7 @@ void CPolyPolygon::GetBounds(void) nTotal += m_rgcPoly[m_offsetC + i]; } - Debug::Assert(nTotal >= 1); + Debug::Assert(nTotal >= 1, "nTotal should be greater than or equal to 1."); for (int i = 1; i < nTotal; i++) { @@ -1371,7 +1376,7 @@ void CPolyPolygon::Divide( IN INT cGroup // number of CPolyPolygon to divide into ) { - Debug::Assert(m_cPolygons >= cGroup); + Debug::Assert(m_cPolygons >= cGroup, "The number of polygons (m_cPolygons) should be greater than or equal to the group count (cGroup)."); int part = m_cPolygons / cGroup; // number of polygons per group diff --git a/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gdipen.cpp b/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gdipen.cpp index 03271b1d933..4f7aaca56ae 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gdipen.cpp +++ b/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gdipen.cpp @@ -7,7 +7,7 @@ bool DashStylesEqual(DashStyle^ da, DashStyle^ db) { - Debug::Assert(da != nullptr && db != nullptr); + Debug::Assert(da != nullptr && db != nullptr, "DashStyle da and db should not be null."); if (!AreCloseReal(da->Offset, db->Offset)) { @@ -17,7 +17,7 @@ bool DashStylesEqual(DashStyle^ da, DashStyle^ db) DoubleCollection^ a = da->Dashes; DoubleCollection^ b = db->Dashes; - Debug::Assert(a != nullptr && b != nullptr); + Debug::Assert(a != nullptr && b != nullptr, "a and b should not be null."); int count = a->Count; @@ -40,7 +40,7 @@ bool DashStylesEqual(DashStyle^ da, DashStyle^ db) bool PenSupported(Pen ^ pPen, Matrix matrix, unsigned dpi) { - Debug::Assert(pPen != nullptr); + Debug::Assert(pPen != nullptr, "pPen should not be null."); // Pen width in inch double width = pPen->Thickness * GetScaleX(matrix) / dpi; diff --git a/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gdirt.cpp b/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gdirt.cpp index 41cbf985f7a..ed51749fe0b 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gdirt.cpp +++ b/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gdirt.cpp @@ -200,7 +200,7 @@ HRESULT CGDIRenderTarget::DrawBitmap_PassThrough( int nImageHeight ) { - Debug::Assert(pIBitmap != nullptr); + Debug::Assert(pIBitmap != nullptr, "pIBitmap should not be null."); HRESULT hr = E_NOTIMPL; @@ -363,8 +363,8 @@ PixelFormat GetLoadFormat(PixelFormat format) HRESULT CGDIRenderTarget::DrawBitmap(BitmapSource ^ pImage, array^ buffer, Rect rectDest) { - Debug::Assert(pImage != nullptr); - Debug::Assert(!rectDest.IsEmpty); + Debug::Assert(pImage != nullptr, "pImage should not be null"); + Debug::Assert(!rectDest.IsEmpty, "rectDest should not be empty"); // Compute destination bounding rectangle in measure units, then transform to device units. // Afterwards clip. @@ -639,7 +639,7 @@ ref class StrokeGeometrySplitter : public CapacityStreamGeometryContext Brush^ callbackBrush ) { - Debug::Assert(callback != nullptr); + Debug::Assert(callback != nullptr, "callback should not be null."); _transform = transform; @@ -1066,7 +1066,7 @@ HRESULT CGDIRenderTarget::StrokePath( IN Brush ^pStrokeBrush ) { - Debug::Assert(pPen != nullptr); + Debug::Assert(pPen != nullptr, "pPen should not be null."); Int32Rect drawbounds; @@ -1409,7 +1409,7 @@ void GenerateGradientBandVertices( IN Color% color ) { - Debug::Assert((vertexOffset + 2) <= vertices->Length); + Debug::Assert((vertexOffset + 2) <= vertices->Length, "Vertex offset is out of bounds"); // vertices differ only in y coordinate vertices[vertexOffset++].Fill( @@ -1434,7 +1434,8 @@ void GenerateGradientBandTriangles( IN int vertexOffset ) { - Debug::Assert((indexOffset + 6) <= indices->Length); + Debug::Assert((indexOffset + 6) <= indices->Length, + "Assertion failed: indexOffset + 6 should be less than or equal to indices->Length."); // first triangle starts at bottom vertex for (int i = 0; i < 3; i++) @@ -1541,7 +1542,7 @@ HRESULT CGDIRenderTarget::FillLinearGradient( return E_NOTIMPL; } - Debug::Assert(lastGroupIndex >= firstGroupIndex); + Debug::Assert(lastGroupIndex >= firstGroupIndex, "lastGroupIndex should be greater than or equal to firstGroupIndex."); // Number of gradient bands (regions filled with gradient between 2 colors). // Handle padding spread method by adding edge bands. @@ -1774,7 +1775,7 @@ HRESULT CGDIRenderTarget::RasterizeBrush( double ScaleY ) { - Debug::Assert(pFillBrush != nullptr); + Debug::Assert(pFillBrush != nullptr, "pFillBrush cannot be null."); HRESULT hr = S_OK; @@ -1990,7 +1991,7 @@ HRESULT CGDIRenderTarget::RasterizeShape( if (SUCCEEDED(hr)) { - Debug::Assert(nRemain == 0); + Debug::Assert(nRemain == 0, "nRemain should be zero."); } if (clipPushed) diff --git a/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gditextrt.cpp b/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gditextrt.cpp index ed3081ea3f4..0426f32315b 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gditextrt.cpp +++ b/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gditextrt.cpp @@ -83,7 +83,7 @@ bool RenderUnicode(GlyphRun ^pGlyphRun) Debug::Assert(!renderCodepoints || ( pGlyphRun->Characters != nullptr && pGlyphRun->GlyphIndices->Count == pGlyphRun->Characters->Count - ) + ), "Assertion failed: Condition for GlyphIndices and Characters count mismatch." ); // diff --git a/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/utils.cpp b/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/utils.cpp index e64ef60432e..d9fcb500fb6 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/utils.cpp +++ b/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/utils.cpp @@ -154,7 +154,7 @@ HRESULT RectFToGDIRect(Rect % boundsF, Int32Rect % rect) // Lower-right exclus // 2 pixels in size, and does not touch any pixels in column // 3 or row 3: - Debug::Assert((rect.Width >= 0) && (rect.Height >= 0)); + Debug::Assert((rect.Width >= 0) && (rect.Height >= 0), "Rectangle dimensions should not be negative. Width: " + rect.Width + ", Height: " + rect.Height); if (fSucceeded) return S_OK; @@ -250,7 +250,7 @@ TransformBounds( delete [] vertex; - Debug::Assert((left <= right) && (top <= bottom)); + Debug::Assert((left <= right) && (top <= bottom), "Invalid rectangle bounds. Left: " + left + ", Right: " + right + ", Top: " + top + ", Bottom: " + bottom); bounds.X = left; bounds.Y = top; @@ -291,10 +291,10 @@ bool IntersectRect( ) { // we want normalized rects here - Debug::Assert(prcSrc1.Width >= 0); - Debug::Assert(prcSrc2.Width >= 0); - Debug::Assert(prcSrc1.Height >= 0); - Debug::Assert(prcSrc2.Height >= 0); + Debug::Assert(prcSrc1.Width >= 0, "prcSrc1 width should not be negative. Width: " + prcSrc1.Width); + Debug::Assert(prcSrc2.Width >= 0, "prcSrc2 width should not be negative. Width: " + prcSrc2.Width); + Debug::Assert(prcSrc1.Height >= 0, "prcSrc1 height should not be negative. Height: " + prcSrc1.Height); + Debug::Assert(prcSrc2.Height >= 0, "prcSrc2 height should not be negative. Height: " + prcSrc2.Height); int w = min(prcSrc1.X + prcSrc1.Width, prcSrc2.X + prcSrc2.Width) - max(prcSrc1.X, prcSrc2.X);