@@ -26,8 +26,10 @@ public GraphicsPath(FillMode fillMode)
26
26
27
27
public GraphicsPath ( PointF [ ] pts , byte [ ] types ) : this ( pts , types , FillMode . Alternate ) { }
28
28
29
- public unsafe GraphicsPath ( PointF [ ] pts ! ! , byte [ ] types , FillMode fillMode )
29
+ public unsafe GraphicsPath ( PointF [ ] pts , byte [ ] types , FillMode fillMode )
30
30
{
31
+ ArgumentNullException . ThrowIfNull ( pts ) ;
32
+
31
33
if ( pts . Length != types . Length )
32
34
throw Gdip . StatusException ( Gdip . InvalidParameter ) ;
33
35
@@ -43,8 +45,10 @@ public unsafe GraphicsPath(PointF[] pts!!, byte[] types, FillMode fillMode)
43
45
44
46
public GraphicsPath ( Point [ ] pts , byte [ ] types ) : this ( pts , types , FillMode . Alternate ) { }
45
47
46
- public unsafe GraphicsPath ( Point [ ] pts ! ! , byte [ ] types , FillMode fillMode )
48
+ public unsafe GraphicsPath ( Point [ ] pts , byte [ ] types , FillMode fillMode )
47
49
{
50
+ ArgumentNullException . ThrowIfNull ( pts ) ;
51
+
48
52
if ( pts . Length != types . Length )
49
53
throw Gdip . StatusException ( Gdip . InvalidParameter ) ;
50
54
@@ -242,8 +246,10 @@ public bool IsOutlineVisible(float x, float y, Pen pen, Graphics? graphics)
242
246
return IsOutlineVisible ( new PointF ( x , y ) , pen , graphics ) ;
243
247
}
244
248
245
- public bool IsOutlineVisible ( PointF pt , Pen pen ! ! , Graphics ? graphics )
249
+ public bool IsOutlineVisible ( PointF pt , Pen pen , Graphics ? graphics )
246
250
{
251
+ ArgumentNullException . ThrowIfNull ( pen ) ;
252
+
247
253
Gdip . CheckStatus ( Gdip . GdipIsOutlineVisiblePathPoint (
248
254
new HandleRef ( this , _nativePath ) ,
249
255
pt . X , pt . Y ,
@@ -260,8 +266,10 @@ public bool IsOutlineVisible(PointF pt, Pen pen!!, Graphics? graphics)
260
266
261
267
public bool IsOutlineVisible ( int x , int y , Pen pen , Graphics ? graphics ) => IsOutlineVisible ( new Point ( x , y ) , pen , graphics ) ;
262
268
263
- public bool IsOutlineVisible ( Point pt , Pen pen ! ! , Graphics ? graphics )
269
+ public bool IsOutlineVisible ( Point pt , Pen pen , Graphics ? graphics )
264
270
{
271
+ ArgumentNullException . ThrowIfNull ( pen ) ;
272
+
265
273
Gdip . CheckStatus ( Gdip . GdipIsOutlineVisiblePathPointI (
266
274
new HandleRef ( this , _nativePath ) ,
267
275
pt . X , pt . Y ,
@@ -279,8 +287,10 @@ public void AddLine(float x1, float y1, float x2, float y2)
279
287
Gdip . CheckStatus ( Gdip . GdipAddPathLine ( new HandleRef ( this , _nativePath ) , x1 , y1 , x2 , y2 ) ) ;
280
288
}
281
289
282
- public unsafe void AddLines ( PointF [ ] points ! ! )
290
+ public unsafe void AddLines ( PointF [ ] points )
283
291
{
292
+ ArgumentNullException . ThrowIfNull ( points ) ;
293
+
284
294
if ( points . Length == 0 )
285
295
throw new ArgumentException ( null , nameof ( points ) ) ;
286
296
@@ -297,8 +307,10 @@ public void AddLine(int x1, int y1, int x2, int y2)
297
307
Gdip . CheckStatus ( Gdip . GdipAddPathLineI ( new HandleRef ( this , _nativePath ) , x1 , y1 , x2 , y2 ) ) ;
298
308
}
299
309
300
- public unsafe void AddLines ( Point [ ] points ! ! )
310
+ public unsafe void AddLines ( Point [ ] points )
301
311
{
312
+ ArgumentNullException . ThrowIfNull ( points ) ;
313
+
302
314
if ( points . Length == 0 )
303
315
throw new ArgumentException ( null , nameof ( points ) ) ;
304
316
@@ -348,8 +360,10 @@ public void AddBezier(float x1, float y1, float x2, float y2, float x3, float y3
348
360
x1 , y1 , x2 , y2 , x3 , y3 , x4 , y4 ) ) ;
349
361
}
350
362
351
- public unsafe void AddBeziers ( PointF [ ] points ! ! )
363
+ public unsafe void AddBeziers ( PointF [ ] points )
352
364
{
365
+ ArgumentNullException . ThrowIfNull ( points ) ;
366
+
353
367
fixed ( PointF * p = points )
354
368
{
355
369
Gdip . CheckStatus ( Gdip . GdipAddPathBeziers ( new HandleRef ( this , _nativePath ) , p , points . Length ) ) ;
@@ -368,8 +382,10 @@ public void AddBezier(int x1, int y1, int x2, int y2, int x3, int y3, int x4, in
368
382
x1 , y1 , x2 , y2 , x3 , y3 , x4 , y4 ) ) ;
369
383
}
370
384
371
- public unsafe void AddBeziers ( params Point [ ] points ! ! )
385
+ public unsafe void AddBeziers ( params Point [ ] points )
372
386
{
387
+ ArgumentNullException . ThrowIfNull ( points ) ;
388
+
373
389
if ( points . Length == 0 )
374
390
return ;
375
391
@@ -382,16 +398,20 @@ public unsafe void AddBeziers(params Point[] points!!)
382
398
/// <summary>
383
399
/// Add cardinal splines to the path object
384
400
/// </summary>
385
- public unsafe void AddCurve ( PointF [ ] points ! ! )
401
+ public unsafe void AddCurve ( PointF [ ] points )
386
402
{
403
+ ArgumentNullException . ThrowIfNull ( points ) ;
404
+
387
405
fixed ( PointF * p = points )
388
406
{
389
407
Gdip . CheckStatus ( Gdip . GdipAddPathCurve ( new HandleRef ( this , _nativePath ) , p , points . Length ) ) ;
390
408
}
391
409
}
392
410
393
- public unsafe void AddCurve ( PointF [ ] points ! ! , float tension )
411
+ public unsafe void AddCurve ( PointF [ ] points , float tension )
394
412
{
413
+ ArgumentNullException . ThrowIfNull ( points ) ;
414
+
395
415
if ( points . Length == 0 )
396
416
return ;
397
417
@@ -401,68 +421,84 @@ public unsafe void AddCurve(PointF[] points!!, float tension)
401
421
}
402
422
}
403
423
404
- public unsafe void AddCurve ( PointF [ ] points ! ! , int offset , int numberOfSegments , float tension )
424
+ public unsafe void AddCurve ( PointF [ ] points , int offset , int numberOfSegments , float tension )
405
425
{
426
+ ArgumentNullException . ThrowIfNull ( points ) ;
427
+
406
428
fixed ( PointF * p = points )
407
429
{
408
430
Gdip . CheckStatus ( Gdip . GdipAddPathCurve3 (
409
431
new HandleRef ( this , _nativePath ) , p , points . Length , offset , numberOfSegments , tension ) ) ;
410
432
}
411
433
}
412
434
413
- public unsafe void AddCurve ( Point [ ] points ! ! )
435
+ public unsafe void AddCurve ( Point [ ] points )
414
436
{
437
+ ArgumentNullException . ThrowIfNull ( points ) ;
438
+
415
439
fixed ( Point * p = points )
416
440
{
417
441
Gdip . CheckStatus ( Gdip . GdipAddPathCurveI ( new HandleRef ( this , _nativePath ) , p , points . Length ) ) ;
418
442
}
419
443
}
420
444
421
- public unsafe void AddCurve ( Point [ ] points ! ! , float tension )
445
+ public unsafe void AddCurve ( Point [ ] points , float tension )
422
446
{
447
+ ArgumentNullException . ThrowIfNull ( points ) ;
448
+
423
449
fixed ( Point * p = points )
424
450
{
425
451
Gdip . CheckStatus ( Gdip . GdipAddPathCurve2I (
426
452
new HandleRef ( this , _nativePath ) , p , points . Length , tension ) ) ;
427
453
}
428
454
}
429
455
430
- public unsafe void AddCurve ( Point [ ] points ! ! , int offset , int numberOfSegments , float tension )
456
+ public unsafe void AddCurve ( Point [ ] points , int offset , int numberOfSegments , float tension )
431
457
{
458
+ ArgumentNullException . ThrowIfNull ( points ) ;
459
+
432
460
fixed ( Point * p = points )
433
461
{
434
462
Gdip . CheckStatus ( Gdip . GdipAddPathCurve3I (
435
463
new HandleRef ( this , _nativePath ) , p , points . Length , offset , numberOfSegments , tension ) ) ;
436
464
}
437
465
}
438
466
439
- public unsafe void AddClosedCurve ( PointF [ ] points ! ! )
467
+ public unsafe void AddClosedCurve ( PointF [ ] points )
440
468
{
469
+ ArgumentNullException . ThrowIfNull ( points ) ;
470
+
441
471
fixed ( PointF * p = points )
442
472
{
443
473
Gdip . CheckStatus ( Gdip . GdipAddPathClosedCurve (
444
474
new HandleRef ( this , _nativePath ) , p , points . Length ) ) ;
445
475
}
446
476
}
447
477
448
- public unsafe void AddClosedCurve ( PointF [ ] points ! ! , float tension )
478
+ public unsafe void AddClosedCurve ( PointF [ ] points , float tension )
449
479
{
480
+ ArgumentNullException . ThrowIfNull ( points ) ;
481
+
450
482
fixed ( PointF * p = points )
451
483
{
452
484
Gdip . CheckStatus ( Gdip . GdipAddPathClosedCurve2 ( new HandleRef ( this , _nativePath ) , p , points . Length , tension ) ) ;
453
485
}
454
486
}
455
487
456
- public unsafe void AddClosedCurve ( Point [ ] points ! ! )
488
+ public unsafe void AddClosedCurve ( Point [ ] points )
457
489
{
490
+ ArgumentNullException . ThrowIfNull ( points ) ;
491
+
458
492
fixed ( Point * p = points )
459
493
{
460
494
Gdip . CheckStatus ( Gdip . GdipAddPathClosedCurveI ( new HandleRef ( this , _nativePath ) , p , points . Length ) ) ;
461
495
}
462
496
}
463
497
464
- public unsafe void AddClosedCurve ( Point [ ] points ! ! , float tension )
498
+ public unsafe void AddClosedCurve ( Point [ ] points , float tension )
465
499
{
500
+ ArgumentNullException . ThrowIfNull ( points ) ;
501
+
466
502
fixed ( Point * p = points )
467
503
{
468
504
Gdip . CheckStatus ( Gdip . GdipAddPathClosedCurve2I ( new HandleRef ( this , _nativePath ) , p , points . Length , tension ) ) ;
@@ -476,8 +512,10 @@ public void AddRectangle(RectangleF rect)
476
512
rect . X , rect . Y , rect . Width , rect . Height ) ) ;
477
513
}
478
514
479
- public unsafe void AddRectangles ( RectangleF [ ] rects ! ! )
515
+ public unsafe void AddRectangles ( RectangleF [ ] rects )
480
516
{
517
+ ArgumentNullException . ThrowIfNull ( rects ) ;
518
+
481
519
if ( rects . Length == 0 )
482
520
throw new ArgumentException ( null , nameof ( rects ) ) ;
483
521
@@ -495,8 +533,10 @@ public void AddRectangle(Rectangle rect)
495
533
rect . X , rect . Y , rect . Width , rect . Height ) ) ;
496
534
}
497
535
498
- public unsafe void AddRectangles ( Rectangle [ ] rects ! ! )
536
+ public unsafe void AddRectangles ( Rectangle [ ] rects )
499
537
{
538
+ ArgumentNullException . ThrowIfNull ( rects ) ;
539
+
500
540
if ( rects . Length == 0 )
501
541
throw new ArgumentException ( null , nameof ( rects ) ) ;
502
542
@@ -547,8 +587,10 @@ public void AddPie(int x, int y, int width, int height, float startAngle, float
547
587
sweepAngle ) ) ;
548
588
}
549
589
550
- public unsafe void AddPolygon ( PointF [ ] points ! ! )
590
+ public unsafe void AddPolygon ( PointF [ ] points )
551
591
{
592
+ ArgumentNullException . ThrowIfNull ( points ) ;
593
+
552
594
fixed ( PointF * p = points )
553
595
{
554
596
Gdip . CheckStatus ( Gdip . GdipAddPathPolygon ( new HandleRef ( this , _nativePath ) , p , points . Length ) ) ;
@@ -558,16 +600,20 @@ public unsafe void AddPolygon(PointF[] points!!)
558
600
/// <summary>
559
601
/// Adds a polygon to the current figure.
560
602
/// </summary>
561
- public unsafe void AddPolygon ( Point [ ] points ! ! )
603
+ public unsafe void AddPolygon ( Point [ ] points )
562
604
{
605
+ ArgumentNullException . ThrowIfNull ( points ) ;
606
+
563
607
fixed ( Point * p = points )
564
608
{
565
609
Gdip . CheckStatus ( Gdip . GdipAddPathPolygonI ( new HandleRef ( this , _nativePath ) , p , points . Length ) ) ;
566
610
}
567
611
}
568
612
569
- public void AddPath ( GraphicsPath addingPath ! ! , bool connect )
613
+ public void AddPath ( GraphicsPath addingPath , bool connect )
570
614
{
615
+ ArgumentNullException . ThrowIfNull ( addingPath ) ;
616
+
571
617
Gdip . CheckStatus ( Gdip . GdipAddPathPath (
572
618
new HandleRef ( this , _nativePath ) , new HandleRef ( addingPath , addingPath . _nativePath ) , connect ) ) ;
573
619
}
@@ -582,8 +628,10 @@ public void AddString(string s, FontFamily family, int style, float emSize, Poin
582
628
AddString ( s , family , style , emSize , new Rectangle ( origin . X , origin . Y , 0 , 0 ) , format ) ;
583
629
}
584
630
585
- public void AddString ( string s , FontFamily family ! ! , int style , float emSize , RectangleF layoutRect , StringFormat ? format )
631
+ public void AddString ( string s , FontFamily family , int style , float emSize , RectangleF layoutRect , StringFormat ? format )
586
632
{
633
+ ArgumentNullException . ThrowIfNull ( family ) ;
634
+
587
635
Gdip . CheckStatus ( Gdip . GdipAddPathString (
588
636
new HandleRef ( this , _nativePath ) ,
589
637
s ,
@@ -595,8 +643,10 @@ public void AddString(string s, FontFamily family!!, int style, float emSize, Re
595
643
new HandleRef ( format , format ? . nativeFormat ?? IntPtr . Zero ) ) ) ;
596
644
}
597
645
598
- public void AddString ( string s , FontFamily family ! ! , int style , float emSize , Rectangle layoutRect , StringFormat ? format )
646
+ public void AddString ( string s , FontFamily family , int style , float emSize , Rectangle layoutRect , StringFormat ? format )
599
647
{
648
+ ArgumentNullException . ThrowIfNull ( family ) ;
649
+
600
650
Gdip . CheckStatus ( Gdip . GdipAddPathStringI (
601
651
new HandleRef ( this , _nativePath ) ,
602
652
s ,
@@ -608,8 +658,10 @@ public void AddString(string s, FontFamily family!!, int style, float emSize, Re
608
658
new HandleRef ( format , format ? . nativeFormat ?? IntPtr . Zero ) ) ) ;
609
659
}
610
660
611
- public void Transform ( Matrix matrix ! ! )
661
+ public void Transform ( Matrix matrix )
612
662
{
663
+ ArgumentNullException . ThrowIfNull ( matrix ) ;
664
+
613
665
if ( matrix . NativeMatrix == IntPtr . Zero )
614
666
return ;
615
667
@@ -649,8 +701,10 @@ public void Flatten(Matrix? matrix, float flatness)
649
701
650
702
public void Widen ( Pen pen , Matrix ? matrix ) => Widen ( pen , matrix , Flatness ) ;
651
703
652
- public void Widen ( Pen pen ! ! , Matrix ? matrix , float flatness )
704
+ public void Widen ( Pen pen , Matrix ? matrix , float flatness )
653
705
{
706
+ ArgumentNullException . ThrowIfNull ( pen ) ;
707
+
654
708
// GDI+ wrongly returns an out of memory status when there is nothing in the path, so we have to check
655
709
// before calling the widen method and do nothing if we dont have anything in the path.
656
710
if ( PointCount == 0 )
@@ -672,8 +726,10 @@ public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix? matrix, WarpMo
672
726
Warp ( destPoints , srcRect , matrix , warpMode , 0.25f ) ;
673
727
}
674
728
675
- public unsafe void Warp ( PointF [ ] destPoints ! ! , RectangleF srcRect , Matrix ? matrix , WarpMode warpMode , float flatness )
729
+ public unsafe void Warp ( PointF [ ] destPoints , RectangleF srcRect , Matrix ? matrix , WarpMode warpMode , float flatness )
676
730
{
731
+ ArgumentNullException . ThrowIfNull ( destPoints ) ;
732
+
677
733
fixed ( PointF * p = destPoints )
678
734
{
679
735
Gdip . CheckStatus ( Gdip . GdipWarpPath (
0 commit comments