Use ReadOnlyMemory<byte> for binary data to eliminate UTF-16 transcoding (#1070)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: ericstj <8918108+ericstj@users.noreply.github.com>
Co-authored-by: Eric StJohn <ericstj@microsoft.com>
This commit is contained in:
Copilot 2026-02-19 14:08:05 -08:00 • committed by GitHub
commit 80b1ad21d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -95,7 +95,7 @@ public class AIContentExtensionsTests
Content =
[
new TextContentBlock { Text = "Text result" },
new ImageContentBlock { Data = Convert.ToBase64String([1, 2, 3]), MimeType = "image/png" }
ImageContentBlock.FromBytes((byte[])[1, 2, 3], "image/png")
]
};
@ -301,7 +301,7 @@ public class AIContentExtensionsTests
var contentBlock = dataContent.ToContentBlock();
var imageBlock = Assert.IsType<ImageContentBlock>(contentBlock);
Assert.Equal(Convert.ToBase64String(imageData), imageBlock.Data);
Assert.Equal(imageData, imageBlock.DecodedData);
Assert.Equal("image/png", imageBlock.MimeType);
Assert.NotNull(imageBlock.Meta);
Assert.True(imageBlock.Meta.ContainsKey("dimensions"));