public StoredMutantInfo(ProjectFilesClone filesClone) { _filesClone = filesClone; Directory = _filesClone.ParentPath.ToString(); _assembliesPaths = new List<string>(); }
public StoredMutantInfo(ProjectFilesClone filesClone) { _filesClone = filesClone; Directory = _filesClone.ParentPath.ToString(); _assembliesPaths = new List <string>(); }
public async Task <ProjectFilesClone> CreateCloneAsync(string name) { FilePathAbsolute tmp = CreateTmpDir("VisualMutator-" + name + "-"); ProjectFilesClone clone = await _filesManager.CreateProjectClone(_mainClone.Referenced, _mainClone.Assemblies, tmp); clone.IsIncomplete |= _mainClone.IsIncomplete; return(clone); }
public CciModuleSource(ProjectFilesClone filesClone) : this() { foreach (var assembliesPath in filesClone.Assemblies) { var sss = new CodeDeepCopier(Host); var m = DecompileFile(assembliesPath.Path); var copied = sss.Copy(m.Module); m.Module = copied; _moduleInfoList.Add(m); } }
public ProjectClonesManager( IHostEnviromentConnection hostEnviroment, FilesManager filesManager, IFileSystem fs) { _hostEnviroment = hostEnviroment; _filesManager = filesManager; _fs = fs; List<FilePathAbsolute> originalProjectFiles = _hostEnviroment.GetProjectAssemblyPaths().ToList(); IEnumerable<FilePathAbsolute> referencedFiles = GetReferencedAssemblyPaths(originalProjectFiles).Select(s => s.ToFilePathAbs()); FilePathAbsolute tmp = CreateTmpDir("VisualMutator-MainClone-"); _mainClone = _filesManager.CreateProjectClone(referencedFiles, originalProjectFiles, tmp).Result; }
public ProjectClonesManager( IHostEnviromentConnection hostEnviroment, FilesManager filesManager, IFileSystem fs) { _hostEnviroment = hostEnviroment; _filesManager = filesManager; _fs = fs; List <FilePathAbsolute> originalProjectFiles = _hostEnviroment.GetProjectAssemblyPaths().ToList(); IEnumerable <FilePathAbsolute> referencedFiles = GetReferencedAssemblyPaths(originalProjectFiles).Select(s => s.ToFilePathAbs()); FilePathAbsolute tmp = CreateTmpDir("VisualMutator-MainClone-"); _mainClone = _filesManager.CreateProjectClone(referencedFiles, originalProjectFiles, tmp).Result; }
private void TryAdd(ProjectFilesClone item1) { foreach (var whiteCach in _whiteCaches) { if (whiteCach.Value.Count < _maxCount) { var guid = Guid.NewGuid(); _log.Debug("Whitecache#" + PrintCacheState(whiteCach.Key) + "Add started."); var filePath = item1.Assemblies.Single(_ => _.FileName == whiteCach.Key); var cci = new CciModuleSource(filePath.Path); cci.Guid = guid; whiteCach.Value.Add(cci); _log.Debug("Whitecache#" + PrintCacheState(whiteCach.Key) + "Add finished: " + guid); } } }
private void InitializeModuleNames() { ProjectFilesClone projectFilesClone = _paths.Take(); foreach (var path in projectFilesClone.Assemblies) { var cci = new CciModuleSource(path.Path); _moduleNameToFileName.Add(cci.Modules.Single().Name, path.FileName); _fileNameToModuleName.Add(path.FileName, cci.Modules.Single().Name); var queue = new BlockingCollection <CciModuleSource>(20) { cci }; _whiteCaches.TryAdd(path.FileName, queue); _log.Debug("Whitecache#" + PrintCacheState(path.FileName) + "Initializing module name."); } _paths.Add(projectFilesClone); _initialized = true; NotifyClients(); }
public SessionConfiguration( IProjectClonesManager fileManager, TestsLoader testLoader, IFactory <AutoCreationController> autoCreationControllerFactory, IRootFactory <SessionController> sessionFactory, IWhiteSource whiteCache) { _testLoader = testLoader; _autoCreationControllerFactory = autoCreationControllerFactory; _sessionFactory = sessionFactory; _whiteCache = whiteCache; _originalFilesClone = fileManager.CreateClone("Mutants"); _testsClone = fileManager.CreateClone("Tests"); if (_originalFilesClone.IsIncomplete || _testsClone.IsIncomplete || _testsClone.Assemblies.Count == 0) { AssemblyLoadProblem = true; } }
public SessionConfiguration( IProjectClonesManager fileManager, TestsLoader testLoader, IFactory<AutoCreationController> autoCreationControllerFactory, IRootFactory<SessionController> sessionFactory, IWhiteSource whiteCache) { _testLoader = testLoader; _autoCreationControllerFactory = autoCreationControllerFactory; _sessionFactory = sessionFactory; _whiteCache = whiteCache; _originalFilesClone = fileManager.CreateClone("Mutants"); _testsClone = fileManager.CreateClone("Tests"); if (_originalFilesClone.IsIncomplete || _testsClone.IsIncomplete || _testsClone.Assemblies.Count == 0) { AssemblyLoadProblem = true; } }
private void TryAdd(ProjectFilesClone item1) { foreach (var whiteCach in _whiteCaches) { if (whiteCach.Value.Count < _maxCount) { var guid = Guid.NewGuid(); _log.Debug("Whitecache#"+ PrintCacheState(whiteCach.Key) + "Add started."); var filePath = item1.Assemblies.Single(_ => _.FileName == whiteCach.Key); var cci = new CciModuleSource(filePath.Path); cci.Guid = guid; whiteCach.Value.Add(cci); _log.Debug("Whitecache#" + PrintCacheState(whiteCach.Key) + "Add finished: " + guid); } } }
public async Task Initialize() { _error = null; _paths = new BlockingCollection <ProjectFilesClone>(); ProjectFilesClone[] projectFilesClones = await Task.WhenAll( Enumerable.Range(0, _threadsCount) .Select(i => _fileManager.CreateCloneAsync("WhiteCache-" + i))); _filesPool = projectFilesClones.ToList(); foreach (var projectFilesClone in _filesPool) { _paths.Add(projectFilesClone); } ProjectFilesClone filesClone = _paths.Take(); _mainModules = Task.Run(() => { _referenceStrings = new List <string>(); var task = filesClone.Assemblies.Select(a => { var cci = new CciModuleSource(a.Path); cci.Guid = Guid.NewGuid(); _log.Debug("Whitecache#" + a.FileName + ": Created initial source: " + cci.Guid); return(cci); }).ToList(); _paths.Add(filesClone); return(task); }); new Thread(() => { try { InitializeModuleNames(); foreach (ProjectFilesClone item in _paths.GetConsumingEnumerable()) { lock (this) { while (_whiteCaches.All(_ => _.Value.Count >= _maxCount) && !_paths.IsAddingCompleted) { Monitor.Wait(this); } } if (_paths.IsAddingCompleted) { return; } ProjectFilesClone item1 = item; Task.Run(() => TryAdd(item1)) .ContinueWith(task => { _paths.TryAdd(item1); NotifyClients(); }).LogErrors(); } } catch (Exception e) { _log.Error("Read assembly failed. ", e); _error = e; _paths.CompleteAdding(); } }).Start(); }