Closed scottbilas closed 2 months ago
I don't have any particular problem with taking this change, but just out of curiosity, what's the situation that made the Memory
property necessary?
The use case is when wanting to pass ControlBuilder
memory to an async utility function. The compiler will not permit receiving it as a ReadOnlySpan<char>
. So ControlBuilder.Span
is unusable.
A good example of this is Terminal.OutAsync(ReadOnlyMemory<char>)
. I can't get at the underlying ArrayBufferWriter
array memory in the ControlBuilder
, so the only other option is an unfortunate allocating ToString()
.
Span<>
isn't available inside of an async method, which makes it more difficult to useControlBuilder
without an alloc.The underlying type is
ArrayBufferWriter<>
, which exports aMemory
, so this change just exposes that API toControlBuilder
as well.