public override bool CheckFileCollisions(string buildTargetName) { bool flag = false; Dictionary <string, List <PluginInfo> > dictionary = new Dictionary <string, List <PluginInfo> >(); foreach (PluginImporter importer in PluginImporter.GetImporters(BuildTarget.Android)) { List <PluginInfo> list; PluginInfo item = new PluginInfo(buildTargetName, importer); if (dictionary.TryGetValue(item.assetName, out list)) { foreach (PluginInfo info2 in list) { if (item.ConflictsWith(info2)) { Debug.LogError($"Found plugins with same names and architectures, {item.assetPath} ({item.cpuType}) and {info2.assetPath} ({info2.cpuType}). Assign different architectures or delete the duplicate."); flag = true; } } } else { dictionary[item.assetName] = list = new List <PluginInfo>(); } list.Add(item); } return(flag); }
static private void AddReferencedAssembliesRecurse(string assemblyPath, List <string> alreadyFoundAssemblies, string[] allAssemblyPaths, string[] foldersToSearch, Dictionary <string, AssemblyDefinition> cache, BuildTarget target, ScriptingImplementation scriptingImplementation) { if (IgnoreAssembly(assemblyPath, target, scriptingImplementation)) { return; } if (!File.Exists(assemblyPath)) { return; } AssemblyDefinition assembly = GetAssemblyDefinitionCached(assemblyPath, cache); if (assembly == null) { throw new System.ArgumentException("Referenced Assembly " + Path.GetFileName(assemblyPath) + " could not be found!"); } // Ignore it if we already added the assembly if (alreadyFoundAssemblies.IndexOf(assemblyPath) != -1) { return; } alreadyFoundAssemblies.Add(assemblyPath); var architectureSpecificPlugins = PluginImporter.GetImporters(target).Where(i => { var cpu = i.GetPlatformData(target, "CPU"); return(!string.IsNullOrEmpty(cpu) && !string.Equals(cpu, "AnyCPU", StringComparison.InvariantCultureIgnoreCase)); }).Select(i => Path.GetFileName(i.assetPath)).Distinct(); // Go through all referenced assemblies foreach (AssemblyNameReference referencedAssembly in assembly.MainModule.AssemblyReferences) { // Special cases for Metro if (referencedAssembly.Name == "BridgeInterface") { continue; } if (referencedAssembly.Name == "WinRTBridge") { continue; } if (referencedAssembly.Name == "UnityEngineProxy") { continue; } if (IgnoreAssembly(referencedAssembly.Name + ".dll", target, scriptingImplementation)) { continue; } string foundPath = FindAssemblyName(referencedAssembly.FullName, referencedAssembly.Name, allAssemblyPaths, foldersToSearch, cache); if (foundPath == "") { // Ignore architecture specific plugin references var found = false; foreach (var extension in new[] { ".dll", ".winmd" }) { if (architectureSpecificPlugins.Any(p => string.Equals(p, referencedAssembly.Name + extension, StringComparison.InvariantCultureIgnoreCase))) { found = true; break; } } if (found) { continue; } throw new System.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, assembly.MainModule.Assembly.Name.Name, assemblyPath)); } AddReferencedAssembliesRecurse(foundPath, alreadyFoundAssemblies, allAssemblyPaths, foldersToSearch, cache, target, scriptingImplementation); } }
public static PluginImporter[] GetImporters(BuildTarget platform) { return(PluginImporter.GetImporters(BuildPipeline.GetBuildTargetName(platform))); }
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); } } } } } } }
public static PluginImporter[] GetImporters(BuildTargetGroup buildTargetGroup, BuildTarget buildTarget) { return(PluginImporter.GetImporters(BuildPipeline.GetBuildTargetGroupName(buildTargetGroup), BuildPipeline.GetBuildTargetName(buildTarget))); }
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); } } } } }