问题描述
我需要类似于 PropertyInfo.ReflectedType
在完整框架中所做的事情.
I need something like what PropertyInfo.ReflectedType
does in the full framework.
目前我无法弄清楚什么可以替代 PropertyInfo
的整个属性.
For now I've been not able to figure out what can be the alternative to the whole property of PropertyInfo
.
推荐答案
ReflectedType 在 .NET Core 中不受支持,正如微软的人所说,它被有意排除".这个 github 上的问题 包含一个博客链接,该链接解释了原因,但现在已损坏...
ReflectedType is not supported in .NET Core and was "intentionally excluded" as guys from Microsoft says. This question on github contains a link to blog that explains the reason but is broken right now...
您可以查看像 Nunit 这样的 PR.消除使用 ReflectedType 为 ASP .Net 5 支持做准备 或 AutoFixture.支持 CoreCLR 以获得如何调整代码的想法.通常,有效的解决方案是删除所有 ReflectedType
属性的使用,而是保留并使用对获取该类型的对象(反射对象)的引用.
You may look on PRs like Nunit. Eliminate use of ReflectedType in preparation for ASP .Net 5 support or AutoFixture. Support for CoreCLR to get ideas how to adapt your code. In general, the working solution is to remove all using of ReflectedType
property and instead hold and use the reference to the the object for which the type was got (reflected object).
这篇关于.NET Core/.NET Standard 中 PropertyInfo.ReflectedType 的等价物是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!