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
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ internal DelegatingTypeDescriptionProvider(Type type)
IServiceProvider? provider,
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type objectType,
Type[]? argTypes,
object[]? args)
object?[]? args)
{
return Provider.CreateInstance(provider, objectType, argTypes, args);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ internal static void AddEditorTable(Type editorBaseType, Hashtable table)
IServiceProvider? provider,
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type objectType,
Type[]? argTypes,
object[]? args)
object?[]? args)
{
Debug.Assert(objectType != null, "Should have arg-checked before coming in here");

Expand All @@ -277,9 +277,9 @@ internal static void AddEditorTable(Type editorBaseType, Hashtable table)
argTypes = new Type[args.Length];
for (int idx = 0; idx < args.Length; idx++)
{
if (args[idx] != null)
if (args[idx] is object arg)
{
argTypes[idx] = args[idx].GetType();
argTypes[idx] = arg.GetType();
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected TypeDescriptionProvider(TypeDescriptionProvider parent)
IServiceProvider? provider,
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type objectType,
Type[]? argTypes,
object[]? args)
object?[]? args)
{
if (_parent != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public static EventDescriptor CreateEvent(
IServiceProvider? provider,
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type objectType,
Type[]? argTypes,
object[]? args)
object?[]? args)
{
ArgumentNullException.ThrowIfNull(objectType);

Expand Down Expand Up @@ -3015,7 +3015,7 @@ internal TypeDescriptionNode(TypeDescriptionProvider provider)
IServiceProvider? provider,
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type objectType,
Type[]? argTypes,
object[]? args)
object?[]? args)
{
ArgumentNullException.ThrowIfNull(objectType);

Expand Down