Skip to content

[Breaking change] Type.MakeGenericSignatureType argument validation #48902

@jkotas

Description

@jkotas

Description

Starting in .NET 10 Preview 3, Type.MakeGenericSignatureType API validates that the genericTypeDefinition argument is in fact a generic type definition.

Version

.NET 10 Preview 3

Previous behavior

Type.MakeGenericSignatureType accepted any type for the genericTypeDefinition argument.

New behavior

Type.MakeGenericSignatureType requires genericTypeDefinition argument to be a generic type definition and throws ArgumentException otherwise.

Type of breaking change

  • Behavioral change: Existing binaries might behave differently at runtime.

Reason for change

The type created by Type.MakeGenericSignatureType had non-sensical behavior when the genericTypeDefinition argument was not a generic type definition.

Recommended action

Avoid calling Type.MakeGenericSignatureType for types that are not generic type definitions. For example:

// Before
Type instantiatedType = Type.MakeGenericSignatureType(originalType, instantiation);

// After
Type instantiatedType = originalType.IsGenericTypeDefinition ? Type.MakeGenericSignatureType(originalType, instantiation) : originalType;

Affected APIs

  • System.Type.MakeGenericSignatureType

Metadata

Metadata

Assignees

Labels

🗺️ reQUESTTriggers an issue to be imported into Quest.breaking-changeIndicates a .NET Core breaking change

Type

No type

Projects

Status

🔖 Ready

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions