private WhitelistingResult TryWhitelistAssemblyName(AssemblyName assName, bool singleFile) { var result = WhitelistingResult.Exists; var assNameString = assName.Name; var hash = InjectionRoutines.GetAssemblyHash(assName); var allowed = whitelist.FirstOrDefault(allowedAssembly => allowedAssembly.name == assNameString); if (allowed != null) { if (allowed.AddHash(hash)) { if (singleFile) { ShowNotification(new GUIContent("New hash added!")); } result = WhitelistingResult.Updated; } else { if (singleFile) { ShowNotification(new GUIContent("Assembly already exists!")); } } } else { allowed = new AllowedAssembly(assNameString, new[] { hash }); whitelist.Add(allowed); if (singleFile) { ShowNotification(new GUIContent("Assembly added!")); } result = WhitelistingResult.Added; } return(result); }
private static AllowedAssembly[] GetAssembliesInBuild() { #if ACTK_DEBUG_VERBOSE sw.Stop(); Debug.Log(ACTkConstants.LogPrefix + "Trying to guess which assemblies can get into the build..."); sw.Start(); #endif var libraries = BuildPostProcessor.GetGuessedLibrariesForBuild(); #if ACTK_DEBUG_VERBOSE sw.Stop(); Debug.Log(ACTkConstants.LogPrefix + "Total libraries candidates: " + libraries.Length); sw.Start(); var invalidAssemblies = string.Empty; #endif var result = new List <AllowedAssembly>(); foreach (var libraryPath in libraries) { #if ACTK_DEBUG_PARANIOD sw.Stop(); Debug.Log(ACTkConstants.LogPrefix + "Checking library at the path: " + libraryPath); sw.Start(); #endif try { var assName = AssemblyName.GetAssemblyName(libraryPath); var name = assName.Name; var hash = InjectionRoutines.GetAssemblyHash(assName); var allowed = result.FirstOrDefault(allowedAssembly => allowedAssembly.name == name); if (allowed != null) { allowed.AddHash(hash); } else { allowed = new AllowedAssembly(name, new[] { hash }); result.Add(allowed); } } catch { // not a valid IL assembly, skipping #if ACTK_DEBUG_VERBOSE invalidAssemblies += libraryPath + "\n"; #endif } } #if ACTK_DEBUG_VERBOSE if (!string.IsNullOrEmpty(invalidAssemblies)) { sw.Stop(); Debug.Log(ACTkConstants.LogPrefix + "Not valid assemblies:\n" + invalidAssemblies); sw.Start(); } #endif #if ACTK_DEBUG sw.Stop(); var trace = ACTkConstants.LogPrefix + "Found assemblies in build (" + result.Count + ", " + sw.ElapsedMilliseconds + " ms):\n"; foreach (var allowedAssembly in result) { trace += " Name: " + allowedAssembly.name + "\n"; trace = allowedAssembly.hashes.Aggregate(trace, (current, hash) => current + (" Hash: " + hash + "\n")); } Debug.Log(trace); sw.Start(); #endif return(result.ToArray()); }