Skip to content

Commit 1bb5c43

Browse files
author
Anjali
authored
Addressed ambiguous call to overloaded function (#9435)
1 parent 0be453c commit 1bb5c43

File tree

13 files changed

+73
-67
lines changed

13 files changed

+73
-67
lines changed

src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FontCollectionLoader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace MS { namespace Internal { namespace Text { namespace TextInterface
2525

2626
public:
2727

28-
FontCollectionLoader() { Debug::Assert(false); }
28+
FontCollectionLoader() { Debug::Assert(false, "Assertion failed"); }
2929

3030
FontCollectionLoader(
3131
IFontSourceCollectionFactory^ fontSourceCollectionFactory,

src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FontFileEnumerator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace MS { namespace Internal { namespace Text { namespace TextInterface
2727

2828
public:
2929

30-
FontFileEnumerator() { Debug::Assert(false); }
30+
FontFileEnumerator() { Debug::Assert(false, "Assertion failed"); }
3131

3232
FontFileEnumerator(
3333
IEnumerable<IFontSource^>^ fontSourceCollection,

src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FontFileLoader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace MS { namespace Internal { namespace Text { namespace TextInterface
2222

2323
public:
2424

25-
FontFileLoader() { Debug::Assert(false); }
25+
FontFileLoader() { Debug::Assert(false, "Assertion failed"); }
2626

2727
FontFileLoader(IFontSourceFactory^ fontSourceFactory);
2828

src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FontFileStream.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace MS { namespace Internal { namespace Text { namespace TextInterface
2929
/// Asserts false because COM convention requires us to have a default constructor
3030
/// but we are the only entity that can construct these objects, and we use the
3131
/// other constructor.
32-
FontFileStream() { Debug::Assert(false); }
32+
FontFileStream() { Debug::Assert(false, "Assertion failed"); }
3333

3434
/// <summary>
3535
/// ctor.

src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/inc/GDIExporter/gdirt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ ref class CGDIRenderTarget : public CGDIDevice, public ILegacyDevice
8787
public:
8888
FontSimulatedStyleKey(String^ faceName, LONG lfWeight, BYTE lfItalic)
8989
{
90-
Debug::Assert(faceName != nullptr);
90+
Debug::Assert(faceName != nullptr, "faceName is not null.");
9191

9292
m_faceName = faceName;
9393
m_lfWeight = lfWeight;

src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/FontInfo.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
// FontStreamContext
1717
FontStreamContext::FontStreamContext(GlyphTypeface^ source)
1818
{
19-
Debug::Assert(source != nullptr);
19+
Debug::Assert(source != nullptr, "source should not be null");
2020

2121
_sourceTypeface = source;
2222
}
2323

2424
FontStreamContext::FontStreamContext(Uri^ source, int streamLength)
2525
{
26-
Debug::Assert(source != nullptr);
26+
Debug::Assert(source != nullptr, "Source should not be null.");
2727

2828
_sourceUri = source;
2929
_streamLength = streamLength;
@@ -129,7 +129,7 @@ bool FontStreamContext::Equals(FontStreamContext% otherContext)
129129

130130
if (otherStream != nullptr)
131131
{
132-
Debug::Assert(thisStream->Length == otherStream->Length);
132+
Debug::Assert(thisStream->Length == otherStream->Length, "Length of both streams should be same.");
133133

134134
//
135135
// Compare both streams CompareLength bytes at a time.
@@ -187,7 +187,7 @@ bool FontStreamContext::Equals(FontStreamContext% otherContext)
187187
}
188188
}
189189

190-
Debug::Assert(eof == 2);
190+
Debug::Assert(eof == 2, "Number of streams reaching eof should be 2.");
191191
}
192192
}
193193

@@ -197,14 +197,14 @@ bool FontStreamContext::Equals(FontStreamContext% otherContext)
197197
// FontInstallInfo
198198
FontInstallInfo::FontInstallInfo(Uri^ uri)
199199
{
200-
Debug::Assert(uri != nullptr);
200+
Debug::Assert(uri != nullptr, "Uri should not be null.");
201201

202202
_uri = uri;
203203
}
204204

205205
bool FontInstallInfo::Equals(FontStreamContext% context, FontInstallInfo^ otherFont)
206206
{
207-
Debug::Assert(otherFont != nullptr);
207+
Debug::Assert(otherFont != nullptr, "OtherFont should not be null.");
208208

209209
if (_uri->Equals(otherFont->_uri))
210210
{
@@ -798,7 +798,7 @@ Object^ FontInstallInfo::Install(FontStreamContext% context, String^ % newFamily
798798

799799
void FontInstallInfo::Uninstall(Object^ installHandle)
800800
{
801-
Debug::Assert(installHandle != nullptr);
801+
Debug::Assert(installHandle != nullptr, "Install handle should not be null.");
802802

803803
String^ filename = dynamic_cast<String^>(installHandle);
804804

@@ -851,7 +851,7 @@ bool FontInfo::UsePrivate(GlyphTypeface^ typeface)
851851
// installed as private or system font, in which case we simply use one of those.
852852
// Otherwise install the GlyphTypeface font into GDI.
853853
//
854-
Debug::Assert(typeface != nullptr);
854+
Debug::Assert(typeface != nullptr, "GlyphTypeface should not be null");
855855

856856
FontStreamContext installContext(typeface);
857857

@@ -904,7 +904,7 @@ void FontInfo::UninstallPrivate()
904904
{
905905
if (_privateInstall != nullptr)
906906
{
907-
Debug::Assert(_privateInstallHandle != nullptr);
907+
Debug::Assert(_privateInstallHandle != nullptr, "Private font should not be installed at this point");
908908

909909
_privateInstall->Uninstall(_privateInstallHandle);
910910

src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gdibitmap.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ int PaletteSorter::Search(int start, int end, COLORREF color)
7575
{
7676
for (;;)
7777
{
78-
Debug::Assert((start >= 0) && (end < IndexUsed));
78+
Debug::Assert((start >= 0) && (end < IndexUsed), "Invalid index range. Start: " + start + ", End: " + end + ", IndexUsed: " + IndexUsed);
7979

8080
// Break condition
8181
if (start > end)
@@ -251,8 +251,8 @@ void CGDIBitmap::SetBits(interior_ptr<BITMAPINFO> bmi)
251251
// Convert to indexed bitmap
252252
HRESULT CGDIBitmap::ColorReduction()
253253
{
254-
Debug::Assert(m_pSorter != nullptr);
255-
Debug::Assert(m_pSorter->IndexUsed <= 256);
254+
Debug::Assert(m_pSorter != nullptr, "m_pSorter should not be null.");
255+
Debug::Assert(m_pSorter->IndexUsed <= 256, "IndexUsed is out of bounds. IndexUsed: " + m_pSorter->IndexUsed);
256256

257257
int bpp = 8;
258258

@@ -284,7 +284,7 @@ HRESULT CGDIBitmap::ColorReduction()
284284
{
285285
int index = m_pSorter->Find(RGB(src[2], src[1], src[0]));
286286

287-
Debug::Assert(index < 2);
287+
Debug::Assert(index < 2, "index should be less than 2.");
288288

289289
dst[0] |= mask * index;
290290

@@ -305,7 +305,7 @@ HRESULT CGDIBitmap::ColorReduction()
305305
{
306306
int index = m_pSorter->Find(RGB(src[2], src[1], src[0]));
307307

308-
Debug::Assert(index < 16);
308+
Debug::Assert(index < 16, "index should be less than 16.");
309309

310310
if (w & 1)
311311
{
@@ -322,13 +322,13 @@ HRESULT CGDIBitmap::ColorReduction()
322322
}
323323
else
324324
{
325-
Debug::Assert(bpp == 8);
325+
Debug::Assert(bpp == 8, "bpp should be equal to 8.");
326326

327327
for (int w = 0; w < m_Width; w ++)
328328
{
329329
int index = m_pSorter->Find(RGB(src[2], src[1], src[0]));
330330

331-
Debug::Assert(index < 256);
331+
Debug::Assert(index < 256, "index should be less than 256.");
332332

333333
dst[0] = (BYTE) index;
334334

@@ -510,15 +510,15 @@ value class BandIterator
510510
// Gets the current band's rectangle.
511511
Int32Rect GetCurrent()
512512
{
513-
Debug::Assert(_index < _count && _index >= 0);
513+
Debug::Assert(_index < _count && _index >= 0, "Index out of bounds. Index: " + _index + ", Count: " + _count);
514514

515515
return _band;
516516
}
517517

518518
// Moves to the next band.
519519
bool MoveNext()
520520
{
521-
Debug::Assert(_index < _count && _index >= -1);
521+
Debug::Assert(_index < _count && _index >= -1, "Index out of bounds. Index: " + _index + ", Count: " + _count);
522522

523523
_index++;
524524

@@ -565,8 +565,8 @@ value class BandIterator
565565
HRESULT
566566
CGDIBitmap::StretchBlt(CGDIDevice ^ pDevice, const Int32Rect & dst, bool flipHoriz, bool flipVert)
567567
{
568-
Debug::Assert(pDevice != nullptr);
569-
Debug::Assert(IsValid());
568+
Debug::Assert(pDevice != nullptr, "pDevice should not be null.");
569+
Debug::Assert(IsValid(), "Not in a valid state.");
570570

571571
if ((m_Height > 0) && (m_Width > 0))
572572
{
@@ -682,7 +682,7 @@ CGDIBitmap::StretchBlt(CGDIDevice ^ pDevice, const Int32Rect & dst, bool flipHor
682682

683683
HRESULT CGDIBitmap::Load(BitmapSource ^ pBitmap, array<Byte>^ buffer, PixelFormat LoadFormat)
684684
{
685-
Debug::Assert(pBitmap != nullptr);
685+
Debug::Assert(pBitmap != nullptr, "pBitmap should not be null.");
686686

687687
m_pBitmap = pBitmap;
688688

@@ -831,8 +831,8 @@ BitmapSource ^ CreateBitmapAndFillWithBrush(
831831
PixelFormat pixelFormat
832832
)
833833
{
834-
Debug::Assert(brush != nullptr);
835-
Debug::Assert((nWidth > 0) && (nHeight > 0));
834+
Debug::Assert(brush != nullptr, "brush should not be null.");
835+
Debug::Assert((nWidth > 0) && (nHeight > 0), "Width and height must be positive. Width: " + nWidth + ", Height: " + nHeight);
836836

837837
RenderTargetBitmap ^pBitmap = gcnew RenderTargetBitmap(nWidth, nHeight, 96, 96, pixelFormat);
838838

src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gdidevice.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ HRESULT CGDIDevice::SetupForIncreasedResolution(int resolutionMultiplier, XFORM&
306306
{
307307
if (resolutionMultiplier > 1)
308308
{
309-
Debug::Assert((GetCaps() & CAP_WorldTransform) != 0);
309+
Debug::Assert((GetCaps() & CAP_WorldTransform) != 0, "CAP_WorldTransform flag is not set. GetCaps() returned: " + GetCaps());
310310

311311
// The points are greater than we want them so we need
312312
// to set a scaling transform to get them to the right size.
@@ -337,7 +337,7 @@ CGDIDevice::CleanupForIncreasedResolution(int resolutionMultiplier, const XFORM&
337337
{
338338
if (resolutionMultiplier > 1)
339339
{
340-
Debug::Assert((GetCaps() & CAP_WorldTransform) != 0);
340+
Debug::Assert((GetCaps() & CAP_WorldTransform) != 0, "CAP_WorldTransform flag is not set. GetCaps() returned: " + GetCaps());
341341

342342
return ErrorCode(CNativeMethods::SetWorldTransform(m_hDC, &oldTransform));
343343
}

src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/GDIExporter/gdipath.cpp

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ ref class GdiGeometryConverter : public CapacityStreamGeometryContext
247247
}
248248

249249
_figureStartIndex = AddPoint(point, PT_MOVETO);
250-
Debug::Assert(_figureStartIndex != -1);
250+
Debug::Assert(_figureStartIndex != -1, "figure start index cannot be -1.");
251251

252252
_figureStartPoint = point;
253253
_figureHasGaps = false;
@@ -403,7 +403,9 @@ ref class GdiGeometryConverter : public CapacityStreamGeometryContext
403403
if (_bezierIndex == 2 && _pointCount >= 3)
404404
{
405405
Debug::Assert((_types[_pointCount - 1] & PT_TYPEMASK) == PT_BEZIERTO &&
406-
(_types[_pointCount - 2] & PT_TYPEMASK) == PT_BEZIERTO);
406+
(_types[_pointCount - 2] & PT_TYPEMASK) == PT_BEZIERTO,
407+
"Last two points must be of type PT_BEZIERTO. "
408+
"Types: " + (_types[_pointCount - 1] & PT_TYPEMASK) + ", " + (_types[_pointCount - 2] & PT_TYPEMASK));
407409

408410
if (Colinear(dx, dy, _pointCount - 2, _pointCount - 1) &&
409411
Colinear(dx, dy, _pointCount - 3, _pointCount - 1))
@@ -436,7 +438,7 @@ ref class GdiGeometryConverter : public CapacityStreamGeometryContext
436438
// MUST be followed by adding a new point, or end geometry.
437439
void RemoveLastPoint()
438440
{
439-
Debug::Assert(_pointCount > 0);
441+
Debug::Assert(_pointCount > 0, "-pointCount should be greater than 0.");
440442

441443
if ((_types[_pointCount - 1] & PT_TYPEMASK) == PT_MOVETO)
442444
{
@@ -451,7 +453,8 @@ ref class GdiGeometryConverter : public CapacityStreamGeometryContext
451453

452454
Point GetLastPoint()
453455
{
454-
Debug::Assert(!Double::IsNaN(_lastPoint.X) && !Double::IsNaN(_lastPoint.Y));
456+
Debug::Assert(!Double::IsNaN(_lastPoint.X) && !Double::IsNaN(_lastPoint.Y),
457+
"Invalid point coordinates. X: " + _lastPoint.X + ", Y: " + _lastPoint.Y);
455458

456459
return _lastPoint;
457460
}
@@ -630,7 +633,8 @@ CGDIPath::CGDIPath(
630633
bool ForFill,
631634
Pen ^ pPen)
632635
{
633-
Debug::Assert(ForFill || pPen != nullptr);
636+
Debug::Assert(ForFill || pPen != nullptr,
637+
"ForFill is false and pPen is null. ForFill: " + ForFill + ", pPen: " + (pPen == nullptr ? "null" : "not null"));
634638

635639
// get path GDI fill mode
636640
m_PathFillMode = (geometry.GetFillRule() == FillRule::EvenOdd) ? ALTERNATE : WINDING;
@@ -757,7 +761,8 @@ void CGDIPath::ProcessPolygon(int count, bool ForFill, int figureCount)
757761
}
758762

759763
// add polygon count for previous polygon
760-
Debug::Assert((iPoint - iStartPoint) >= 2);
764+
Debug::Assert((iPoint - iStartPoint) >= 2, "Insufficient points for polygon. Points: " + (iPoint - iStartPoint));
765+
761766
m_PolyCounts[iPolygon] = iPoint - iStartPoint;
762767
}
763768

@@ -770,7 +775,7 @@ void CGDIPath::ProcessPolygon(int count, bool ForFill, int figureCount)
770775

771776
default:
772777
// invalid type
773-
Debug::Assert(0);
778+
Debug::Assert(0, "Unexpected assertion reached. This is a placeholder for an invalid type check.");
774779
// FALLTHRU
775780

776781
case PT_LINETO:
@@ -838,7 +843,7 @@ void CGDIPath::ProcessCurve(int count, bool ForFill)
838843
// Get the actual device bounds of the transformed points
839844
void CGDIPath::GetDeviceBounds(array<PointI>^ p, int count)
840845
{
841-
Debug::Assert(count >= 1);
846+
Debug::Assert(count >= 1, "Count should be greater than or equal to 1.");
842847

843848
int minX, minY, maxX, maxY;
844849

@@ -875,8 +880,8 @@ void CGDIPath::GetDeviceBounds(array<PointI>^ p, int count)
875880
// !!! This is a problem if there is already a path opened or defined
876881
HRESULT CGDIPath::Fill(CGDIDevice ^ dc, GdiSafeHandle^ brush)
877882
{
878-
Debug::Assert(IsValid());
879-
Debug::Assert(brush != nullptr);
883+
Debug::Assert(IsValid(), "Not in a valid state.");
884+
Debug::Assert(brush != nullptr, "brush should not be null.");
880885

881886
HRESULT hr = S_OK;
882887

@@ -964,8 +969,8 @@ HRESULT CGDIPath::Fill(CGDIDevice ^ dc, GdiSafeHandle^ brush)
964969

965970
HRESULT CGDIPath::Draw(CGDIDevice ^ dc, GdiSafeHandle ^ pen)
966971
{
967-
Debug::Assert(IsValid());
968-
Debug::Assert(pen != nullptr);
972+
Debug::Assert(IsValid(), "Not in a valid state.");
973+
Debug::Assert(pen != nullptr, "pen should not be null.");
969974

970975
HRESULT hr = S_OK;
971976

@@ -1005,7 +1010,7 @@ HRESULT CGDIPath::Draw(CGDIDevice ^ dc, GdiSafeHandle ^ pen)
10051010

10061011
// The polygons are generated through our API and
10071012
// should have been verified above.
1008-
Debug::Assert(count > 0);
1013+
Debug::Assert(count > 0, "Count should be greater than 0.");
10091014

10101015
if ((m_Points[offset].x == m_Points[offset + count - 1].x) &&
10111016
(m_Points[offset].y == m_Points[offset + count - 1].y))
@@ -1068,7 +1073,7 @@ HRESULT CGDIPath::Draw(CGDIDevice ^ dc, GdiSafeHandle ^ pen)
10681073

10691074
HRESULT CGDIPath::SelectClip(CGDIDevice ^ dc, int mode)
10701075
{
1071-
Debug::Assert(IsValid());
1076+
Debug::Assert(IsValid(), "Not in a valid state.");
10721077

10731078
HRESULT hr = S_OK;
10741079

@@ -1154,7 +1159,7 @@ double CGDIPath::MaxCos(void)
11541159
{
11551160
// close of figure.
11561161
// figure is from this point and last PT_MOVETO inclusive.
1157-
Debug::Assert(lastMoveTo != -1);
1162+
Debug::Assert(lastMoveTo != -1, "last PT_MOVETO is not initialized.");
11581163

11591164
figureStartClose->Add(lastMoveTo);
11601165
figureStartClose->Add(i);
@@ -1343,7 +1348,7 @@ void CPolyPolygon::GetBounds(void)
13431348
nTotal += m_rgcPoly[m_offsetC + i];
13441349
}
13451350

1346-
Debug::Assert(nTotal >= 1);
1351+
Debug::Assert(nTotal >= 1, "nTotal should be greater than or equal to 1.");
13471352

13481353
for (int i = 1; i < nTotal; i++)
13491354
{
@@ -1371,7 +1376,7 @@ void CPolyPolygon::Divide(
13711376
IN INT cGroup // number of CPolyPolygon to divide into
13721377
)
13731378
{
1374-
Debug::Assert(m_cPolygons >= cGroup);
1379+
Debug::Assert(m_cPolygons >= cGroup, "The number of polygons (m_cPolygons) should be greater than or equal to the group count (cGroup).");
13751380

13761381
int part = m_cPolygons / cGroup; // number of polygons per group
13771382

0 commit comments

Comments
 (0)