Esempio n. 1
0
        static void ProcessStrip(
            List <Regex> attributeNames, List <string> dllFileNames, IAssemblyResolver resolver,
            bool parallel, string?logFile
            )
        {
            var stripper = new AttributeStripper(attributeNames.ToArray());

            // let's strip attribute fom dlls!
            if (parallel)
            {
                Parallel.ForEach(dllFileNames, strip);
            }
            else
            {
                dllFileNames.ForEach(strip);
            }

            // show summary

            Log("* Summary * ", logFile);
            foreach (var item in stripper.StripTotalCountMap.OrderByDescending(i => i.Value))
            {
                Log($"  - {item.Key} : {item.Value}", logFile);
            }

            void strip(string dllFileName)
            {
                if (!File.Exists(dllFileName))
                {
                    throw new Exception($"File does not exist: {dllFileName}");
                }

                var stripCountMap = stripper.ProcessDll(dllFileName, resolver);
                var logStr        = "- ProcessDll : " + dllFileName + "\n" + string.Join(
                    "\n",
                    stripCountMap.OrderByDescending(i => i.Value).Select(item => $"  - {item.Key} : {item.Value}")
                    );

                Log(logStr, logFile);
            }
        }
        private static void ProcessStrip(List <string> attributeNames, List <string> dllFileNames)
        {
            var stripper = new AttributeStripper(attributeNames.ToArray());

            // let's strip attribute fom dlls!

            foreach (var dllFileName in dllFileNames)
            {
                if (File.Exists(dllFileName) == false)
                {
                    continue;
                }

                Log("- ProcessDll : " + dllFileName);
                try
                {
                    stripper.ProcessDll(dllFileName);
                    foreach (var item in stripper.StripCountMap.OrderByDescending(i => i.Value))
                    {
                        Log(string.Format("  - {0} : {1}", item.Key, item.Value));
                    }
                }
                catch (Exception e)
                {
                    Log("  - Failed: " + e);
                }
            }

            // show summary

            Log("* Summary * ");
            foreach (var item in stripper.StripTotalCountMap.OrderByDescending(i => i.Value))
            {
                Log(string.Format("  - {0} : {1}", item.Key, item.Value));
            }
        }
        private static void ProcessStrip(List<string> attributeNames, List<string> dllFileNames)
        {
            var stripper = new AttributeStripper(attributeNames.ToArray());

            // let's strip attribute fom dlls!

            foreach (var dllFileName in dllFileNames)
            {
                if (File.Exists(dllFileName) == false)
                    continue;

                Log("- ProcessDll : " + dllFileName);
                try
                {
                    stripper.ProcessDll(dllFileName);
                    foreach (var item in stripper.StripCountMap.OrderByDescending(i => i.Value))
                        Log(string.Format("  - {0} : {1}", item.Key, item.Value));
                }
                catch (Exception e)
                {
                    Log("  - Failed: " + e);
                }
            }

            // show summary

            Log("* Summary * ");
            foreach (var item in stripper.StripTotalCountMap.OrderByDescending(i => i.Value))
                Log(string.Format("  - {0} : {1}", item.Key, item.Value));
        }