< Summary - PropertyGridHelpers Code Coverage

Information
Class: PropertyGridHelpers.TypeDescriptors.LocalizedTypeDescriptor
Assembly: PropertyGridHelpers
File(s): c:\agent\_work\9\s\Code\PropertyGridHelpers\TypeDescriptors\LocalizedTypeDescriptor.cs
Tag: PropertyGridHelpers Build_2025.7.15.1_#485
Line coverage
100%
Covered lines: 10
Uncovered lines: 0
Coverable lines: 10
Total lines: 62
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
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%
LocalizedTypeDescriptor(...)20----
GetProperties()20100%11100%
GetProperties(...)110100%22100%
GetProperties(...)100----

File(s)

c:\agent\_work\9\s\Code\PropertyGridHelpers\TypeDescriptors\LocalizedTypeDescriptor.cs

#LineLine coverage
 1using PropertyGridHelpers.PropertyDescriptors;
 2using System;
 3using System.ComponentModel;
 4
 5namespace PropertyGridHelpers.TypeDescriptors
 6{
 7#if NET8_0_OR_GREATER
 8    /// <summary>
 9    /// A type descriptor that provides localization for property names, categories, and descriptions.
 10    /// </summary>
 11    /// <param name="parent">
 12    /// The parent <see cref="ICustomTypeDescriptor"/> to wrap.
 13    /// </param>
 14    /// <seealso cref="CustomTypeDescriptor"/>
 1615    public class LocalizedTypeDescriptor(ICustomTypeDescriptor parent) : CustomTypeDescriptor(parent)
 16    {
 17#else
 18    /// <summary>
 19    /// A type descriptor that provides localization for property names, categories, and descriptions.
 20    /// </summary>
 21    /// <seealso cref="CustomTypeDescriptor"/>
 22    public class LocalizedTypeDescriptor : CustomTypeDescriptor
 23    {
 24        /// <summary>
 25        /// Initializes a new instance of the <see cref="LocalizedTypeDescriptor"/> class.
 26        /// </summary>
 27        /// <param name="parent">
 28        /// The parent <see cref="ICustomTypeDescriptor"/> to wrap.
 29        /// </param>
 30        public LocalizedTypeDescriptor(ICustomTypeDescriptor parent)
 1631            : base(parent) { }
 32#endif
 33
 34        /// <summary>
 35        /// Returns the collection of properties for the current object, using the default attributes.
 36        /// </summary>
 37        /// <returns>
 38        /// A <see cref="PropertyDescriptorCollection"/> containing the localized properties.
 39        /// </returns>
 2040        public override PropertyDescriptorCollection GetProperties() => GetProperties(null);
 41
 42        /// <summary>
 43        /// Returns the collection of properties for the current object that match the specified attributes,
 44        /// with each property descriptor decorated to support localization.
 45        /// </summary>
 46        /// <param name="attributes">
 47        /// An array of attributes to use as a filter. Only properties marked with one or more of these
 48        /// attributes will be included in the result.
 49        /// </param>
 50        /// <returns>
 51        /// A <see cref="PropertyDescriptorCollection"/> containing the filtered and localized properties.
 52        /// </returns>
 53        public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
 1654        {
 2455            var baseProps = base.GetProperties(attributes);
 2456            var newProps = new PropertyDescriptor[baseProps.Count];
 6457            for (var i = 0; i < baseProps.Count; i++)
 3258                newProps[i] = new LocalizedPropertyDescriptor(baseProps[i]);
 2459            return new PropertyDescriptorCollection(newProps);
 1660        }
 61    }
 62}