Skip to content

Commit

Permalink
Merge pull request #18 from ModernRonin/WhitespaceFixes
Browse files Browse the repository at this point in the history
Whitespace fixes
  • Loading branch information
ModernRonin authored Dec 13, 2020
2 parents fbadb31 + 774fc9c commit 57f89e0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
14 changes: 10 additions & 4 deletions ModernRonin.ProjectRenamer/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void addNewReferences()
dependencies.ForEach(d => addReference(newProjectPath, d));

void addReference(string project, string reference) =>
DotNet($"add {project} reference {reference}");
projectReferenceCommand("add", project, reference);
}

void removeOldReferences()
Expand All @@ -85,9 +85,12 @@ void removeOldReferences()
dependencies.ForEach(d => removeReference(oldProjectPath, d));

void removeReference(string project, string reference) =>
DotNet($"remove {project} reference {reference}");
projectReferenceCommand("remove", project, reference);
}

void projectReferenceCommand(string command, string project, string reference) =>
DotNet($"{command} {project.Escape()} reference {reference.Escape()}");

(string[] dependents, string[] dependencies) analyzeReferences()
{
Log(
Expand Down Expand Up @@ -188,10 +191,13 @@ void addToSolution()
var solutionFolderArgument = string.IsNullOrWhiteSpace(solutionFolderPath)
? string.Empty
: $"-s \"{solutionFolderPath}\"";
DotNet($"sln add {solutionFolderArgument} {newProjectPath}");
solutionCommand($"add {solutionFolderArgument}", newProjectPath);
}

void removeFromSolution() => DotNet($"sln remove {oldProjectPath}");
void removeFromSolution() => solutionCommand("remove", oldProjectPath);

void solutionCommand(string command, string projectPath) =>
DotNet($"sln {command} {projectPath.Escape()}");

(bool wasFound, string projectPath, string solutionFolder) findProject()
{
Expand Down
2 changes: 2 additions & 0 deletions ModernRonin.ProjectRenamer/CommonExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public static class CommonExtensions
{
public static string AsText(this bool self) => self ? "yes" : "no";

public static string Escape(this string self) => $"\"{self}\"";

public static bool IsDirectorySeparator(this char self) =>
self == Path.DirectorySeparatorChar || self == Path.AltDirectorySeparatorChar;

Expand Down
4 changes: 3 additions & 1 deletion ModernRonin.ProjectRenamer/release.history
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Version>2.1.0</Version>
<Version>2.1.1</Version>
<PackageReleaseNotes>
2.1.1:
* bugfix: projects in paths containing whitespace no longer crash the dotnet commands; thanks to @NicolasRiou for reporting the bug
2.1.0:
* feature: you can move projects to different folders now instead of just renaming them
* feature: you can specify a directory to exclude from project reference updates
Expand Down

0 comments on commit 57f89e0

Please sign in to comment.