Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion src/System.Drawing.Common/src/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,32 @@
<Left>lib/netstandard2.0/System.Drawing.Common.dll</Left>
<Right>lib/net462/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0015</DiagnosticId>
<Target>P:System.Drawing.Image.Height:[T:System.ComponentModel.DefaultValueAttribute]</Target>
<Left>lib/net10.0/System.Drawing.Common.dll</Left>
<Right>lib/net10.0/System.Drawing.Common.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0015</DiagnosticId>
<Target>P:System.Drawing.Image.Width:[T:System.ComponentModel.DefaultValueAttribute]</Target>
<Left>lib/net10.0/System.Drawing.Common.dll</Left>
<Right>lib/net10.0/System.Drawing.Common.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0015</DiagnosticId>
<Target>P:System.Drawing.Image.Height:[T:System.ComponentModel.DefaultValueAttribute]</Target>
<Left>lib/netstandard2.0/System.Drawing.Common.dll</Left>
<Right>lib/net10.0/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0015</DiagnosticId>
<Target>P:System.Drawing.Image.Width:[T:System.ComponentModel.DefaultValueAttribute]</Target>
<Left>lib/netstandard2.0/System.Drawing.Common.dll</Left>
<Right>lib/net10.0/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0015</DiagnosticId>
<Target>P:System.Drawing.Font.Name:[T:System.ComponentModel.EditorAttribute]</Target>
Expand Down Expand Up @@ -67,4 +93,4 @@
<Left>lib/netstandard2.0/System.Drawing.Common.dll</Left>
<Right>lib/net462/System.Drawing.Common.dll</Right>
</Suppression>
</Suppressions>
</Suppressions>
4 changes: 2 additions & 2 deletions src/System.Drawing.Common/src/System/Drawing/Image.cs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ public SizeF PhysicalDimension
/// <summary>
/// Gets the width of this <see cref='Image'/>.
/// </summary>
[DefaultValue(false)]
[DefaultValue(0)]
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public int Width
Expand All @@ -440,7 +440,7 @@ public int Width
/// <summary>
/// Gets the height of this <see cref='Image'/>.
/// </summary>
[DefaultValue(false)]
[DefaultValue(0)]
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public int Height
Expand Down
14 changes: 14 additions & 0 deletions src/System.Drawing.Common/tests/System/Drawing/ImageTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.ComponentModel;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
using System.Text;
Expand All @@ -19,6 +20,19 @@ public class ImageTests
private const int PropertyTagTypeASCII = 2;
private const int PropertyTagTypeShort = 3;

[Theory]
[InlineData(nameof(Image.Width))]
[InlineData(nameof(Image.Height))]
public void ImageDimensionProperty_DefaultValueIsZero(string propertyName)
{
PropertyDescriptor? property = TypeDescriptor.GetProperties(typeof(Image))[propertyName];
Assert.NotNull(property);

DefaultValueAttribute defaultValue = Assert.IsType<DefaultValueAttribute>(
property.Attributes[typeof(DefaultValueAttribute)]);
Assert.Equal(0, defaultValue.Value);
}

[Fact]
public void PropertyIdList_GetBitmapJpg_Success()
{
Expand Down