Ejemplo n.º 1
0
        // ============================================================================================
        #region Methods
        // ============================================================================================

        /// <summary>
        /// Analyze the given assemblies.
        /// </summary>
        /// <param name="assemblies">List of assemblies; optional</param>
        /// <param name="moduleMap">Dictionary with the module name of each class file or null (then the assembly is used to get the module
        /// information)); key is the full qualified class name in LOWER CASE and value the module name</param>
        /// <returns>A list of found types as TypeDescription entities; never null (but may be empty)</returns>
        public static IList <TypeDescription> AnalyzeAssemblies(IList <Assembly> assemblies, IDictionary <string, string> moduleMap)
        {
            IList <TypeDescription> foundTypes = new List <TypeDescription>();

            if (assemblies == null)
            {
                return(foundTypes);
            }

            foreach (var assembly in assemblies)
            {
                try
                {
                    string source = GetSource(assembly);
                    foreach (Type type in assembly.GetTypes())
                    {
                        var typeType = ParserUtil.GetTypeType(type);
                        if (typeType != null && !IsTypeSkipped(type))
                        {
                            TypeDescription typeDescription = AnalyzeType(type, typeType, source, moduleMap);
                            foundTypes.Add(typeDescription);
                        }
                    }
                }
                catch (ReflectionTypeLoadException ex)
                {
                    Console.WriteLine("Assembly '" + assembly.FullName + "' can't be parsed due to: " + ex.LoaderExceptions[0].Message);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Assembly '" + assembly.FullName + "' can't be parsed due to: " + ex.Message);
                }
            }

            return(foundTypes);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The program logic.
        /// </summary>
        /// <param name="args">Program arguments</param>
        private static void Run(string[] args)
        {
            if (WantsHelp(args))
            {
                DisplayHelpAndWait();
                return;
            }

            IList <Assembly> assemblies = GetAssemblies(args);

            if (assemblies == null || assemblies.Count == 0)
            {
                Console.WriteLine("No ASSEMBLIES found!");
                return;
            }
            else
            {
                Console.WriteLine("All " + assemblies.Count + " ASSEMBLIES successfully read.");
            }
            string targetPath = GetTargetPathEnsured(args);

            // Read the source files of all modules and create a map to identify the modules
            string moduleRootPath = GetModuleRootPathEnsured(args);
            IDictionary <string, string> moduleMap = null;
            string skipScan = GetArgIfExists("-skipModuleScan", args);

            if (string.IsNullOrWhiteSpace(skipScan) || "false".Equals(skipScan, StringComparison.InvariantCultureIgnoreCase))
            {
                moduleMap = CreateModuleMap(moduleRootPath);
            }

            IList <TypeDescription> foundTypes = ParserUtil.AnalyzeAssemblies(assemblies, moduleMap);

            OutputUtil.Export(foundTypes, targetPath);
            Console.WriteLine("FINISHED!");
        }