Skip to content

Commit f65737a

Browse files
NeWbY100claude
andcommitted
fix(inspector): show encoding name in the combo selection box
The themed ComboBox's selection box renders via ToString() (DisplayMemberPath only drives the dropdown items), so it showed the record's default "TextEncodingOption { ... }". Override ToString() to return DisplayName. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 1dc0161 commit f65737a

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

ReScene.NET.Tests/TextEncodingOptionsTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,15 @@ public void AllEntries_HaveNonNullEncoding()
3131
{
3232
Assert.All(TextEncodingOptions.All, e => Assert.NotNull(e.Encoding));
3333
}
34+
35+
[Fact]
36+
public void ToString_ReturnsDisplayName()
37+
{
38+
// The encoding ComboBox's selection box renders via ToString(), so it must be the
39+
// friendly name — not the record's default "TextEncodingOption { ... }" form.
40+
var utf8 = TextEncodingOptions.All[0];
41+
42+
Assert.Equal("UTF-8", utf8.ToString());
43+
Assert.All(TextEncodingOptions.All, e => Assert.Equal(e.DisplayName, e.ToString()));
44+
}
3445
}

ReScene.NET/Helpers/TextEncodingOption.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
namespace ReScene.NET.Helpers;
44

55
/// <summary>A selectable text encoding: a human-friendly name plus the backing <see cref="Encoding"/>.</summary>
6-
public sealed record TextEncodingOption(string DisplayName, Encoding Encoding);
6+
public sealed record TextEncodingOption(string DisplayName, Encoding Encoding)
7+
{
8+
// The themed ComboBox's selection box falls back to ToString() (DisplayMemberPath only drives
9+
// the dropdown items), so present the friendly name rather than the record's default rendering.
10+
public override string ToString() => DisplayName;
11+
}
712

813
/// <summary>
914
/// The curated set of encodings offered by the Inspector's Text view. CP437 and Windows-1252 are not

0 commit comments

Comments
 (0)