void ComputeListOfAssemblies(HashSet <string> assemblies, AssemblyDefinition assembly, List <Exception> exceptions) { if (assembly == null) { return; } var fqname = assembly.MainModule.FileName; if (assemblies.Contains(fqname)) { return; } assemblies.Add(fqname); var asm = new Assembly(this, assembly); asm.ComputeSatellites(); this.Assemblies.Add(asm); var main = assembly.MainModule; foreach (AssemblyNameReference reference in main.AssemblyReferences) { // Verify that none of the references references an incorrect platform assembly. switch (reference.Name) { case "monotouch": case "Xamarin.iOS": case "Xamarin.TVOS": case "Xamarin.WatchOS": if (reference.Name != Driver.GetProductAssembly(App)) { exceptions.Add(ErrorHelper.CreateError(34, "Cannot reference '{0}.dll' in a {1} project - it is implicitly referenced by '{2}'.", reference.Name, Driver.TargetFramework.Identifier, assembly.FullName)); } break; } var reference_assembly = ManifestResolver.Resolve(reference); ComputeListOfAssemblies(assemblies, reference_assembly, exceptions); } // Custom Attribute metadata can include references to other assemblies, e.g. [X (typeof (Y)], // but it is not reflected in AssemblyReferences :-( ref: #37611 // so we must scan every custom attribute to look for System.Type GetCustomAttributeReferences(assembly, assemblies, exceptions); GetCustomAttributeReferences(main, assemblies, exceptions); if (main.HasTypes) { foreach (var ca in main.GetCustomAttributes()) { GetCustomAttributeReferences(ca, assemblies, exceptions); } } }
void ComputeListOfAssemblies(HashSet<string> assemblies, AssemblyDefinition assembly, List<Exception> exceptions) { if (assembly == null) return; var fqname = assembly.MainModule.FullyQualifiedName; if (assemblies.Contains (fqname)) return; assemblies.Add (fqname); var asm = new Assembly (this, assembly); asm.ComputeSatellites (); this.Assemblies.Add (asm); var main = assembly.MainModule; foreach (AssemblyNameReference reference in main.AssemblyReferences) { // Verify that none of the references references an incorrect platform assembly. switch (reference.Name) { case "monotouch": case "Xamarin.iOS": case "Xamarin.TVOS": case "Xamarin.WatchOS": if (reference.Name != Driver.ProductAssembly) exceptions.Add (ErrorHelper.CreateError (34, "Cannot reference '{0}.dll' in a {1} project - it is implicitly referenced by '{2}'.", reference.Name, Driver.TargetFramework.Identifier, assembly.FullName)); break; } var reference_assembly = ManifestResolver.Resolve (reference); ComputeListOfAssemblies (assemblies, reference_assembly, exceptions); } // Custom Attribute metadata can include references to other assemblies, e.g. [X (typeof (Y)], // but it is not reflected in AssemblyReferences :-( ref: #37611 // so we must scan every custom attribute to look for System.Type GetCustomAttributeReferences (assembly, assemblies, exceptions); GetCustomAttributeReferences (main, assemblies, exceptions); if (main.HasTypes) { foreach (var t in main.Types) { GetTypeReferences (t, assemblies, exceptions); } } }