.NET内省VS反射
时间:2020-03-05 18:56:14 来源:igfitidea点击:
.NET中的内省和反射有什么区别
解决方案
回答
它们是同一整体的两个部分。
自省是指类具有在自身内部"看"并查看例如方法所采用的参数,其成员的名称等的能力。
反射是.NET如何实现自省的特定名称。其他语言可能将其称为不同的东西(对于运行时类型信息,C ++称之为有限的自省RTTI)。
回答
自2004年以来,FxCop引入了自省功能,以代替反射功能:
What's new in FxCop 1.30 is that it now performs analysis through a technique called Introspection. The use of the Introspection engine allows for much faster analysis and supports multithreaded analysis. Unlike the Reflection engine from previous versions, in the Introspection engine the assemblies you're analyzing are not locked so you won't need to shut down FxCop to do a fix and recompile of those assemblies. Finally, the Introspection engine offers a much richer analysis infrastructure compared to the Reflection engine.