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:
parent
a3ce9e9606
commit
80b1ad21d7
1 changed files with 400 additions and 103 deletions
|
|
@ -37,13 +37,13 @@ public class McpClientToolTests : ClientServerTestBase
|
|||
[McpServerTool]
|
||||
public static ImageContentBlock ImageTool() =>
|
||||
new()
|
||||
{ Data = Convert.ToBase64String(Encoding.UTF8.GetBytes("fake-image-data")), MimeType = "image/png" };
|
||||
{ Data = System.Text.Encoding.UTF8.GetBytes(Convert.ToBase64String(Encoding.UTF8.GetBytes("fake-image-data"))), MimeType = "image/png" };
|
||||
|
||||
// Tool that returns audio content as single ContentBlock
|
||||
[McpServerTool]
|
||||
public static AudioContentBlock AudioTool() =>
|
||||
new()
|
||||
{ Data = Convert.ToBase64String(Encoding.UTF8.GetBytes("fake-audio-data")), MimeType = "audio/mp3" };
|
||||
{ Data = System.Text.Encoding.UTF8.GetBytes(Convert.ToBase64String(Encoding.UTF8.GetBytes("fake-audio-data"))), MimeType = "audio/mp3" };
|
||||
|
||||
// Tool that returns embedded resource
|
||||
[McpServerTool]
|
||||
|
|
@ -103,7 +103,7 @@ public class McpClientToolTests : ClientServerTestBase
|
|||
[McpServerTool]
|
||||
public static IEnumerable<ContentBlock> MixedWithNonConvertibleTool()
|
||||
{
|
||||
yield return new ImageContentBlock { Data = Convert.ToBase64String(Encoding.UTF8.GetBytes("image-data")), MimeType = "image/png" };
|
||||
yield return new ImageContentBlock { Data = System.Text.Encoding.UTF8.GetBytes(Convert.ToBase64String(Encoding.UTF8.GetBytes("image-data"))), MimeType = "image/png" };
|
||||
yield return new ResourceLinkBlock { Uri = "file://linked.txt", Name = "linked.txt" };
|
||||
}
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ public class McpClientToolTests : ClientServerTestBase
|
|||
Resource = new BlobResourceContents
|
||||
{
|
||||
Uri = "data://blob",
|
||||
Blob = Convert.ToBase64String(Encoding.UTF8.GetBytes("binary-data")),
|
||||
Blob = System.Text.Encoding.UTF8.GetBytes(Convert.ToBase64String(Encoding.UTF8.GetBytes("binary-data"))),
|
||||
MimeType = "application/octet-stream"
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue