Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use BinaryData.Empty instead of bespoke solution in SCM and Azure.Core #46669

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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