< Summary - PropertyGridHelpers Code Coverage

Information
Class: PropertyGridHelpers.UIEditors.CollectionUIEditor<T>
Assembly: PropertyGridHelpers
File(s): c:\agent\_work\9\s\Code\PropertyGridHelpers\UIEditors\CollectionUIEditor.cs
Tag: PropertyGridHelpers Build_2025.7.15.1_#485
Line coverage
100%
Covered lines: 4
Uncovered lines: 0
Coverable lines: 4
Total lines: 45
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
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
CollectionUIEditor()30
CreateInstance(...)70

File(s)

c:\agent\_work\9\s\Code\PropertyGridHelpers\UIEditors\CollectionUIEditor.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.ComponentModel.Design;
 4
 5namespace PropertyGridHelpers.UIEditors
 6{
 7    /// <summary>
 8    /// Provides a strongly-typed collection editor for editing <see cref="List{T}"/> properties
 9    /// in a <see cref="System.Windows.Forms.PropertyGrid"/>.
 10    /// This allows users to add, remove, and edit items of type <typeparamref name="T"/>
 11    /// using the standard collection editor dialog.
 12    /// </summary>
 13    /// <typeparam name="T">The type of the items in the collection being edited.</typeparam>
 14    /// <seealso cref="CollectionEditor"/>
 15    /// <remarks>
 16    /// This editor automatically uses a <see cref="List{T}"/> as the collection type,
 17    /// and supports simple creation of string elements or any other type with a
 18    /// parameterless constructor.
 19    /// </remarks>
 20    public class CollectionUIEditor<T> : CollectionEditor
 21    {
 22        /// <summary>
 23        /// Initializes a new instance of the <see cref="CollectionUIEditor{T}"/> class,
 24        /// targeting collections of type <see cref="List{T}"/>.
 25        /// </summary>
 1626        public CollectionUIEditor() : base(type: typeof(List<T>))
 827        {
 28
 1629        }
 30
 31        /// <summary>
 32        /// Creates a new instance of the specified <paramref name="itemType"/> to add to the collection.
 33        /// </summary>
 34        /// <param name="itemType">The type of the item to create.</param>
 35        /// <returns>
 36        /// A new instance of <paramref name="itemType"/>. For strings, an empty string is returned.
 37        /// </returns>
 38        /// <remarks>
 39        /// This override ensures that <c>string</c> elements are initialized to an empty value,
 40        /// while other types use their parameterless constructor.
 41        /// </remarks>
 42        protected override object CreateInstance(Type itemType) =>
 1643            itemType == typeof(string) ? string.Empty : (object)Activator.CreateInstance(itemType);
 44    }
 45}