< Summary - PropertyGridHelpers Code Coverage

Information
Class: PropertyGridHelpers.Attributes.LocalizedDisplayNameAttribute
Assembly: PropertyGridHelpers
File(s): c:\agent\_work\9\s\Code\PropertyGridHelpers\Attributes\LocalizedDisplayNameAttribute.cs
Tag: PropertyGridHelpers Build_2025.7.15.1_#485
Line coverage
100%
Covered lines: 8
Uncovered lines: 0
Coverable lines: 8
Total lines: 97
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBlocks covered Blocks not covered Branch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)--100%11100%
LocalizedDisplayNameAttribute(...)20----
Get(...)100100%66100%

File(s)

c:\agent\_work\9\s\Code\PropertyGridHelpers\Attributes\LocalizedDisplayNameAttribute.cs

#LineLine coverage
 1using System;
 2using System.ComponentModel;
 3
 4namespace PropertyGridHelpers.Attributes
 5{
 6#if NET8_0_OR_GREATER
 7    /// <summary>
 8    /// Specifies a localized display name for a property, event, or other
 9    /// member in a class.
 10    /// </summary>
 11    /// <seealso cref="LocalizedTextAttribute" />
 12    /// <param name="resourceKey">The key identifying the localized string in the resource file.</param>
 13    /// <remarks>
 14    /// Initializes a new instance of the <see cref="LocalizedDisplayNameAttribute" /> class.
 15    /// </remarks>
 16    /// <example>
 17    ///   <code language="csharp">
 18    ///       [ResourcePath(nameof(TestControl))]
 19    ///       [TypeDescriptionProvider(typeof(LocalizedTypeDescriptionProvider))]
 20    ///       public partial class TestControl : UserControl
 21    ///       {
 22    ///           [LocalizedCategory("Category_Layout")]
 23    ///           [LocalizedDescription("Description_Scrollbar")]
 24    ///           [LocalizedDisplayName("DisplayName_Scrollbar")]
 25    ///           [Editor(typeof(FlagEnumUIEditor&lt;EnumTextConverter&lt;ScrollBars&gt;&gt;), typeof(UITypeEditor))]
 26    ///           [TypeConverter(typeof(EnumTextConverter&lt;ScrollBars&gt;))]
 27    ///           [DefaultValue(ScrollBars.None)]
 28    ///           [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
 29    ///           [EditorBrowsable(EditorBrowsableState.Always)]
 30    ///           [Bindable(true)]
 31    ///           public ScrollBars Scrollbars
 32    ///           {
 33    ///               get => _Scrollbars;
 34    ///               set => _Scrollbars = value;
 35    ///           }
 36    ///       }
 37    ///   </code>
 38    /// </example>
 39    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Method, AllowMultiple = false)
 2440    public class LocalizedDisplayNameAttribute(string resourceKey) : LocalizedTextAttribute(resourceKey)
 41    {
 42#else
 43    /// <summary>
 44    /// Specifies a localized display name for a property, event, or other
 45    /// member in a class.
 46    /// </summary>
 47    /// <seealso cref="LocalizedTextAttribute" />
 48    /// <remarks>
 49    /// Initializes a new instance of the <see cref="LocalizedDisplayNameAttribute" /> class.
 50    /// </remarks>
 51    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Method, AllowMultiple = false)
 52    public class LocalizedDisplayNameAttribute : LocalizedTextAttribute
 53    {
 54        /// <summary>
 55        /// Initializes a new instance of the <see cref="LocalizedDisplayNameAttribute" /> class.
 56        /// </summary>
 57        /// <param name="resourceKey">The key identifying the localized string in the resource file.</param>
 58        /// <example>
 59        ///   <code language="csharp">
 60        ///       [ResourcePath(nameof(TestControl))]
 61        ///       [TypeDescriptionProvider(typeof(LocalizedTypeDescriptionProvider))]
 62        ///       public partial class TestControl : UserControl
 63        ///       {
 64        ///           [LocalizedCategory("Category_Layout")]
 65        ///           [LocalizedDescription("Description_Scrollbar")]
 66        ///           [LocalizedDisplayName("DisplayName_Scrollbar")]
 67        ///           [Editor(typeof(FlagEnumUIEditor&lt;EnumTextConverter&lt;ScrollBars&gt;&gt;), typeof(UITypeEditor))
 68        ///           [TypeConverter(typeof(EnumTextConverter&lt;ScrollBars&gt;))]
 69        ///           [DefaultValue(ScrollBars.None)]
 70        ///           [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
 71        ///           [EditorBrowsable(EditorBrowsableState.Always)]
 72        ///           [Bindable(true)]
 73        ///           public ScrollBars Scrollbars
 74        ///           {
 75        ///               get => _Scrollbars;
 76        ///               set => _Scrollbars = value;
 77        ///           }
 78        ///       }
 79        ///   </code>
 80        /// </example>
 1681        public LocalizedDisplayNameAttribute(string resourceKey) : base(resourceKey)
 882        {
 1683        }
 84#endif
 85
 86        /// <summary>
 87        /// Gets the <see cref="LocalizedDisplayNameAttribute"/> from the specified context.
 88        /// </summary>
 89        /// <param name="context">The context.</param>
 90        /// <returns></returns>
 91        public static new LocalizedDisplayNameAttribute Get(ITypeDescriptorContext context) =>
 2892            context == null || context.Instance == null || context.PropertyDescriptor == null
 2893                ? null
 2894                : Support.Support.GetFirstCustomAttribute<LocalizedDisplayNameAttribute>(
 2895                    Support.Support.GetPropertyInfo(context));
 96    }
 97}