Add Utf8.TryWrite (#83852)
authorStephen Toub <stoub@microsoft.com>
Thu, 6 Apr 2023 11:12:46 +0000 (07:12 -0400)
committerGitHub <noreply@github.com>
Thu, 6 Apr 2023 11:12:46 +0000 (07:12 -0400)
commit2c8cb129ed084e374f06eaa29f21e9ab0b9e8066
treefc6e5d89fa660690ac94949c154c79177255e899
parentcc0146487bd370083fbaf57d4e333b8bdc6ec60f
Add Utf8.TryWrite (#83852)

* Add Utf8.TryWrite

Initial implementation of Utf8.TryWriteUtf8. The performance of this won't be great at present, but will improve as our cores types add implementation of IUtf8SpanFormattable. For tests, I copy/pasted the tests we had for MemoryExtensions.TryWrite and searched/replaced to make them work for Utf8.TryWrite.

* Address PR feedback
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
src/libraries/System.Private.CoreLib/src/System/IUtf8SpanFormattable.cs [new file with mode: 0644]
src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8.cs
src/libraries/System.Runtime/ref/System.Runtime.cs
src/libraries/System.Runtime/tests/System.Runtime.Tests.csproj
src/libraries/System.Runtime/tests/System/Text/Unicode/Utf8Tests.TryWrite.cs [new file with mode: 0644]
src/libraries/System.Runtime/tests/System/Text/Unicode/Utf8Tests.cs