Skip to content

Commit

Permalink
Added .vb file support
Browse files Browse the repository at this point in the history
Merge pull request #1 from tcoza/main
  • Loading branch information
EricBatlle authored May 13, 2024
2 parents 612f07c + 753a293 commit 5eb5977
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions NamespaceAdjuster/NamespaceAdjuster.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<Compile Include="NamespaceUpdater\IFileNamespaceUpdater.cs" />
<Compile Include="NamespaceUpdater\LogicFileNamespaceUpdaterService.cs" />
<Compile Include="NamespaceUpdater\FileNamespaceUpdaterProvider.cs" />
<Compile Include="NamespaceUpdater\VbNamespaceUpdaterService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="NamespaceAdjusterPackage.cs" />
<Compile Include="SolutionSelection\ISolutionSelectionService.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ internal class FileNamespaceUpdaterProvider
public FileNamespaceUpdaterProvider()
{
updaterServices.Add(new CsNamespaceUpdaterService());
updaterServices.Add(new VbNamespaceUpdaterService());
}

public IFileNamespaceUpdater GetUpdater(string filePath)
Expand Down
21 changes: 21 additions & 0 deletions NamespaceAdjuster/NamespaceUpdater/VbNamespaceUpdaterService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Text.RegularExpressions;

namespace NamespaceUpdater
{
internal class VbNamespaceUpdaterService : LogicFileNamespaceUpdaterService
{
protected override string SupportedFileExtension => ".vb";

protected override string NamespaceStartLimiter => string.Empty;

protected override string NamespaceEndLimiter => "End Namespace";

protected override Match FindNamespaceMatch(string fileContent) =>
Regex.Match(fileContent, @"[\r\n|\r|\n]?Namespace\s(.+)");

protected override MatchCollection FindUsingMatches(string fileContent) =>
Regex.Matches(fileContent, @"\n?Imports\s(.+)");

protected override string BuildNamespaceLine(string desiredNamespace) => "Namespace " + desiredNamespace;
}
}

0 comments on commit 5eb5977

Please sign in to comment.