private static string FindAssemblyName(string fullName, string name, string[] allAssemblyPaths, string[] foldersToSearch, Dictionary <string, AssemblyDefinition> cache) { string result; for (int i = 0; i < allAssemblyPaths.Length; i++) { if (File.Exists(allAssemblyPaths[i])) { AssemblyDefinition assemblyDefinitionCached = AssemblyHelper.GetAssemblyDefinitionCached(allAssemblyPaths[i], cache); if (assemblyDefinitionCached.MainModule.Assembly.Name.Name == name) { result = allAssemblyPaths[i]; return(result); } } } for (int j = 0; j < foldersToSearch.Length; j++) { string path = foldersToSearch[j]; string text = Path.Combine(path, name + ".dll"); if (File.Exists(text)) { result = text; return(result); } } result = ""; return(result); }
private static string FindAssemblyName(string fullName, string name, string[] allAssemblyPaths, string[] foldersToSearch, Dictionary <string, AssemblyDefinition> cache) { for (int index = 0; index < allAssemblyPaths.Length; ++index) { if (((AssemblyNameReference)AssemblyHelper.GetAssemblyDefinitionCached(allAssemblyPaths[index], cache).get_MainModule().get_Assembly().get_Name()).get_Name() == name) { return(allAssemblyPaths[index]); } } foreach (string path1 in foldersToSearch) { string path = Path.Combine(path1, name + ".dll"); if (File.Exists(path)) { return(path); } } return(string.Empty); }
private static void AddReferencedAssembliesRecurse(string assemblyPath, List <string> alreadyFoundAssemblies, string[] allAssemblyPaths, string[] foldersToSearch, Dictionary <string, AssemblyDefinition> cache, BuildTarget target) { if (AssemblyHelper.IgnoreAssembly(assemblyPath, target)) { return; } AssemblyDefinition assemblyDefinitionCached = AssemblyHelper.GetAssemblyDefinitionCached(assemblyPath, cache); if (assemblyDefinitionCached == null) { throw new ArgumentException("Referenced Assembly " + Path.GetFileName(assemblyPath) + " could not be found!"); } if (alreadyFoundAssemblies.IndexOf(assemblyPath) != -1) { return; } alreadyFoundAssemblies.Add(assemblyPath); IEnumerable <string> source = (from i in PluginImporter.GetImporters(target).Where(delegate(PluginImporter i) { string platformData = i.GetPlatformData(target, "CPU"); return(!string.IsNullOrEmpty(platformData) && !string.Equals(platformData, "AnyCPU", StringComparison.InvariantCultureIgnoreCase)); }) select Path.GetFileName(i.assetPath)).Distinct <string>(); foreach (AssemblyNameReference referencedAssembly in assemblyDefinitionCached.MainModule.AssemblyReferences) { if (!(referencedAssembly.Name == "BridgeInterface")) { if (!(referencedAssembly.Name == "WinRTBridge")) { if (!(referencedAssembly.Name == "UnityEngineProxy")) { if (!AssemblyHelper.IgnoreAssembly(referencedAssembly.Name + ".dll", target)) { string text = AssemblyHelper.FindAssemblyName(referencedAssembly.FullName, referencedAssembly.Name, allAssemblyPaths, foldersToSearch, cache); if (text == string.Empty) { bool flag = false; string[] array = new string[] { ".dll", ".winmd" }; string extension; for (int j = 0; j < array.Length; j++) { extension = array[j]; if (source.Any((string p) => string.Equals(p, referencedAssembly.Name + extension, StringComparison.InvariantCultureIgnoreCase))) { flag = true; break; } } if (!flag) { throw new ArgumentException(string.Format("The Assembly {0} is referenced by {1} ('{2}'). But the dll is not allowed to be included or could not be found.", referencedAssembly.Name, assemblyDefinitionCached.MainModule.Assembly.Name.Name, assemblyPath)); } } else { AssemblyHelper.AddReferencedAssembliesRecurse(text, alreadyFoundAssemblies, allAssemblyPaths, foldersToSearch, cache, target); } } } } } } }
private static void AddReferencedAssembliesRecurse(string assemblyPath, List <string> alreadyFoundAssemblies, string[] allAssemblyPaths, string[] foldersToSearch, Dictionary <string, AssemblyDefinition> cache, BuildTarget target) { // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type AssemblyHelper.\u003CAddReferencedAssembliesRecurse\u003Ec__AnonStorey2D recurseCAnonStorey2D = new AssemblyHelper.\u003CAddReferencedAssembliesRecurse\u003Ec__AnonStorey2D(); // ISSUE: reference to a compiler-generated field recurseCAnonStorey2D.target = target; // ISSUE: reference to a compiler-generated field if (AssemblyHelper.IgnoreAssembly(assemblyPath, recurseCAnonStorey2D.target)) { return; } AssemblyDefinition definitionCached = AssemblyHelper.GetAssemblyDefinitionCached(assemblyPath, cache); if (definitionCached == null) { throw new ArgumentException("Referenced Assembly " + Path.GetFileName(assemblyPath) + " could not be found!"); } if (alreadyFoundAssemblies.IndexOf(assemblyPath) != -1) { return; } alreadyFoundAssemblies.Add(assemblyPath); // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated method IEnumerable <string> source = ((IEnumerable <PluginImporter>)PluginImporter.GetImporters(recurseCAnonStorey2D.target)).Where <PluginImporter>(new Func <PluginImporter, bool>(recurseCAnonStorey2D.\u003C\u003Em__40)).Select <PluginImporter, string>((Func <PluginImporter, string>)(i => Path.GetFileName(i.assetPath))).Distinct <string>(); // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type AssemblyHelper.\u003CAddReferencedAssembliesRecurse\u003Ec__AnonStorey2E recurseCAnonStorey2E = new AssemblyHelper.\u003CAddReferencedAssembliesRecurse\u003Ec__AnonStorey2E(); using (Collection <AssemblyNameReference> .Enumerator enumerator = definitionCached.get_MainModule().get_AssemblyReferences().GetEnumerator()) { // ISSUE: explicit reference operation while (((Collection <AssemblyNameReference> .Enumerator)@enumerator).MoveNext()) { // ISSUE: reference to a compiler-generated field // ISSUE: explicit reference operation recurseCAnonStorey2E.referencedAssembly = ((Collection <AssemblyNameReference> .Enumerator)@enumerator).get_Current(); // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated field if (!(recurseCAnonStorey2E.referencedAssembly.get_Name() == "BridgeInterface") && !(recurseCAnonStorey2E.referencedAssembly.get_Name() == "WinRTBridge") && (!(recurseCAnonStorey2E.referencedAssembly.get_Name() == "UnityEngineProxy") && !AssemblyHelper.IgnoreAssembly(recurseCAnonStorey2E.referencedAssembly.get_Name() + ".dll", recurseCAnonStorey2D.target))) { // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated field string assemblyName = AssemblyHelper.FindAssemblyName(recurseCAnonStorey2E.referencedAssembly.get_FullName(), recurseCAnonStorey2E.referencedAssembly.get_Name(), allAssemblyPaths, foldersToSearch, cache); if (assemblyName == string.Empty) { bool flag = false; // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type AssemblyHelper.\u003CAddReferencedAssembliesRecurse\u003Ec__AnonStorey2F recurseCAnonStorey2F = new AssemblyHelper.\u003CAddReferencedAssembliesRecurse\u003Ec__AnonStorey2F(); // ISSUE: reference to a compiler-generated field recurseCAnonStorey2F.\u003C\u003Ef__ref\u002446 = recurseCAnonStorey2E; string[] strArray = new string[2] { ".dll", ".winmd" }; foreach (string str in strArray) { // ISSUE: reference to a compiler-generated field recurseCAnonStorey2F.extension = str; // ISSUE: reference to a compiler-generated method if (source.Any <string>(new Func <string, bool>(recurseCAnonStorey2F.\u003C\u003Em__42))) { flag = true; break; } } if (!flag) { // ISSUE: reference to a compiler-generated field throw new ArgumentException(string.Format("The Assembly {0} is referenced by {1} ('{2}'). But the dll is not allowed to be included or could not be found.", (object)recurseCAnonStorey2E.referencedAssembly.get_Name(), (object)((AssemblyNameReference)definitionCached.get_MainModule().get_Assembly().get_Name()).get_Name(), (object)assemblyPath)); } } else { // ISSUE: reference to a compiler-generated field AssemblyHelper.AddReferencedAssembliesRecurse(assemblyName, alreadyFoundAssemblies, allAssemblyPaths, foldersToSearch, cache, recurseCAnonStorey2D.target); } } } } }