Skip to content

Commit 601b82b

Browse files
authored
Use BinaryData.Empty instead of bespoke solution in SCM and Azure.Core (Azure#46669)
* Fix 41034 * update CHANGELOG
1 parent c9fa717 commit 601b82b

File tree

5 files changed

+6
-8
lines changed

5 files changed

+6
-8
lines changed

sdk/core/Azure.Core/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
### Other Changes
1212

13+
- Use `BinaryData.Empty` for `PipelineResponse.Content` when HTTP message has no content.
14+
1315
## 1.44.1 (2024-10-09)
1416

1517
### Other Changes

sdk/core/Azure.Core/src/Response.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ public abstract class Response : IDisposable
4141
/// </summary>
4242
public virtual ResponseHeaders Headers => new ResponseHeaders(this);
4343

44-
// TODO(matell): The .NET Framework team plans to add BinaryData.Empty in dotnet/runtime#49670, and we can use it then.
45-
private static readonly BinaryData s_EmptyBinaryData = new BinaryData(Array.Empty<byte>());
46-
4744
/// <summary>
4845
/// Gets the contents of HTTP response, if it is available.
4946
/// </summary>
@@ -56,7 +53,7 @@ public virtual BinaryData Content
5653
{
5754
if (ContentStream == null)
5855
{
59-
return s_EmptyBinaryData;
56+
return BinaryData.Empty;
6057
}
6158

6259
MemoryStream? memoryContent = ContentStream as MemoryStream;

sdk/core/System.ClientModel/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
### Other Changes
1212

13+
- Use `BinaryData.Empty` for `PipelineResponse.Content` when HTTP message has no content ([#46669](https://github.com/Azure/azure-sdk-for-net/pull/46669)).
14+
1315
## 1.2.1 (2024-10-09)
1416

1517
### Bugs Fixed

sdk/core/System.ClientModel/src/Message/PipelineResponse.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ namespace System.ClientModel.Primitives;
1212
/// </summary>
1313
public abstract class PipelineResponse : IDisposable
1414
{
15-
// TODO(matell): The .NET Framework team plans to add BinaryData.Empty in dotnet/runtime#49670, and we can use it then.
16-
internal static readonly BinaryData s_EmptyBinaryData = new(Array.Empty<byte>());
17-
1815
/// <summary>
1916
/// Gets the status code of the HTTP response.
2017
/// </summary>

sdk/core/System.ClientModel/src/Pipeline/HttpClientPipelineTransport.Response.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private async ValueTask<BinaryData> BufferContentSyncOrAsync(CancellationToken c
100100
{
101101
// Content is not buffered but there is no source stream.
102102
// Our contract from Azure.Core is to return BinaryData.Empty in this case.
103-
_bufferedContent = s_EmptyBinaryData;
103+
_bufferedContent = BinaryData.Empty;
104104
return _bufferedContent;
105105
}
106106

0 commit comments

Comments
 (0)