Description
Creating System.Type instance for array of System.Void is no longer allowed.
Version
.NET 9 Preview 1
Previous behavior
typeof(void).MakeArrayType() returned System.Type instance.
New behavior
typeof(void).MakeArrayType() throws an exception.
Type of breaking change
Reason for change
Array of System.Void is an invalid type. This type is rejected in number of situations (e.g. void[] in C# does not compile) and it is not possible to create arrays of this type.
.NET runtimes allowed this invalid type to be created in some situations. However, attempts to use this invalid type lead in other .NET runtime APIs often lead to unexpected behaviors. It is better to disallow creating these invalid array types in all situations to make the behavior robust and consistent.
Recommended action
Remove code that tries to create a type for array of System.Void.
Feature area
Core .NET libraries
Affected APIs
System.Type.MakeArrayType
Associated WorkItem - 196554
Description
Creating System.Type instance for array of System.Void is no longer allowed.
Version
.NET 9 Preview 1
Previous behavior
typeof(void).MakeArrayType()returned System.Type instance.New behavior
typeof(void).MakeArrayType()throws an exception.Type of breaking change
Reason for change
Array of System.Void is an invalid type. This type is rejected in number of situations (e.g.
void[]in C# does not compile) and it is not possible to create arrays of this type..NET runtimes allowed this invalid type to be created in some situations. However, attempts to use this invalid type lead in other .NET runtime APIs often lead to unexpected behaviors. It is better to disallow creating these invalid array types in all situations to make the behavior robust and consistent.
Recommended action
Remove code that tries to create a type for array of System.Void.
Feature area
Core .NET libraries
Affected APIs
System.Type.MakeArrayType
Associated WorkItem - 196554