[System.Drawing.Common] Fix argument name in exception of Bitmap constructor (dotnet...
authorFilip Navara <filip.navara@gmail.com>
Thu, 3 Oct 2019 17:59:55 +0000 (19:59 +0200)
committerSantiago Fernandez Madero <safern@microsoft.com>
Thu, 3 Oct 2019 17:59:55 +0000 (10:59 -0700)
* [System.Drawing.Common] Fix argument name in exception of Bitmap constructor

* Fix test for NetFX

Commit migrated from https://github.com/dotnet/corefx/commit/78c2b959d814fffd2345d056576fe417a9405751

src/libraries/System.Drawing.Common/src/System/Drawing/Bitmap.cs
src/libraries/System.Drawing.Common/tests/BitmapTests.cs

index e6e3fe1..4a050cc 100644 (file)
@@ -96,6 +96,9 @@ namespace System.Drawing
 
         public Bitmap(Image original, int width, int height) : this(width, height, PixelFormat.Format32bppArgb)
         {
+            if (original == null)
+                throw new ArgumentNullException(nameof(original));
+
             using (Graphics g = Graphics.FromImage(this))
             {
                 g.Clear(Color.Transparent);
index 77e387e..85e2f7e 100644 (file)
@@ -377,8 +377,8 @@ namespace System.Drawing.Tests
         [ConditionalFact(Helpers.IsDrawingSupported)]
         public void Ctor_NullImageWithSize_ThrowsArgumentNullException()
         {
-            AssertExtensions.Throws<ArgumentNullException>("image", () => new Bitmap(null, new Size(1, 2)));
-            AssertExtensions.Throws<ArgumentNullException>("image", () => new Bitmap(null, 1, 2));
+            AssertExtensions.Throws<ArgumentNullException>("original", "image", () => new Bitmap(null, new Size(1, 2)));
+            AssertExtensions.Throws<ArgumentNullException>("original", "image", () => new Bitmap(null, 1, 2));
         }
 
         [ConditionalFact(Helpers.IsDrawingSupported)]