From c0a079de416d6b901f87744966447bc51fbaeea1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enner=20P=C3=A9rez?= Date: Sat, 16 Mar 2024 04:09:27 -0500 Subject: [PATCH] Source Generated Regex --- src/Commands/AssumeUnchanged.cs | 10 ++++++---- src/Commands/Blame.cs | 8 +++++--- src/Commands/Command.cs | 7 ++++--- src/Commands/CompareRevisions.cs | 7 ++++--- src/Commands/Diff.cs | 9 +++++---- src/Commands/IsBinary.cs | 7 ++++--- src/Commands/QueryBranches.cs | 8 +++++--- src/Commands/QueryCommitChanges.cs | 7 ++++--- src/Commands/QueryFileSize.cs | 8 +++++--- src/Commands/QueryLocalChanges.cs | 7 ++++--- src/Commands/QueryRemotes.cs | 7 ++++--- src/Commands/QueryRevisionObjects.cs | 8 +++++--- src/Commands/QueryStagedFileBlobGuid.cs | 7 ++++--- src/Commands/QueryStashChanges.cs | 8 +++++--- src/Commands/QueryStashes.cs | 8 +++++--- src/Commands/QuerySubmodules.cs | 12 +++++++----- src/Models/DiffResult.cs | 12 +++++++----- src/Models/Remote.cs | 17 +++++++++++++---- src/ViewModels/InitGitFlow.cs | 8 +++++--- 19 files changed, 101 insertions(+), 64 deletions(-) diff --git a/src/Commands/AssumeUnchanged.cs b/src/Commands/AssumeUnchanged.cs index d7dc4c06..c1d7110e 100644 --- a/src/Commands/AssumeUnchanged.cs +++ b/src/Commands/AssumeUnchanged.cs @@ -2,9 +2,11 @@ using System.Text.RegularExpressions; namespace SourceGit.Commands { - public class AssumeUnchanged { - class ViewCommand : Command { - private static readonly Regex REG = new Regex(@"^(\w)\s+(.+)$"); + public partial class AssumeUnchanged { + partial class ViewCommand : Command { + + [GeneratedRegex(@"^(\w)\s+(.+)$")] + private static partial Regex REG(); public ViewCommand(string repo) { WorkingDirectory = repo; @@ -18,7 +20,7 @@ namespace SourceGit.Commands { } protected override void OnReadline(string line) { - var match = REG.Match(line); + var match = REG().Match(line); if (!match.Success) return; if (match.Groups[1].Value == "h") { diff --git a/src/Commands/Blame.cs b/src/Commands/Blame.cs index b8c977e7..99ff3923 100644 --- a/src/Commands/Blame.cs +++ b/src/Commands/Blame.cs @@ -3,8 +3,10 @@ using System.Text; using System.Text.RegularExpressions; namespace SourceGit.Commands { - public class Blame : Command { - private static readonly Regex REG_FORMAT = new Regex(@"^\^?([0-9a-f]+)\s+.*\((.*)\s+(\d+)\s+[\-\+]?\d+\s+\d+\) (.*)"); + public partial class Blame : Command { + + [GeneratedRegex(@"^\^?([0-9a-f]+)\s+.*\((.*)\s+(\d+)\s+[\-\+]?\d+\s+\d+\) (.*)")] + private static partial Regex REG_FORMAT(); private static readonly DateTime UTC_START = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).ToLocalTime(); public Blame(string repo, string file, string revision) { @@ -44,7 +46,7 @@ namespace SourceGit.Commands { return; } - var match = REG_FORMAT.Match(line); + var match = REG_FORMAT().Match(line); if (!match.Success) return; _content.AppendLine(match.Groups[4].Value); diff --git a/src/Commands/Command.cs b/src/Commands/Command.cs index cf79841d..b0d630d0 100644 --- a/src/Commands/Command.cs +++ b/src/Commands/Command.cs @@ -6,7 +6,7 @@ using System.Text; using System.Text.RegularExpressions; namespace SourceGit.Commands { - public class Command { + public partial class Command { public class CancelToken { public bool Requested { get; set; } = false; } @@ -70,7 +70,7 @@ namespace SourceGit.Commands { if (e.Data.StartsWith("remote: Counting objects:", StringComparison.Ordinal)) return; if (e.Data.StartsWith("remote: Compressing objects:", StringComparison.Ordinal)) return; if (e.Data.StartsWith("Filtering content:", StringComparison.Ordinal)) return; - if (_progressRegex.IsMatch(e.Data)) return; + if (_progressRegex().IsMatch(e.Data)) return; errs.Add(e.Data); }; @@ -142,6 +142,7 @@ namespace SourceGit.Commands { protected virtual void OnReadline(string line) { } - private static readonly Regex _progressRegex = new Regex(@"\d+%"); + [GeneratedRegex(@"\d+%")] + private static partial Regex _progressRegex(); } } \ No newline at end of file diff --git a/src/Commands/CompareRevisions.cs b/src/Commands/CompareRevisions.cs index 2b10adab..66616ddb 100644 --- a/src/Commands/CompareRevisions.cs +++ b/src/Commands/CompareRevisions.cs @@ -2,8 +2,9 @@ using System.Text.RegularExpressions; namespace SourceGit.Commands { - public class CompareRevisions : Command { - private static readonly Regex REG_FORMAT = new Regex(@"^(\s?[\w\?]{1,4})\s+(.+)$"); + public partial class CompareRevisions : Command { + [GeneratedRegex(@"^(\s?[\w\?]{1,4})\s+(.+)$")] + private static partial Regex REG_FORMAT(); public CompareRevisions(string repo, string start, string end) { WorkingDirectory = repo; @@ -18,7 +19,7 @@ namespace SourceGit.Commands { } protected override void OnReadline(string line) { - var match = REG_FORMAT.Match(line); + var match = REG_FORMAT().Match(line); if (!match.Success) return; var change = new Models.Change() { Path = match.Groups[2].Value }; diff --git a/src/Commands/Diff.cs b/src/Commands/Diff.cs index 8003922b..bcad4f4c 100644 --- a/src/Commands/Diff.cs +++ b/src/Commands/Diff.cs @@ -3,8 +3,9 @@ using System.Collections.Generic; using System.Text.RegularExpressions; namespace SourceGit.Commands { - public class Diff : Command { - private static readonly Regex REG_INDICATOR = new Regex(@"^@@ \-(\d+),?\d* \+(\d+),?\d* @@"); + public partial class Diff : Command { + [GeneratedRegex(@"^@@ \-(\d+),?\d* \+(\d+),?\d* @@")] + private static partial Regex REG_INDICATOR(); private static readonly string PREFIX_LFS_NEW = "+version https://git-lfs.github.com/spec/"; private static readonly string PREFIX_LFS_DEL = "-version https://git-lfs.github.com/spec/"; private static readonly string PREFIX_LFS_MODIFY = " version https://git-lfs.github.com/spec/"; @@ -57,7 +58,7 @@ namespace SourceGit.Commands { } if (_result.TextDiff.Lines.Count == 0) { - var match = REG_INDICATOR.Match(line); + var match = REG_INDICATOR().Match(line); if (!match.Success) { if (line.StartsWith("Binary", StringComparison.Ordinal)) _result.IsBinary = true; return; @@ -96,7 +97,7 @@ namespace SourceGit.Commands { _newLine++; } else if (ch != '\\') { ProcessInlineHighlights(); - var match = REG_INDICATOR.Match(line); + var match = REG_INDICATOR().Match(line); if (match.Success) { _oldLine = int.Parse(match.Groups[1].Value); _newLine = int.Parse(match.Groups[2].Value); diff --git a/src/Commands/IsBinary.cs b/src/Commands/IsBinary.cs index d9096aa2..a3b92b4c 100644 --- a/src/Commands/IsBinary.cs +++ b/src/Commands/IsBinary.cs @@ -1,8 +1,9 @@ using System.Text.RegularExpressions; namespace SourceGit.Commands { - public class IsBinary : Command { - private static readonly Regex REG_TEST = new Regex(@"^\-\s+\-\s+.*$"); + public partial class IsBinary : Command { + [GeneratedRegex(@"^\-\s+\-\s+.*$")] + private static partial Regex REG_TEST(); public IsBinary(string repo, string commit, string path) { WorkingDirectory = repo; @@ -12,7 +13,7 @@ namespace SourceGit.Commands { } public bool Result() { - return REG_TEST.IsMatch(ReadToEnd().StdOut); + return REG_TEST().IsMatch(ReadToEnd().StdOut); } } } diff --git a/src/Commands/QueryBranches.cs b/src/Commands/QueryBranches.cs index 859f909f..927d96c2 100644 --- a/src/Commands/QueryBranches.cs +++ b/src/Commands/QueryBranches.cs @@ -3,10 +3,12 @@ using System.Collections.Generic; using System.Text.RegularExpressions; namespace SourceGit.Commands { - public class QueryBranches : Command { + public partial class QueryBranches : Command { private static readonly string PREFIX_LOCAL = "refs/heads/"; private static readonly string PREFIX_REMOTE = "refs/remotes/"; - private static readonly Regex REG_AHEAD_BEHIND = new Regex(@"^(\d+)\s(\d+)$"); + + [GeneratedRegex(@"^(\d+)\s(\d+)$")] + private static partial Regex REG_AHEAD_BEHIND(); public QueryBranches(string repo) { WorkingDirectory = repo; @@ -71,7 +73,7 @@ namespace SourceGit.Commands { var rs = cmd.ReadToEnd(); if (!rs.IsSuccess) return string.Empty; - var match = REG_AHEAD_BEHIND.Match(rs.StdOut); + var match = REG_AHEAD_BEHIND().Match(rs.StdOut); if (!match.Success) return string.Empty; var ahead = int.Parse(match.Groups[1].Value); diff --git a/src/Commands/QueryCommitChanges.cs b/src/Commands/QueryCommitChanges.cs index 7b252efd..02fc7e48 100644 --- a/src/Commands/QueryCommitChanges.cs +++ b/src/Commands/QueryCommitChanges.cs @@ -2,8 +2,9 @@ using System.Text.RegularExpressions; namespace SourceGit.Commands { - public class QueryCommitChanges : Command { - private static readonly Regex REG_FORMAT = new Regex(@"^(\s?[\w\?]{1,4})\s+(.+)$"); + public partial class QueryCommitChanges : Command { + [GeneratedRegex(@"^(\s?[\w\?]{1,4})\s+(.+)$")] + private static partial Regex REG_FORMAT(); public QueryCommitChanges(string repo, string commitSHA) { WorkingDirectory = repo; @@ -18,7 +19,7 @@ namespace SourceGit.Commands { } protected override void OnReadline(string line) { - var match = REG_FORMAT.Match(line); + var match = REG_FORMAT().Match(line); if (!match.Success) return; var change = new Models.Change() { Path = match.Groups[2].Value }; diff --git a/src/Commands/QueryFileSize.cs b/src/Commands/QueryFileSize.cs index e16bf9e6..a75b1768 100644 --- a/src/Commands/QueryFileSize.cs +++ b/src/Commands/QueryFileSize.cs @@ -1,8 +1,10 @@ using System.Text.RegularExpressions; namespace SourceGit.Commands { - public class QueryFileSize : Command { - private static readonly Regex REG_FORMAT = new Regex(@"^\d+\s+\w+\s+[0-9a-f]+\s+(\d+)\s+.*$"); + public partial class QueryFileSize : Command { + + [GeneratedRegex(@"^\d+\s+\w+\s+[0-9a-f]+\s+(\d+)\s+.*$")] + private static partial Regex REG_FORMAT(); public QueryFileSize(string repo, string file, string revision) { WorkingDirectory = repo; @@ -15,7 +17,7 @@ namespace SourceGit.Commands { var rs = ReadToEnd(); if (rs.IsSuccess) { - var match = REG_FORMAT.Match(rs.StdOut); + var match = REG_FORMAT().Match(rs.StdOut); if (match.Success) { return long.Parse(match.Groups[1].Value); } diff --git a/src/Commands/QueryLocalChanges.cs b/src/Commands/QueryLocalChanges.cs index 260885d5..8b543b47 100644 --- a/src/Commands/QueryLocalChanges.cs +++ b/src/Commands/QueryLocalChanges.cs @@ -3,8 +3,9 @@ using System.Collections.Generic; using System.Text.RegularExpressions; namespace SourceGit.Commands { - public class QueryLocalChanges : Command { - private static readonly Regex REG_FORMAT = new Regex(@"^(\s?[\w\?]{1,4})\s+(.+)$"); + public partial class QueryLocalChanges : Command { + [GeneratedRegex(@"^(\s?[\w\?]{1,4})\s+(.+)$")] + private static partial Regex REG_FORMAT(); private static readonly string[] UNTRACKED = [ "no", "all" ]; public QueryLocalChanges(string repo, bool includeUntracked = true) { @@ -19,7 +20,7 @@ namespace SourceGit.Commands { } protected override void OnReadline(string line) { - var match = REG_FORMAT.Match(line); + var match = REG_FORMAT().Match(line); if (!match.Success) return; if (line.EndsWith("/", StringComparison.Ordinal)) return; // Ignore changes with git-worktree diff --git a/src/Commands/QueryRemotes.cs b/src/Commands/QueryRemotes.cs index e8e21b4a..f301339f 100644 --- a/src/Commands/QueryRemotes.cs +++ b/src/Commands/QueryRemotes.cs @@ -2,8 +2,9 @@ using System.Text.RegularExpressions; namespace SourceGit.Commands { - public class QueryRemotes : Command { - private static readonly Regex REG_REMOTE = new Regex(@"^([\w\.\-]+)\s*(\S+).*$"); + public partial class QueryRemotes : Command { + [GeneratedRegex(@"^([\w\.\-]+)\s*(\S+).*$")] + private static partial Regex REG_REMOTE(); public QueryRemotes(string repo) { WorkingDirectory = repo; @@ -17,7 +18,7 @@ namespace SourceGit.Commands { } protected override void OnReadline(string line) { - var match = REG_REMOTE.Match(line); + var match = REG_REMOTE().Match(line); if (!match.Success) return; var remote = new Models.Remote() { diff --git a/src/Commands/QueryRevisionObjects.cs b/src/Commands/QueryRevisionObjects.cs index b0c48f2a..4dc0dafe 100644 --- a/src/Commands/QueryRevisionObjects.cs +++ b/src/Commands/QueryRevisionObjects.cs @@ -2,8 +2,10 @@ using System.Text.RegularExpressions; namespace SourceGit.Commands { - public class QueryRevisionObjects : Command { - private static readonly Regex REG_FORMAT = new Regex(@"^\d+\s+(\w+)\s+([0-9a-f]+)\s+(.*)$"); + public partial class QueryRevisionObjects : Command { + + [GeneratedRegex(@"^\d+\s+(\w+)\s+([0-9a-f]+)\s+(.*)$")] + private static partial Regex REG_FORMAT(); private List objects = new List(); public QueryRevisionObjects(string repo, string sha) { @@ -18,7 +20,7 @@ namespace SourceGit.Commands { } protected override void OnReadline(string line) { - var match = REG_FORMAT.Match(line); + var match = REG_FORMAT().Match(line); if (!match.Success) return; var obj = new Models.Object(); diff --git a/src/Commands/QueryStagedFileBlobGuid.cs b/src/Commands/QueryStagedFileBlobGuid.cs index 4a1c30e2..b2b21c6b 100644 --- a/src/Commands/QueryStagedFileBlobGuid.cs +++ b/src/Commands/QueryStagedFileBlobGuid.cs @@ -1,8 +1,9 @@ using System.Text.RegularExpressions; namespace SourceGit.Commands { - public class QueryStagedFileBlobGuid : Command { - private static readonly Regex REG_FORMAT = new Regex(@"^\d+\s+([0-9a-f]+)\s+.*$"); + public partial class QueryStagedFileBlobGuid : Command { + [GeneratedRegex(@"^\d+\s+([0-9a-f]+)\s+.*$")] + private static partial Regex REG_FORMAT(); public QueryStagedFileBlobGuid(string repo, string file) { WorkingDirectory = repo; @@ -12,7 +13,7 @@ namespace SourceGit.Commands { public string Result() { var rs = ReadToEnd(); - var match = REG_FORMAT.Match(rs.StdOut.Trim()); + var match = REG_FORMAT().Match(rs.StdOut.Trim()); if (match.Success) { return match.Groups[1].Value; } diff --git a/src/Commands/QueryStashChanges.cs b/src/Commands/QueryStashChanges.cs index c2d50d45..2f9d7312 100644 --- a/src/Commands/QueryStashChanges.cs +++ b/src/Commands/QueryStashChanges.cs @@ -2,8 +2,10 @@ using System.Text.RegularExpressions; namespace SourceGit.Commands { - public class QueryStashChanges : Command { - private static readonly Regex REG_FORMAT = new Regex(@"^(\s?[\w\?]{1,4})\s+(.+)$"); + public partial class QueryStashChanges : Command { + + [GeneratedRegex(@"^(\s?[\w\?]{1,4})\s+(.+)$")] + private static partial Regex REG_FORMAT(); public QueryStashChanges(string repo, string sha) { WorkingDirectory = repo; @@ -17,7 +19,7 @@ namespace SourceGit.Commands { } protected override void OnReadline(string line) { - var match = REG_FORMAT.Match(line); + var match = REG_FORMAT().Match(line); if (!match.Success) return; var change = new Models.Change() { Path = match.Groups[2].Value }; diff --git a/src/Commands/QueryStashes.cs b/src/Commands/QueryStashes.cs index 7e159500..be51849b 100644 --- a/src/Commands/QueryStashes.cs +++ b/src/Commands/QueryStashes.cs @@ -3,8 +3,10 @@ using System.Collections.Generic; using System.Text.RegularExpressions; namespace SourceGit.Commands { - public class QueryStashes : Command { - private static readonly Regex REG_STASH = new Regex(@"^Reflog: refs/(stash@\{\d+\}).*$"); + public partial class QueryStashes : Command { + + [GeneratedRegex(@"^Reflog: refs/(stash@\{\d+\}).*$")] + private static partial Regex REG_STASH(); public QueryStashes(string repo) { WorkingDirectory = repo; @@ -28,7 +30,7 @@ namespace SourceGit.Commands { if (_current == null) return; if (line.StartsWith("Reflog: refs/stash@", StringComparison.Ordinal)) { - var match = REG_STASH.Match(line); + var match = REG_STASH().Match(line); if (match.Success) _current.Name = match.Groups[1].Value; } else if (line.StartsWith("Reflog message: ", StringComparison.Ordinal)) { _current.Message = line.Substring(16); diff --git a/src/Commands/QuerySubmodules.cs b/src/Commands/QuerySubmodules.cs index 8a581f93..fc2a522f 100644 --- a/src/Commands/QuerySubmodules.cs +++ b/src/Commands/QuerySubmodules.cs @@ -2,9 +2,11 @@ using System.Text.RegularExpressions; namespace SourceGit.Commands { - public class QuerySubmodules : Command { - private readonly Regex REG_FORMAT1 = new Regex(@"^[\-\+ ][0-9a-f]+\s(.*)\s\(.*\)$"); - private readonly Regex REG_FORMAT2 = new Regex(@"^[\-\+ ][0-9a-f]+\s(.*)$"); + public partial class QuerySubmodules : Command { + [GeneratedRegex(@"^[\-\+ ][0-9a-f]+\s(.*)\s\(.*\)$")] + private static partial Regex REG_FORMAT1(); + [GeneratedRegex(@"^[\-\+ ][0-9a-f]+\s(.*)$")] + private static partial Regex REG_FORMAT2(); public QuerySubmodules(string repo) { WorkingDirectory = repo; @@ -18,13 +20,13 @@ namespace SourceGit.Commands { } protected override void OnReadline(string line) { - var match = REG_FORMAT1.Match(line); + var match = REG_FORMAT1().Match(line); if (match.Success) { _submodules.Add(match.Groups[1].Value); return; } - match = REG_FORMAT2.Match(line); + match = REG_FORMAT2().Match(line); if (match.Success) { _submodules.Add(match.Groups[1].Value); } diff --git a/src/Models/DiffResult.cs b/src/Models/DiffResult.cs index a8266b87..204f509e 100644 --- a/src/Models/DiffResult.cs +++ b/src/Models/DiffResult.cs @@ -49,7 +49,7 @@ namespace SourceGit.Models { } } - public class TextDiff { + public partial class TextDiff { public string File { get; set; } = string.Empty; public List Lines { get; set; } = new List(); public int MaxLineNumber = 0; @@ -282,11 +282,14 @@ namespace SourceGit.Models { builder.Append("\n"); System.IO.File.WriteAllText(output, builder.ToString()); } + + [GeneratedRegex(@"^@@ \-(\d+),?\d* \+(\d+),?\d* @@")] + private static partial Regex indicatorRegex(); private bool ProcessIndicatorForPatch(StringBuilder builder, TextDiffLine indicator, int idx, int start, int end, int ignoreRemoves, int ignoreAdds, bool revert, bool tailed) { - var indicatorRegex = new Regex(@"^@@ \-(\d+),?\d* \+(\d+),?\d* @@"); + - var match = indicatorRegex.Match(indicator.Content); + var match = indicatorRegex().Match(indicator.Content); var oldStart = int.Parse(match.Groups[1].Value); var newStart = int.Parse(match.Groups[2].Value) + ignoreRemoves - ignoreAdds; var oldCount = 0; @@ -336,9 +339,8 @@ namespace SourceGit.Models { } private bool ProcessIndicatorForPatchSingleSide(StringBuilder builder, TextDiffLine indicator, int idx, int start, int end, int ignoreRemoves, int ignoreAdds, bool revert, bool isOldSide, bool tailed) { - var indicatorRegex = new Regex(@"^@@ \-(\d+),?\d* \+(\d+),?\d* @@"); - var match = indicatorRegex.Match(indicator.Content); + var match = indicatorRegex().Match(indicator.Content); var oldStart = int.Parse(match.Groups[1].Value); var newStart = int.Parse(match.Groups[2].Value) + ignoreRemoves - ignoreAdds; var oldCount = 0; diff --git a/src/Models/Remote.cs b/src/Models/Remote.cs index 021ccc67..fb3ae399 100644 --- a/src/Models/Remote.cs +++ b/src/Models/Remote.cs @@ -1,11 +1,20 @@ using System.Text.RegularExpressions; namespace SourceGit.Models { - public class Remote { + public partial class Remote { + + [GeneratedRegex(@"^http[s]?://([\w\-]+@)?[\w\.\-]+(\:[0-9]+)?/[\w\-]+/[\w\-\.]+\.git$")] + private static partial Regex regex1(); + + [GeneratedRegex(@"^[\w\-]+@[\w\.\-]+(\:[0-9]+)?:[\w\-]+/[\w\-\.]+\.git$")] + private static partial Regex regex2(); + [GeneratedRegex(@"^ssh://([\w\-]+@)?[\w\.\-]+(\:[0-9]+)?/[\w\-]+/[\w\-\.]+\.git$")] + private static partial Regex regex3(); + private static readonly Regex[] URL_FORMATS = [ - new Regex(@"^http[s]?://([\w\-]+@)?[\w\.\-]+(\:[0-9]+)?/[\w\-]+/[\w\-\.]+\.git$"), - new Regex(@"^[\w\-]+@[\w\.\-]+(\:[0-9]+)?:[\w\-]+/[\w\-\.]+\.git$"), - new Regex(@"^ssh://([\w\-]+@)?[\w\.\-]+(\:[0-9]+)?/[\w\-]+/[\w\-\.]+\.git$"), + regex1(), + regex2(), + regex3(), ]; public string Name { get; set; } diff --git a/src/ViewModels/InitGitFlow.cs b/src/ViewModels/InitGitFlow.cs index b63db27e..7a499448 100644 --- a/src/ViewModels/InitGitFlow.cs +++ b/src/ViewModels/InitGitFlow.cs @@ -3,8 +3,10 @@ using System.Text.RegularExpressions; using System.Threading.Tasks; namespace SourceGit.ViewModels { - public class InitGitFlow : Popup { - private static readonly Regex TAG_PREFIX = new Regex(@"^[\w\-/\.]+$"); + public partial class InitGitFlow : Popup { + + [GeneratedRegex(@"^[\w\-/\.]+$")] + private static partial Regex TAG_PREFIX(); [Required(ErrorMessage = "Master branch name is required!!!")] [RegularExpression(@"^[\w\-/\.]+$", ErrorMessage = "Bad branch name format!")] @@ -63,7 +65,7 @@ namespace SourceGit.ViewModels { } public static ValidationResult ValidateTagPrefix(string tagPrefix, ValidationContext ctx) { - if (!string.IsNullOrWhiteSpace(tagPrefix) && !TAG_PREFIX.IsMatch(tagPrefix)) { + if (!string.IsNullOrWhiteSpace(tagPrefix) && !TAG_PREFIX().IsMatch(tagPrefix)) { return new ValidationResult("Bad tag prefix format!"); }