public static async Task <Package> Copy( Package fromPackage, string folderNameStartsWith = null, bool isRebuildable = false, IScheduler buildThrottleScheduler = null, DirectoryInfo parentDirectory = null) { if (fromPackage == null) { throw new ArgumentNullException(nameof(fromPackage)); } await fromPackage.EnsureReady(new Budget()); folderNameStartsWith = folderNameStartsWith ?? fromPackage.Name; parentDirectory = parentDirectory ?? fromPackage.Directory.Parent; var destination = CreateDirectory(folderNameStartsWith, parentDirectory); fromPackage.Directory.CopyTo(destination, info => { switch (info) { case FileInfo fileInfo: return(FileLock.IsLockFile(fileInfo) || fileInfo.Extension.EndsWith("binlog")); default: return(false); } }); Package copy; if (isRebuildable) { copy = new RebuildablePackage(directory: destination, name: destination.Name, buildThrottleScheduler: buildThrottleScheduler); } else { copy = new NonrebuildablePackage(directory: destination, name: destination.Name, buildThrottleScheduler: buildThrottleScheduler); } return(copy); }
public async Task If_an_already_built_package_contains_new_file_the_new_workspace_contains_the_file() { var oldPackage = await Create.ConsoleWorkspaceCopy(isRebuildable : true); var ws = await oldPackage.CreateRoslynWorkspaceForRunAsync(new TimeBudget(30.Seconds())); var newFile = Path.Combine(oldPackage.Directory.FullName, "Sample.cs"); ws.CurrentSolution.Projects.First().Documents.Select(d => d.FilePath).Should().NotContain(filePath => filePath == newFile); File.WriteAllText(newFile, "//this is a new file"); var newPackage = new RebuildablePackage(directory: oldPackage.Directory); ws = await newPackage.CreateRoslynWorkspaceForRunAsync(new TimeBudget(30.Seconds())); ws.CurrentSolution.Projects.First().Documents.Select(d => d.FilePath).Should().Contain(filePath => filePath == newFile); }
public static async Task <Package> Copy( Package fromPackage, string folderNameStartsWith = null, bool isRebuildable = false, IScheduler buildThrottleScheduler = null, DirectoryInfo parentDirectory = null) { if (fromPackage == null) { throw new ArgumentNullException(nameof(fromPackage)); } await fromPackage.EnsureReady(new Budget()); folderNameStartsWith = folderNameStartsWith ?? fromPackage.Name; parentDirectory = parentDirectory ?? fromPackage.Directory.Parent; var destination = CreateDirectory(folderNameStartsWith, parentDirectory); fromPackage.Directory.CopyTo(destination); var binLogs = destination.GetFiles("*.binlog"); foreach (var fileInfo in binLogs) { fileInfo.Delete(); } Package copy; if (isRebuildable) { copy = new RebuildablePackage(directory: destination, name: destination.Name, buildThrottleScheduler: buildThrottleScheduler); } else { copy = new NonrebuildablePackage(directory: destination, name: destination.Name, buildThrottleScheduler: buildThrottleScheduler); } return(copy); }
public async Task If_an_already_built_package_contains_a_new_file_and_an_old_file_is_deleted_workspace_reflects_it() { var oldPackage = await Create.ConsoleWorkspaceCopy(isRebuildable : true); var sampleCsFile = Path.Combine(oldPackage.Directory.FullName, "Sample.cs"); File.WriteAllText(sampleCsFile, "//this is a file which will be deleted later"); var ws = await oldPackage.CreateRoslynWorkspaceForRunAsync(new TimeBudget(30.Seconds())); ws.CurrentSolution.Projects.First().Documents.Select(d => d.FilePath).Should().Contain(filePath => filePath == sampleCsFile); File.Delete(sampleCsFile); var newFileAdded = Path.Combine(oldPackage.Directory.FullName, "foo.cs"); File.WriteAllText(newFileAdded, "//this is a file we have just created"); var newPackage = new RebuildablePackage(directory: oldPackage.Directory); ws = await newPackage.CreateRoslynWorkspaceForRunAsync(new TimeBudget(30.Seconds())); ws.CurrentSolution.Projects.First().Documents.Select(d => d.FilePath).Should().NotContain(filePath => filePath == sampleCsFile); ws.CurrentSolution.Projects.First().Documents.Select(d => d.FilePath).Should().Contain(filePath => filePath == newFileAdded); }