Skip to content

System.ComponentModel.PropertyDescriptorCollection logic should be consistent about null PropertyDescriptor #55177

Open
@krwq

Description

@krwq

Found during adding nullable annotations to TypeConverter (#54961)

Current logic of PropertyDescriptorCollection is inconsistent about allowing null PropertyDescriptor, i.e.:

  • constructors taking PropertyDescriptor[] do not guard against null values
  • Add, Insert, Remove doesn't have a null check
  • Find if it encounters null property when searching will in many cases throw NRE as it accesses Name without any null checks
  • anything triggering sorting (InternalSort) for non empty collection will most likely throw NRE because it accesses Name without null checks

I've conservatively marked them as non-accepting the null as that will provide most intuitive experience. The solution here is to do one of the following:

  • add null checks and throw on null
  • allow for nulls everywhere

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions