diff --git a/NamespaceAdjuster/NamespaceAdjuster.csproj b/NamespaceAdjuster/NamespaceAdjuster.csproj index d0e364c..12c2291 100644 --- a/NamespaceAdjuster/NamespaceAdjuster.csproj +++ b/NamespaceAdjuster/NamespaceAdjuster.csproj @@ -52,6 +52,7 @@ + diff --git a/NamespaceAdjuster/NamespaceUpdater/FileNamespaceUpdaterProvider.cs b/NamespaceAdjuster/NamespaceUpdater/FileNamespaceUpdaterProvider.cs index 98223fe..6692d88 100644 --- a/NamespaceAdjuster/NamespaceUpdater/FileNamespaceUpdaterProvider.cs +++ b/NamespaceAdjuster/NamespaceUpdater/FileNamespaceUpdaterProvider.cs @@ -11,6 +11,7 @@ internal class FileNamespaceUpdaterProvider public FileNamespaceUpdaterProvider() { updaterServices.Add(new CsNamespaceUpdaterService()); + updaterServices.Add(new VbNamespaceUpdaterService()); } public IFileNamespaceUpdater GetUpdater(string filePath) diff --git a/NamespaceAdjuster/NamespaceUpdater/VbNamespaceUpdaterService.cs b/NamespaceAdjuster/NamespaceUpdater/VbNamespaceUpdaterService.cs new file mode 100644 index 0000000..194f495 --- /dev/null +++ b/NamespaceAdjuster/NamespaceUpdater/VbNamespaceUpdaterService.cs @@ -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; + } +}