Skip to content

Add ControlBuilder.Memory#192

Merged
alexrp merged 2 commits intovezel-dev:masterfrom
scottbilas:api/add-cb-memory
Aug 19, 2024
Merged

Add ControlBuilder.Memory#192
alexrp merged 2 commits intovezel-dev:masterfrom
scottbilas:api/add-cb-memory

Conversation

@scottbilas
Copy link
Copy Markdown
Contributor

Span<> isn't available inside of an async method, which makes it more difficult to use ControlBuilder without an alloc.

The underlying type is ArrayBufferWriter<>, which exports a Memory, so this change just exposes that API to ControlBuilder as well.

@scottbilas scottbilas marked this pull request as ready for review August 14, 2024 15:15
@scottbilas scottbilas requested a review from a team as a code owner August 14, 2024 15:15
Comment thread src/core/PublicAPI.Unshipped.txt Outdated
@alexrp
Copy link
Copy Markdown
Member

alexrp commented Aug 16, 2024

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?

@scottbilas
Copy link
Copy Markdown
Contributor Author

scottbilas commented Aug 16, 2024

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().

@alexrp alexrp force-pushed the api/add-cb-memory branch from 8353b4a to 643a185 Compare August 19, 2024 20:10
@alexrp alexrp enabled auto-merge (rebase) August 19, 2024 20:11
@alexrp alexrp merged commit 39950da into vezel-dev:master Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants