Bud*_*Joe 3 .net c# reflection
有没有办法使用反射来完全"扫描"程序集,以查看是否曾使用过System.IO.File或System.IO.Directory?这些只是示例类.只是想知道是否有办法通过反射(vs代码分析)来做到这一点.
更新:见评论
正如汤米卡里尔所说,塞西尔很容易做到.
using Mono.Cecil;
// ..
var assembly = AssemblyFactory.GetAssembly ("Foo.Bar.dll");
var module = assembly.MainModule;
bool references_file = module.TypeReferences.Contains ("System.IO.File");
Run Code Online (Sandbox Code Playgroud)