private async Task CollectSolutionInformationAsync() { var solutionReader = new SolutionReferenceParser(); var solutionReferences = solutionReader.Process(await Context.Options.FileSystem.ReadAsync(Context.SolutionPath)); foreach (var solutionReference in solutionReferences) { var solutionHistory = new HistoryInformation(); var solutionPathMapper = new PathMapper(Context.SolutionPath); solutionHistory.Before.AbsolutePath = solutionPathMapper.GetAbsolutePath(solutionReference.RelativePath); solutionHistory.Before.RelativePath = solutionReference.RelativePath; if (Context.Projects.Contains(solutionHistory.Before.AbsolutePath)) { // reference will be moved solutionHistory.After.AbsolutePath = Context.Options.ProjectPathTransformer.AbsolutePath(solutionPathMapper.GetSuggestedPath(solutionHistory.Before.AbsolutePath, Context.DestinationPath)); solutionHistory.After.RelativePath = Context.Options.ProjectPathTransformer.RelativePath(solutionPathMapper.GetRelativePath(solutionHistory.After.AbsolutePath)); } else { solutionHistory.After.AbsolutePath = Context.Options.ProjectPathTransformer.AbsolutePath(solutionPathMapper.GetAbsolutePath(solutionReference.RelativePath)); solutionHistory.After.RelativePath = Context.Options.ProjectPathTransformer.RelativePath(solutionReference.RelativePath); } SolutionReferences.Add(solutionHistory); } }
private async Task CollectProjectsInformationAsync() { foreach (var currentProject in SolutionReferences) { var projectProcessor = new ProjectReferenceParser(); var projectReferences = projectProcessor.Process(await Context.Options.FileSystem.ReadAsync(currentProject.Before.AbsolutePath)); var historyInformations = new List <HistoryInformation>(); foreach (var projectReference in projectReferences) { var referenceHistory = new HistoryInformation(); referenceHistory.Before.RelativePath = projectReference.RelativePath; referenceHistory.Before.AbsolutePath = new PathMapper(currentProject.Before.AbsolutePath).GetAbsolutePath(projectReference.RelativePath); var futureReference = SolutionReferences.FirstOrDefault(d => string.Equals(d.Before.AbsolutePath, referenceHistory.Before.AbsolutePath, StringComparison.OrdinalIgnoreCase)); if (futureReference == null) { referenceHistory.After.AbsolutePath = referenceHistory.Before.AbsolutePath; referenceHistory.After.RelativePath = referenceHistory.Before.RelativePath; } else { referenceHistory.After.AbsolutePath = futureReference.After.AbsolutePath; referenceHistory.After.RelativePath = new PathMapper(currentProject.After.AbsolutePath).GetRelativePath(futureReference.After.AbsolutePath); } historyInformations.Add(referenceHistory); } ProjectReferences.Add(currentProject.Before.AbsolutePath, historyInformations); } }
private static void HandleReferenceRenames(HistoryInformation projectReference, StringBuilder solutionContent) { if (!string.Equals(Path.GetFileName(projectReference.Before.RelativePath), Path.GetFileName(projectReference.After.RelativePath), StringComparison.OrdinalIgnoreCase)) { solutionContent.Replace( $@"""{Path.GetFileNameWithoutExtension(projectReference.Before.RelativePath)}""", $@"""{Path.GetFileNameWithoutExtension(projectReference.After.RelativePath)}""" ); } }