在 .NET Standard/Core 中获取构造函数列表的等价物是什么?

What's the equivalent for getting the list of constructors in .NET Standard / Core?

我正在尝试将我的 .NET 4 项目升级到 .NETStandard 和 Core,但找不到相应的项目:-

        var ctors = typeof(T).GetConstructors();

GetConstructors 是反射的一部分,因此似乎是故意缺少或移动支持...

谢谢。 西蒙.

在 .NET 标准/Core 中,很多反射 api 被移动到特定的包 (system.reflection)。这个包在类型 class.

上提供扩展方法 GetTypeInfo
typeof(T).GetTypeInfo().DeclaredConstructors;

很简单 - 只需添加 GetTypeInfo():

var ctors = typeof(T).GetTypeInfo().DeclaredConstructors();