Skip to content

Commit

Permalink
Use BinaryData.Empty instead of bespoke solution in SCM and Azure.Core (
Browse files Browse the repository at this point in the history
#46669)

* Fix 41034

* update CHANGELOG
  • Loading branch information
annelo-msft authored Oct 16, 2024
1 parent c9fa717 commit 601b82b
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
2 changes: 2 additions & 0 deletions sdk/core/Azure.Core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

### Other Changes

- Use `BinaryData.Empty` for `PipelineResponse.Content` when HTTP message has no content.

## 1.44.1 (2024-10-09)

### Other Changes
Expand Down
5 changes: 1 addition & 4 deletions sdk/core/Azure.Core/src/Response.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ public abstract class Response : IDisposable
/// </summary>
public virtual ResponseHeaders Headers => new ResponseHeaders(this);

// TODO(matell): The .NET Framework team plans to add BinaryData.Empty in dotnet/runtime#49670, and we can use it then.
private static readonly BinaryData s_EmptyBinaryData = new BinaryData(Array.Empty<byte>());

/// <summary>
/// Gets the contents of HTTP response, if it is available.
/// </summary>
Expand All @@ -56,7 +53,7 @@ public virtual BinaryData Content
{
if (ContentStream == null)
{
return s_EmptyBinaryData;
return BinaryData.Empty;
}

MemoryStream? memoryContent = ContentStream as MemoryStream;
Expand Down
2 changes: 2 additions & 0 deletions sdk/core/System.ClientModel/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

### Other Changes

- Use `BinaryData.Empty` for `PipelineResponse.Content` when HTTP message has no content ([#46669](https://github.com/Azure/azure-sdk-for-net/pull/46669)).

## 1.2.1 (2024-10-09)

### Bugs Fixed
Expand Down
3 changes: 0 additions & 3 deletions sdk/core/System.ClientModel/src/Message/PipelineResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ namespace System.ClientModel.Primitives;
/// </summary>
public abstract class PipelineResponse : IDisposable
{
// TODO(matell): The .NET Framework team plans to add BinaryData.Empty in dotnet/runtime#49670, and we can use it then.
internal static readonly BinaryData s_EmptyBinaryData = new(Array.Empty<byte>());

/// <summary>
/// Gets the status code of the HTTP response.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private async ValueTask<BinaryData> BufferContentSyncOrAsync(CancellationToken c
{
// Content is not buffered but there is no source stream.
// Our contract from Azure.Core is to return BinaryData.Empty in this case.
_bufferedContent = s_EmptyBinaryData;
_bufferedContent = BinaryData.Empty;
return _bufferedContent;
}

Expand Down

0 comments on commit 601b82b

Please sign in to comment.