You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
More BytesRef/UnicodeUtil UTF-8-to-string fixes, #1024 (#1171)
* UnicodeUtil: Change UTF8toUTF16 to throw DecoderFallbackException, #1024
Changed UTF8toUTF16 method to throw DecoderFallbackException instead of FormatException
when invalid UTF-8 is encountered. This aligns with .NET conventions where
DecoderFallbackException is the appropriate exception type for character decoding
issues (equivalent to Java's CharacterCodingException).
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* BytesRef: Use Utf8ToStringWithFallback in DebuggerDisplay, #1024
Changed DebuggerDisplay attribute to use Utf8ToStringWithFallback() instead of
Utf8ToString() to prevent exceptions when debugging BytesRef instances that
contain invalid UTF-8 sequences.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* BytesRef: Show "Invalid UTF-8" label and string-before-bytes in DebuggerDisplay, #1024
Address NightOwl888's review on #1171. The prior DebuggerDisplay used
Utf8ToStringWithFallback, which silently substitutes U+FFFD for malformed
input — indistinguishable from a real U+FFFD in the data. Switch to a
private DebuggerDisplay property that uses TryUtf8ToString, shows the
literal "Invalid UTF-8" on decode failure, and puts the decoded string
before the raw bytes.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* UnicodeUtil: Fix UTF8toUTF16WithFallback byte[] overload to use fallback path, #1024
The byte[]/offset/length overload was delegating to the throwing
UTF8toUTF16 variant, so callers like BytesRef.Utf8ToStringWithFallback()
would throw DecoderFallbackException on invalid UTF-8 instead of
substituting U+FFFD as the method name and docs promise. Delegate to
the ReadOnlySpan<byte> fallback overload and add a regression test
covering the 4-arg signature with a non-zero offset.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>
publicsealedclassBytesRef:IComparable<BytesRef>,IComparable,IEquatable<BytesRef>// LUCENENET specific - implemented IComparable for FieldComparator, IEquatable<BytesRef>
50
50
{
51
51
/// <summary>
@@ -317,6 +317,11 @@ public bool TryUtf8ToString([NotNullWhen(true)] out string? result)
317
317
}
318
318
#nullable restore
319
319
320
+
// LUCENENET specific: "Invalid UTF-8" disambiguates a decode failure from a legitimate U+FFFD in the data.
321
+
[SuppressMessage("CodeQuality","IDE0051:Remove unused private members",Justification="Referenced by DebuggerDisplay attribute")]
0 commit comments