Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
krwq opened this issue Jul 5, 2021 · 1 comment

Comments

@krwq
Copy link
Member

krwq commented Jul 5, 2021

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
@ghost
Copy link

ghost commented Jul 5, 2021

Tagging subscribers to this area: @safern
See info in area-owners.md if you want to be subscribed.

Issue Details

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
Author: krwq
Assignees: -
Labels:

area-System.ComponentModel

Milestone: -

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Jul 5, 2021
@safern safern removed the untriaged New issue has not been triaged by the area owner label Jul 22, 2021
@safern safern added this to the 7.0.0 milestone Jul 22, 2021
@maryamariyan maryamariyan modified the milestones: 7.0.0, Future Jan 14, 2022
@maryamariyan maryamariyan modified the milestones: Future, 7.0.0 Jan 14, 2022
@eerhardt eerhardt modified the milestones: 7.0.0, Future Jul 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants