protected TestListGUI() { MonoCecilHelper = new MonoCecilHelper(); AssetsDatabaseHelper = new AssetsDatabaseHelper(); GuiHelper = new GuiHelper(MonoCecilHelper, AssetsDatabaseHelper); }
public ProjectIssue Analyze(MethodDefinition methodDefinition, Instruction inst) { if (inst.Previous != null) { return(null); } if (!MonoCecilHelper.IsMonoBehaviour(methodDefinition.DeclaringType)) { return(null); } if (!m_MonoBehaviourMagicMethods.Contains(methodDefinition.Name)) { return(null); } return(new ProjectIssue ( descriptor, methodDefinition.FullName, IssueCategory.ApiCalls, new CallTreeNode(methodDefinition.FullName) )); }
private void AnalyzeAssembly(AssemblyInfo assemblyInfo, IAssemblyResolver assemblyResolver, Action <CallInfo> onCallFound, Action <ProjectIssue> onIssueFound) { Profiler.BeginSample("ScriptAuditor.AnalyzeAssembly " + assemblyInfo.name); using (var assembly = AssemblyDefinition.ReadAssembly(assemblyInfo.path, new ReaderParameters { ReadSymbols = true, AssemblyResolver = assemblyResolver })) { var assemblyName = assembly.Name.Name; // var packageInfo = AssemblyHelper.GetPackageInfoFromAssembly(assemblyName); foreach (var methodDefinition in MonoCecilHelper.AggregateAllTypeDefinitions(assembly.MainModule.Types) .SelectMany(t => t.Methods)) { if (!methodDefinition.HasBody) { continue; } AnalyzeMethodBody(assemblyInfo, methodDefinition, onCallFound, onIssueFound); } } Profiler.EndSample(); }
private void AnalyzeAssembly(string assemblyPath, IAssemblyResolver assemblyResolver, ProjectReport projectReport, CallCrawler callCrawler) { using (var a = AssemblyDefinition.ReadAssembly(assemblyPath, new ReaderParameters() { ReadSymbols = true, AssemblyResolver = assemblyResolver })) { foreach (var methodDefinition in MonoCecilHelper.AggregateAllTypeDefinitions(a.MainModule.Types).SelectMany(t => t.Methods)) { if (!methodDefinition.HasBody) { continue; } AnalyzeMethodBody(projectReport, a, methodDefinition, callCrawler); } } }
public IFileOpenInfo GetFileOpenInfo(Type type, MethodInfo method) { const string fileExtension = ".cs"; var fileOpenInfo = MonoCecilHelper.TryGetCecilFileOpenInfo(type, method); if (string.IsNullOrEmpty(fileOpenInfo.FilePath)) { var dirPath = Paths.UnifyDirectorySeparator(Application.dataPath); var allCsFiles = Directory.GetFiles(dirPath, string.Format("*{0}", fileExtension), SearchOption.AllDirectories) .Select(Paths.UnifyDirectorySeparator); var fileName = allCsFiles.FirstOrDefault(x => x.Split(Path.DirectorySeparatorChar).Last().Equals(string.Concat(type.Name, fileExtension))); fileOpenInfo.FilePath = fileName ?? string.Empty; } fileOpenInfo.FilePath = FilePathToAssetsRelativeAndUnified(fileOpenInfo.FilePath); return(fileOpenInfo); }
public IFileOpenInfo GetFileOpenInfo(Type type, MethodInfo method) { var fileOpenInfo = MonoCecilHelper.TryGetCecilFileOpenInfo(type, method); if (string.IsNullOrEmpty(fileOpenInfo.FilePath)) { var dirPath = Paths.UnifyDirectorySeparator(Application.dataPath); var allCsFiles = GetCSFiles(dirPath, FileExtension); var fileName = allCsFiles.FirstOrDefault(x => x.Split(Path.DirectorySeparatorChar).Last().Equals(string.Concat(GetTestFileName(type), FileExtension))); fileOpenInfo.FilePath = fileName ?? string.Empty; } if (!fileOpenInfo.FilePath.Contains("Assets")) { return(fileOpenInfo); } fileOpenInfo.FilePath = FilePathToAssetsRelativeAndUnified(fileOpenInfo.FilePath); return(fileOpenInfo); }