11// Licensed to the .NET Foundation under one or more agreements.
22// The .NET Foundation licenses this file to you under the MIT license.
33
4+ using System . ComponentModel . Design ;
45using System . Diagnostics . CodeAnalysis ;
56
67namespace System . ComponentModel
@@ -16,10 +17,12 @@ public class ToolboxItemAttribute : Attribute
1617 [ DynamicallyAccessedMembers ( DynamicallyAccessedMemberTypes . PublicConstructors ) ]
1718 private readonly string ? _toolboxItemTypeName ;
1819
20+ private const string DefaultToolboxItemTypeName = "System.Drawing.Design.ToolboxItem, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" ;
21+
1922 /// <summary>
2023 /// Initializes a new instance of ToolboxItemAttribute and sets the type to
2124 /// </summary>
22- public static readonly ToolboxItemAttribute Default = new ToolboxItemAttribute ( "System.Drawing.Design.ToolboxItem, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" ) ;
25+ public static readonly ToolboxItemAttribute Default = new ToolboxItemAttribute ( DefaultToolboxItemTypeName ) ;
2326
2427 /// <summary>
2528 /// Initializes a new instance of ToolboxItemAttribute and sets the type to
@@ -30,7 +33,7 @@ public class ToolboxItemAttribute : Attribute
3033 /// <summary>
3134 /// Gets whether the attribute is the default attribute.
3235 /// </summary>
33- public override bool IsDefaultAttribute ( ) => Equals ( Default ) ;
36+ public override bool IsDefaultAttribute ( ) => _toolboxItemTypeName == DefaultToolboxItemTypeName ;
3437
3538 /// <summary>
3639 /// Initializes a new instance of ToolboxItemAttribute and specifies if default values should be used.
@@ -39,7 +42,12 @@ public ToolboxItemAttribute(bool defaultType)
3942 {
4043 if ( defaultType )
4144 {
42- _toolboxItemTypeName = "System.Drawing.Design.ToolboxItem, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" ;
45+ if ( ! IDesignerHost . IsSupported )
46+ {
47+ throw new NotSupportedException ( SR . IDesignerHostNotSupported ) ;
48+ }
49+
50+ _toolboxItemTypeName = DefaultToolboxItemTypeName ;
4351 }
4452 }
4553
0 commit comments