public ReferenceList Read(string entryAssemblyFilePath, IEnumerable <string> subDirectories, bool skipSystemAssemblies)
        {
            if (!File.Exists(entryAssemblyFilePath))
            {
                throw new ArgumentException(string.Format("File does not exist: {0}", entryAssemblyFilePath));
            }

            _skipSystemAssemblies = skipSystemAssemblies;
            _result = new ReferenceList();
            _cache  = new Dictionary <string, ReferencedAssembly>();

            var workingDirectory = Path.GetDirectoryName(entryAssemblyFilePath);

            _searchDirectories = new List <string>()
            {
                workingDirectory
            };
            try
            {
                if (subDirectories != null)
                {
                    _searchDirectories.AddRange(subDirectories
                                                .Select(x => Path.Combine(workingDirectory, x))
                                                .Where(x => Directory.Exists(x)));
                }
            }
            catch (Exception e)
            {
                throw new Exception($"\"runtime/assemblyBinding/probing\" element in the config file contains invalid paths. {e.Message}");
            }

            AssemblyName[] entryPointReferences;
            var            entryPoint = LoadEntryPoint(entryAssemblyFilePath, out entryPointReferences);

            _result.AddEntryPoint(entryPoint);

            ReadReferencesRecursively(entryPoint, entryPointReferences);
            ReadUnusedAssemblies();

            return(_result);
        }
Example #2
0
        public ReferenceList Read(string entryAssemblyFilePath, bool skipSystemAssemblies = true)
        {
            if (!File.Exists(entryAssemblyFilePath))
            {
                throw new ArgumentException(string.Format("File does not exist: {0}", entryAssemblyFilePath));
            }

            _skipSystemAssemblies = skipSystemAssemblies;
            _result = new ReferenceList();
            _cache  = new Dictionary <string, ReferencedAssembly>();

            _workingDirectory = Path.GetDirectoryName(entryAssemblyFilePath);

            AssemblyName[] entryPointReferences;
            var            entryPoint = LoadEntryPoint(entryAssemblyFilePath, out entryPointReferences);

            _result.AddEntryPoint(entryPoint);

            ReadReferencesRecursively(entryPoint, entryPointReferences);

            return(_result);
        }