internal void AddAssembly (System.Reflection.Assembly asm, bool force = false)
		{
			if (!force) {
				var assemblyName = asm.GetName ().Name;
				if (assemblyName == "MonoDevelop.AspNet" ||
				    assemblyName == "Microsoft.CodeAnalysis.CSharp" ||
				    assemblyName.Contains ("FSharpBinding")  ||
					assemblyName != "RefactoringEssentials" &&
					!(asm.GetReferencedAssemblies ().Any (a => a.Name == diagnosticAnalyzerAssembly) && asm.GetReferencedAssemblies ().Any (a => a.Name == "MonoDevelop.Ide")))
					return;
			}
			foreach (var type in asm.GetTypes ()) {
				var notPortedYetAttribute = (NotPortedYetAttribute)type.GetCustomAttributes (typeof(NotPortedYetAttribute), false).FirstOrDefault ();
				if (notPortedYetAttribute!= null) {
					continue;
				}
				var analyzerAttr = (DiagnosticAnalyzerAttribute)type.GetCustomAttributes (typeof(DiagnosticAnalyzerAttribute), false).FirstOrDefault ();
				if (analyzerAttr != null) {
					var analyzer = (DiagnosticAnalyzer)Activator.CreateInstance (type);
					foreach (var diag in analyzer.SupportedDiagnostics) {
						try {
							Analyzers.Add (new CodeDiagnosticDescriptor (diag, analyzerAttr.Languages, type));
						} catch (Exception e) {
							LoggingService.LogError ("error while adding diagnostic analyzer: " + diag.Id + " from assembly " + asm.FullName, e);
						}
					}
				}

				var codeFixAttr = (ExportCodeFixProviderAttribute)type.GetCustomAttributes (typeof(ExportCodeFixProviderAttribute), false).FirstOrDefault ();
				if (codeFixAttr != null) {
					Fixes.Add (new CodeDiagnosticFixDescriptor (type, codeFixAttr));
				}

				var exportAttr = type.GetCustomAttributes (typeof(ExportCodeRefactoringProviderAttribute), false).FirstOrDefault () as ExportCodeRefactoringProviderAttribute;
				if (exportAttr != null) {
					Refactorings.Add (new CodeRefactoringDescriptor (type, exportAttr)); 
				}
			}
		}
        public static void GetDependencies(System.Reflection.Assembly ass, 
            System.Collections.Generic.List<System.Reflection.Assembly> ls,
            System.Collections.Generic.List<string> paths, string name)
        {
            name += "/" + ass.GetName().Name;
            paths.Add(name);

            //if (StringComparer.OrdinalIgnoreCase.Equals(ass.GetName().Name, "Microsoft.ReportViewer.ProcessingObjectModel"))
            if (true)
            {
                string assemblyPath = GetAssemblyDirectory(ass);
                System.Console.WriteLine(assemblyPath);
                string assemblyFileName = System.IO.Path.GetFileName(assemblyPath);

                string assemblyOutputDirectory = @"d:\reportviewerz\";
                if (System.Environment.OSVersion.Platform == System.PlatformID.Unix)
                    assemblyOutputDirectory = "/root/reportviewerz/";

                if (!System.IO.Directory.Exists(assemblyOutputDirectory))
                    System.IO.Directory.CreateDirectory(assemblyOutputDirectory);

                System.IO.File.Copy(assemblyPath, assemblyOutputDirectory + assemblyFileName, true);
            } // End if

            System.Reflection.AssemblyName[] asmNames = ass.GetReferencedAssemblies();

            foreach (System.Reflection.AssemblyName asmn in asmNames)
            {
                System.Reflection.Assembly ass2 = System.Reflection.Assembly.Load(asmn);

                if (!ls.Contains(ass2))
                {
                    ls.Add(ass2);
                    GetDependencies(ass2, ls, paths, name);
                    //ls.AddRange(GetDependencies(ass2));
                } // End if (!ls.Contains(ass2))

            } // Next asmn
        }
Esempio n. 3
0
        static string[] GetAssemblyVersionStrings(System.Reflection.Assembly ea, System.Reflection.Assembly xa)
        {
            HashSet<string> workingset = new HashSet<string>();
            HashSet<string> fullset = new HashSet<string>();
            fullset.Add(xa.FullName); // add the executing assembly, the root is shown by the caller
            System.Reflection.AssemblyName[] ean = ea.GetReferencedAssemblies();
            System.Reflection.AssemblyName[] xan = xa.GetReferencedAssemblies();
            for (int i = 0; i < ean.Length; i++)
            {
                workingset.Add(ean[i].FullName);
            }
            for (int i = 0; i < xan.Length; i++)
            {
                workingset.Add(xan[i].FullName);
            }

            foreach (string s in workingset)
            {
                Assembly a = null;
                AssemblyName an;
                try
                {
                    a = Assembly.Load(s);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                fullset.Add(s);
                if (a == null)
                    continue;
                an = a.GetName();
                if (an.Name.Equals("RepDB") || an.Name.Equals("NCCCore") || an.Name.Equals("NCCCtrl") || an.Name.Equals("Defs") ||
                    an.Name.Equals("INCCCmd") || an.Name.Equals("INCC6"))  // todo: this hack needs redeeming: the list can and will change
                {
                    System.Reflection.AssemblyName[] ann = a.GetReferencedAssemblies();
                    foreach (AssemblyName ns in ann)
                    {
                        fullset.Add(ns.FullName);
                    }
                }
            }
            string[] res = new string[fullset.Count];
            int j = 0;
            foreach (string s in fullset)
            {
                res[j++] = s;
            }
            return res;
        }