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

Add nullability to CreateInstance in TypeDescriptor/TypeDescriptionProvider to match Activator.CreateInstance #79776

Merged
merged 4 commits into from
Jan 3, 2023
Merged

Conversation

elachlan
Copy link
Contributor

This PR adds nullability to the args parameter of CreateInstance to match Activator.CreateInstance. Thus enabling null to be passed as a parameter to TypeDescriptors.

Related: dotnet/winforms#8353, #79429
Tracking: dotnet/winforms#8342

…onProvider to match Activator.CreateInstance
@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Dec 17, 2022
@ghost
Copy link

ghost commented Dec 17, 2022

Tagging subscribers to this area: @dotnet/area-system-componentmodel
See info in area-owners.md if you want to be subscribed.

Issue Details

This PR adds nullability to the args parameter of CreateInstance to match Activator.CreateInstance. Thus enabling null to be passed as a parameter to TypeDescriptors.

Related: dotnet/winforms#8353, #79429
Tracking: dotnet/winforms#8342

Author: elachlan
Assignees: -
Labels:

area-System.ComponentModel, community-contribution

Milestone: -

@elachlan
Copy link
Contributor Author

CC: @lonitra

@elachlan
Copy link
Contributor Author

elachlan commented Dec 17, 2022

I am unsure if nullability on argTypes is required. but it would make sense if the Type of null is null. argTypes and args are usually kept in sync.

@steveharter
Copy link
Member

Thus enabling null to be passed as a parameter to TypeDescriptors.

This PR appears to fix a nullability mismatch - it should hav always been object?[]?.

@build-analysis build-analysis bot mentioned this pull request Dec 21, 2022
@lonitra
Copy link
Member

lonitra commented Dec 21, 2022

I am unsure if nullability on argTypes is required. but it would make sense if the Type of null is null. argTypes and args are usually kept in sync.

@steveharter what are your thoughts on this? Seems like args and argTypes were meant to be kept in sync so should argTypes also be changed to Type?[]? to allow null when an argument in args is null?

@steveharter
Copy link
Member

I am unsure if nullability on argTypes is required. but it would make sense if the Type of null is null. argTypes and args are usually kept in sync.

@steveharter what are your thoughts on this? Seems like args and argTypes were meant to be kept in sync so should argTypes also be changed to Type?[]? to allow null when an argument in args is null?

In general, for such an API, it seems like a Type instance should always be specified (not null), unless it is unknown or for some reason hard to obtain. I assume that is not the case here, so Type[]? seems correct (not Type?[]?).

@elachlan
Copy link
Contributor Author

That was my thought as well and why I wound back that change. It will also never match a constructor if we pass a null type. Since you can't define a parameter type as null, only nullable.

@elachlan
Copy link
Contributor Author

Are there any changes required to get this merged?

@steveharter steveharter merged commit 8508703 into dotnet:main Jan 3, 2023
@elachlan elachlan deleted the TypeDescriptor-Nullability branch January 8, 2023 23:32
@ghost ghost locked as resolved and limited conversation to collaborators Feb 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.ComponentModel community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants