示例#1
0
		internal void SaveOptions(DiffConfig diffConfig)
		{
			diffConfig.IsolationLevel = (cbIsolationLevel.SelectedIndex == 2) ? AppDomainIsolationLevel.Medium : ((cbIsolationLevel.SelectedIndex == 1) ? AppDomainIsolationLevel.High : AppDomainIsolationLevel.AutoDetect);
			diffConfig.TryResolveGACFirst = cbResolvePref.SelectedIndex == 1;
			diffConfig.UseReflectionOnlyContext = cbContext.SelectedIndex == 0;
			diffConfig.Multithread = cbThreading.SelectedIndex == 0;
		}
        public AssemblyDetail ExtractFrom(string assemblyFile, DiffConfig config)
        {
            Assembly assembly;

            _assemblyFile = assemblyFile;
            _config = config;

            AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += new ResolveEventHandler(CurrentDomain_ReflectionOnlyAssemblyResolve);

            try
            {
                if (config.UseReflectionOnlyContext)
                {
                    Log.Info("Loading assembly {0} (ReflectionContext)", assemblyFile);
                    assembly = Assembly.ReflectionOnlyLoadFrom(assemblyFile);
                }
                else
                {
                    Log.Info("Loading assembly {0}", assemblyFile);
                    assembly = Assembly.LoadFrom(assemblyFile);
                }

                return new AssemblyDetail(assembly);
            }
            catch (Exception ex)
            {
                var errMessage = ex.GetNestedExceptionMessage();
                Log.Error(errMessage);
                throw new Exception(errMessage);
            }
            finally
            {
                AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve -= new ResolveEventHandler(CurrentDomain_ReflectionOnlyAssemblyResolve);
            }
        }
示例#3
0
        public AssemblyDetail ExtractFrom(string assemblyFile, DiffConfig config)
        {
            Assembly assembly;

            _assemblyFile = assemblyFile;
            _config = config;

            AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += new ResolveEventHandler(CurrentDomain_ReflectionOnlyAssemblyResolve);

            try
            {
                if (config.UseReflectionOnlyContext)
                {
                    Log.Info("Loading assembly {0} (ReflectionContext)", assemblyFile);
                    assembly = Assembly.ReflectionOnlyLoadFrom(assemblyFile);
                }
                else
                {
                    Log.Info("Loading assembly {0}", assemblyFile);
                    assembly = Assembly.LoadFrom(assemblyFile);
                }

                return new AssemblyDetail(assembly);
            }
            finally
            {
                AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve -= new ResolveEventHandler(CurrentDomain_ReflectionOnlyAssemblyResolve);
            }
        }
示例#4
0
		internal void LoadOptions(DiffConfig diffConfig)
		{
			cbIsolationLevel.SelectedIndex = (diffConfig.IsolationLevel == AppDomainIsolationLevel.Medium) ? 2 : ((diffConfig.IsolationLevel == AppDomainIsolationLevel.High) ? 1 : 0);
			cbResolvePref.SelectedIndex = diffConfig.TryResolveGACFirst ? 1 : 0;
			cbContext.SelectedIndex = diffConfig.UseReflectionOnlyContext ? 0 : 1;
			cbThreading.SelectedIndex = diffConfig.Multithread ? 0 : 1;
		}
示例#5
0
 public void AppDomain_Isolation_Med_ReflOnly()
 {
     DiffConfig config = new DiffConfig();
     config.IsolationLevel = AppDomainIsolationLevel.Medium;
     config.UseReflectionOnlyContext = true;
     ExtractAll(Subjects.One, config);
     AssertAssemblyNotInCurrentAppDomain("BitDiffer.Tests.Subject");
 }
示例#6
0
		private void AssertChange(string from, string name, ChangeType change, DiffConfig config)
		{
			MemberDetail r1 = ExtractOperator(Subjects.One, from, name, config);
			MemberDetail r2 = ExtractOperator(Subjects.Two, from, name, config);

			Align(r1, r2);

			Assert.AreEqual(change, r2.PerformCompare(r1));
		}
示例#7
0
		internal void LoadOptions(DiffConfig config)
		{
            if (string.IsNullOrEmpty(config.ReferenceDirectories))
            {
                gridFolders.Items = new List<string>();
            }
            else
            {
                gridFolders.Items = new List<string>(config.ReferenceDirectories.Split(';'));
            }
		}
示例#8
0
        public AssemblyDetail ExtractAssemblyInf(string assemblyPath, DiffConfig config)
        {
            if (!Path.IsPathRooted(assemblyPath))
            {
                assemblyPath = Path.GetFullPath(assemblyPath);
            }

            Log.Verbose("Extracting from assembly {0}", Path.GetFileName(assemblyPath));

            DomainExtractorPair pair = GetExtractor(assemblyPath);
            AssemblyDetail ad = pair.Extractor.ExtractFrom(assemblyPath, config);
            OneExtractionComplete(pair);
            return ad;
        }
示例#9
0
 private InterfaceDetail ExtractNestedInterface(string assembly, string className, string interfaceName, DiffConfig config)
 {
     ClassDetail cd = ExtractClass(assembly, className, config);
     Assert.AreEqual(Status.Present, cd.Status);
     return ListOperations.FindOrReturnMissing(cd.FilterChildren<InterfaceDetail>(), interfaceName);
 }
示例#10
0
        internal void SaveOptions(DiffConfig config)
		{
            config.ReferenceDirectories = string.Join(";", gridFolders.Items);
        }
示例#11
0
        public AssemblyComparison CompareAssemblyDirectories(bool recurse, DiffConfig config, ComparisonFilter filter, params string[] assemblyDirectories)
        {
            _config = config;
            _filter = filter;

            int totalFiles = 0;
            List<List<ICanAlign>> allEntries = new List<List<ICanAlign>>();

            SearchOption option = recurse ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;

            foreach (string dir in assemblyDirectories)
            {
                List<ICanAlign> entry = new List<ICanAlign>();

                entry.AddRange(AssemblyDirectoryEntry.From(dir, Directory.GetFiles(dir, "*.dll", option)));
                entry.AddRange(AssemblyDirectoryEntry.From(dir, Directory.GetFiles(dir, "*.exe", option)));

                totalFiles += entry.Count;
                allEntries.Add(entry);
            }

            if (allEntries.Count == 0)
            {
                return null;
            }

            AppDomainIsolationLevel level = _config.IsolationLevel;
            if (level == AppDomainIsolationLevel.AutoDetect)
            {
                level = IsolationDetector.AutoDetectIsolationLevelDirs(assemblyDirectories);
            }

            ListOperations.AlignListsNoParent(allEntries.ToArray());

            AssemblyManager manager = AssemblyManagerFactory.Create(level);

            AssemblyComparison ac = new AssemblyComparison();

            if (_progress != null)
            {
                _progress.SetMaxRange(totalFiles);
            }

            for (int j = 0; j < allEntries[0].Count; j++)
            {
                List<string> thisRun = new List<string>();

                for (int i = 0; i < allEntries.Count; i++)
                {
                    if (allEntries[i][j].Status == Status.Present)
                    {
                        thisRun.Add(((AssemblyDirectoryEntry)allEntries[i][j]).Path);
                    }
                }

                ac.Groups.Add(DoCompareFiles(manager, thisRun.ToArray()));
            }

            manager.AllExtractionsComplete();

            return ac;
        }
示例#12
0
        public AssemblyComparison CompareAssemblyFiles(DiffConfig config, ComparisonFilter filter, params string[] assemblyFiles)
        {
            _config = config;
            _filter = filter;

            if (_progress != null)
            {
                _progress.SetMaxRange(assemblyFiles.Length);
            }

            if (assemblyFiles.Length == 0)
            {
                return null;
            }

            AppDomainIsolationLevel level = _config.IsolationLevel;
            if (level == AppDomainIsolationLevel.AutoDetect)
            {
                level = IsolationDetector.AutoDetectIsolationLevelFiles(assemblyFiles);
            }

            AssemblyManager manager = AssemblyManagerFactory.Create(level);
            AssemblyComparison ac = new AssemblyComparison();
            ac.Groups.Add(DoCompareFiles(manager, assemblyFiles));

            manager.AllExtractionsComplete();

            return ac;
        }
示例#13
0
 private static List<AssemblyDetail> DoCompare(DiffConfig config)
 {
     AssemblyComparison ac = new AssemblyComparer().CompareAssemblyFiles(config, ComparisonFilter.Default, Subjects.One, Subjects.Two);
     Assert.AreEqual(1, ac.Groups.Count);
     return ac.Groups[0].Assemblies;
 }