Vector<T> always throws NotSupportedException for unsupported types

System.Numerics.Vector<T> now always throws a NotSupportedException for unsupported type parameters.

Change description

Previously, members of Vector<T> would not always throw a NotSupportedException when T was an unsupported type. The exception wasn't always thrown because of code paths that supported hardware acceleration. For example, Vector<bool> + Vector<bool> returned default instead of throwing an exception on platforms that have no hardware acceleration, such as Arm32. For unsupported types, Vector<T> members exhibited inconsistent behavior across different platforms and hardware configurations.

Starting in .NET 5, Vector<T> members always throw a NotSupportedException on all hardware configurations when T is not a supported type.

Unsupported types

The supported types for the type parameter of Vector<T> are:

  • byte
  • sbyte
  • short
  • ushort
  • int
  • uint
  • long
  • ulong
  • float
  • double

The supported types have not changed, however, they may change in the future.

Version introduced

5.0

Don't use an unsupported type for the type parameter of Vector<T>.

Affected APIs