Severity: Info (doc/code mismatch — silently functional but misleading to users and reviewers)
File / line: src/Servy.Core/ServiceDependencies/ServiceDependenciesValidator.cs lines 8–16, 44
Code:
// Allowed characters: letters, digits, hyphen, underscore <-- comment
private static readonly Regex ValidServiceNameRegex =
new Regex(@"^[a-zA-Z0-9_.\-]+$", RegexOptions.Compiled, AppConfig.InputRegexTimeout); // <-- regex includes '.'
/// <summary>
/// Validates the input string containing service dependencies.
/// Service names must be separated by semicolons or new lines.
/// Each service name must contain only letters, digits, hyphens, or underscores. <-- doc
/// </summary>
...
if (!ValidServiceNameRegex.IsMatch(serviceName))
{
errors.Add(
$"Invalid service name '{serviceName}'. Only letters, digits, hyphens, and underscores are allowed." // <-- error msg
);
}
What's wrong: Three places (the inline comment, the <summary> XML doc, and the user-facing error message) all assert the dependency-name alphabet is [a-zA-Z0-9_-], but the actual regex character class is [a-zA-Z0-9_.\-] — it permits . (period). This is probably the correct regex (Windows SCM allows period in service names — e.g., a custom service MyApp.Updater), but the documentation everywhere insists otherwise. Net effect:
- A user who reads the docs will assume
MyApp.Updater is rejected as a dependency, when in fact it's accepted.
- A user who hits the validator with
MyApp@Updater and reads the error message will think they need to remove the @, then try MyApp.Updater and be (correctly) surprised that it works — but with no doc explaining why.
- A reviewer reading the regex sees
. and can't tell whether it's intentional or a typo (.\ is suspicious-looking) — the code itself doesn't justify the period.
Suggested fix: Pick one of the two contracts and align all four sites.
Option A (recommended — keep period, since Windows SCM allows it):
// Allowed characters: letters, digits, hyphen, underscore, period
private static readonly Regex ValidServiceNameRegex =
new Regex(@"^[a-zA-Z0-9_.\-]+$", RegexOptions.Compiled, AppConfig.InputRegexTimeout);
/// <summary>
/// ...
/// Each service name must contain only letters, digits, hyphens, underscores, or periods.
/// </summary>
...
errors.Add($"Invalid service name '{serviceName}'. Only letters, digits, hyphens, underscores, and periods are allowed.");
Option B (drop period — matches the doc but rejects legitimate Windows service names like MyApp.Updater):
private static readonly Regex ValidServiceNameRegex =
new Regex(@"^[a-zA-Z0-9_\-]+$", RegexOptions.Compiled, AppConfig.InputRegexTimeout);
Option A is what the codebase appears to actually want.
Severity: Info (doc/code mismatch — silently functional but misleading to users and reviewers)
File / line:
src/Servy.Core/ServiceDependencies/ServiceDependenciesValidator.cslines 8–16, 44Code:
What's wrong: Three places (the inline comment, the
<summary>XML doc, and the user-facing error message) all assert the dependency-name alphabet is[a-zA-Z0-9_-], but the actual regex character class is[a-zA-Z0-9_.\-]— it permits.(period). This is probably the correct regex (Windows SCM allows period in service names — e.g., a custom serviceMyApp.Updater), but the documentation everywhere insists otherwise. Net effect:MyApp.Updateris rejected as a dependency, when in fact it's accepted.MyApp@Updaterand reads the error message will think they need to remove the@, then tryMyApp.Updaterand be (correctly) surprised that it works — but with no doc explaining why..and can't tell whether it's intentional or a typo (.\is suspicious-looking) — the code itself doesn't justify the period.Suggested fix: Pick one of the two contracts and align all four sites.
Option A (recommended — keep period, since Windows SCM allows it):
Option B (drop period — matches the doc but rejects legitimate Windows service names like
MyApp.Updater):Option A is what the codebase appears to actually want.