Skip to content

Commit f85f8f8

Browse files
scottlerchclaude
andauthored
#131 Add the missing InvalidHostnames key to Core's Resources.resx (#133)
The strongly-typed Resources.InvalidHostnames getter existed but Core's Resources.resx had no matching <data name="InvalidHostnames"> entry, so it resolved to null. HostsEntry.ValidateHostnames does `SetError(nameof(HostNames), !_hostnamesValid ? Resources.InvalidHostnames : null)` and SetError treats null as "clear the error", so an invalid hostname surfaced a BLANK IDataErrorInfo message in both the classic and modern editions instead of "Invalid host names". Add the key ("Invalid host names", matching the WinForm resource) plus a regression test asserting the invalid-hostname error message is the non-empty resource string. Split out of the larger CI/coverage PR #132 so the user-facing fix can land on its own. Closes #131 Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 00fcddf commit f85f8f8

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

HostsFileEditor.Core.Tests/HostsEntryTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,20 @@ public void Invalid_Hostname_AfterEdit()
8181
entry.Valid.ShouldBeFalse();
8282
}
8383

84+
// Regression for #131: Resources.InvalidHostnames had no matching key in Core's Resources.resx,
85+
// so it resolved to null and SetError(null) cleared the error — an invalid hostname surfaced a
86+
// BLANK IDataErrorInfo message (rather than "Invalid host names") in both editions.
87+
[TestMethod]
88+
public void Invalid_Hostname_HasNonBlankErrorMessage()
89+
{
90+
var entry = new HostsEntry("127.0.0.1 goodhost");
91+
entry.HostNames = "bad@host"; // invalid character
92+
93+
entry.Valid.ShouldBeFalse();
94+
entry["HostNames"].ShouldNotBeNullOrEmpty();
95+
entry["HostNames"].ShouldBe(HostsFileEditor.Properties.Resources.InvalidHostnames);
96+
}
97+
8498
[TestMethod]
8599
public void ToString_ReturnsExpected()
86100
{

0 commit comments

Comments
 (0)