C#

C#

Made by DeepSource

Rewrite new System.Type[0] as Type.EmptyTypes CS-R1077

Anti-pattern
Major
Autofix

The System.Type class represents classes, interfaces, arrays, enums, and other types. In case you wish to create an empty array whose type is System.Type, consider using Type.EmptyTypes as it is a static, readonly field inside the System.Type class. Doing it this way reduces the number of allocations and exerts less pressure on GC.

Bad Practice

var emptyTypes = new System.Type[0];

Recommended

var emptyTypes = Type.EmptyTypes;

Reference