Skip to content

Remove ICharSequence from ICharTermAttribute and buffer types #1337

Description

@paulirwin

Is there an existing issue for this?

  • I have searched the existing issues

Task description

Follow-up to #1315 (step 2-3 of the plan in #1315 (comment)).

Now that IBufferWriter<char> and Append(ReadOnlySpan<char>) are going to be in place (as of #1315), we can move off ICharSequence on the buffer types.

Phase 1 - Rework callers (non-breaking)

Replace internal logic that consumes ICharSequence (from CharTermAttribute, OpenStringBuilder, and other buffer types) with ReadOnlySpan<char> or ReadOnlyMemory<char> where appropriate. This is purely internal call-site refactoring and must land before the removal below.

Phase 2 - Remove the implementation (breaking)

Remove the ICharSequence implementation from ICharTermAttribute and all buffer types at the same time:

  • Drop SubSequence() and HasValue.
  • Promote any still-needed members directly onto ICharTermAttribute.

Known consequence

Because the compiler does not honor a concrete type's implicit operators through an interface, callers will need to call .AsSpan() explicitly on ICharTermAttribute to pass it into ReadOnlySpan<char> APIs. On the upside, once ICharSequence is gone there is no risk of accidentally routing a value into an ICharSequence API when ReadOnlySpan<char> is the better choice.

This is a breaking change and should be done in a beta release before 4.x final.

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions