Skip to content

Commit

Permalink
Merge pull request #40 from fsbflavio/add-vbproj-suport
Browse files Browse the repository at this point in the history
Add vbproj suport
  • Loading branch information
ModernRonin authored Sep 24, 2022
2 parents 99eea45 + 531a462 commit 7406b00
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
4 changes: 2 additions & 2 deletions ModernRonin.ProjectRenamer/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void Run()
: Path.GetDirectoryName(oldDir);
var newDir = _configuration.NewProjectName.ToAbsolutePath(newBase);
var newFileName = Path.GetFileName(_configuration.NewProjectName);
var newProjectPath = Path.Combine(newDir, $"{newFileName}{Constants.ProjectFileExtension}");
var newProjectPath = Path.Combine(newDir, $"{newFileName}{_configuration.ProjectFileExtension}");
var isPaketUsed = _filesystem.DoesDirectoryExist(".paket");
var gitVersion = _git.GetVersion();
if (!_configuration.DontReviewSettings)
Expand Down Expand Up @@ -231,7 +231,7 @@ string[] allProjects()

return all.Except(excluded).ToArray();

string[] filesIn(string directory) => _filesystem.FindProjectFiles(directory, true);
string[] filesIn(string directory) => _filesystem.FindProjectFiles(directory, true, _configuration.ProjectFileExtension);
}
}

Expand Down
1 change: 1 addition & 0 deletions ModernRonin.ProjectRenamer/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public class Configuration
public string ExcludedDirectory { get; set; } = string.Empty;
public string NewProjectName { get; set; }
public string OldProjectName { get; set; }
public string ProjectFileExtension { get; set; } = Constants.ProjectFileExtension;
}
}
16 changes: 11 additions & 5 deletions ModernRonin.ProjectRenamer/ConfigurationSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public ConfigurationSetup(ILogger console,
$"Do not specify paths for input/'old' project names, please.{Environment.NewLine}{Environment.NewLine}{helpOverview}");
}

configuration.OldProjectName = RemoveProjectFileExtension(configuration.OldProjectName);
configuration.NewProjectName = RemoveProjectFileExtension(configuration.NewProjectName);
configuration.OldProjectName = RemoveProjectFileExtension(configuration.OldProjectName, configuration.ProjectFileExtension);
configuration.NewProjectName = RemoveProjectFileExtension(configuration.NewProjectName, configuration.ProjectFileExtension);

return (configuration, solutionPath);
default:
Expand Down Expand Up @@ -97,12 +97,18 @@ public ConfigurationSetup(ILogger console,
.WithShortName("e")
.WithHelp(
"exclude this directory from project reference updates; must be a relative path to the current directory");
cfg.Parameter(c => c.ProjectFileExtension)
.MakeOptional()
.WithLongName("project-extension")
.WithShortName("pe")
.ExpectAt(3)
.WithHelp("the file extension for the project, ex: .csproj, .vbproj");
return (parser.HelpOverview, parser.Parse(args));
}

static string RemoveProjectFileExtension(string projectName) =>
projectName.EndsWith(Constants.ProjectFileExtension, StringComparison.InvariantCultureIgnoreCase)
? projectName[..^Constants.ProjectFileExtension.Length]
static string RemoveProjectFileExtension(string projectName, string projectFileExtension) =>
projectName.EndsWith(projectFileExtension, StringComparison.InvariantCultureIgnoreCase)
? projectName[..^projectFileExtension.Length]
: projectName;
}
}
4 changes: 2 additions & 2 deletions ModernRonin.ProjectRenamer/Filesystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ public class Filesystem : IFilesystem
public bool DoesDirectoryExist(string directory) => Directory.Exists(directory);
public void EnsureDirectoryExists(string directory) => Directory.CreateDirectory(directory);

public string[] FindProjectFiles(string directory, bool doRecurse) =>
public string[] FindProjectFiles(string directory, bool doRecurse, string projectFileExtension) =>
Directory
.EnumerateFiles(directory, $"*{Constants.ProjectFileExtension}", SearchOption(doRecurse))
.EnumerateFiles(directory, $"*{projectFileExtension}", SearchOption(doRecurse))
.ToArray();

public string[] FindSolutionFiles(string directory, bool doRecurse) =>
Expand Down
2 changes: 1 addition & 1 deletion ModernRonin.ProjectRenamer/IFilesystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public interface IFilesystem
string CurrentDirectory { get; }
bool DoesDirectoryExist(string directory);
void EnsureDirectoryExists(string directory);
string[] FindProjectFiles(string directory, bool doRecurse);
string[] FindProjectFiles(string directory, bool doRecurse, string projectFileExtension);
string[] FindSolutionFiles(string directory, bool doRecurse);
}
}
5 changes: 5 additions & 0 deletions ModernRonin.ProjectRenamer/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
"commandLineArgs": "LibraryInSolutionFolder ProjectInSolutionFolder",
"workingDirectory": "C:\\Projects\\Github\\ProjectRenamerTestBed"
},
"rename library to project, in solution folder, .vbproj": {
"commandName": "Project",
"commandLineArgs": "LibraryInSolutionFolder ProjectInSolutionFolder --project-extension=.vbproj",
"workingDirectory": "C:\\Projects\\Github\\ProjectRenamerTestBed"
},
"rename project to library, in solution folder, no review": {
"commandName": "Project",
"commandLineArgs": "ProjectInSolutionFolder LibraryInSolutionFolder --no-review",
Expand Down

0 comments on commit 7406b00

Please sign in to comment.