You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/ModelContextProtocol.Core/Protocol/ContentBlock.cs
+20-2Lines changed: 20 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -388,6 +388,7 @@ public sealed class TextContentBlock : ContentBlock
388
388
publicsealedclassImageContentBlock:ContentBlock
389
389
{
390
390
privatebyte[]?_decodedData;
391
+
privateReadOnlyMemory<byte>_data;
391
392
392
393
/// <inheritdoc/>
393
394
publicoverridestringType=>"image";
@@ -399,7 +400,15 @@ public sealed class ImageContentBlock : ContentBlock
399
400
/// This is a zero-copy representation of the wire payload of this item. Setting this value will invalidate any cached value of <see cref="DecodedData"/>.
400
401
/// </remarks>
401
402
[JsonPropertyName("data")]
402
-
publicrequiredReadOnlyMemory<byte>Data{get;set;}
403
+
publicrequiredReadOnlyMemory<byte>Data
404
+
{
405
+
get=>_data;
406
+
set
407
+
{
408
+
_data=value;
409
+
_decodedData=null;// Invalidate cache
410
+
}
411
+
}
403
412
404
413
/// <summary>
405
414
/// Gets the decoded image data represented by <see cref="Data"/>.
@@ -443,6 +452,7 @@ public ReadOnlyMemory<byte> DecodedData
443
452
publicsealedclassAudioContentBlock:ContentBlock
444
453
{
445
454
privatebyte[]?_decodedData;
455
+
privateReadOnlyMemory<byte>_data;
446
456
447
457
/// <inheritdoc/>
448
458
publicoverridestringType=>"audio";
@@ -454,7 +464,15 @@ public sealed class AudioContentBlock : ContentBlock
454
464
/// This is a zero-copy representation of the wire payload of this item. Setting this value will invalidate any cached value of <see cref="DecodedData"/>.
455
465
/// </remarks>
456
466
[JsonPropertyName("data")]
457
-
publicrequiredReadOnlyMemory<byte>Data{get;set;}
467
+
publicrequiredReadOnlyMemory<byte>Data
468
+
{
469
+
get=>_data;
470
+
set
471
+
{
472
+
_data=value;
473
+
_decodedData=null;// Invalidate cache
474
+
}
475
+
}
458
476
459
477
/// <summary>
460
478
/// Gets the decoded audio data represented by <see cref="Data"/>.
0 commit comments