Skip to content

Commit

Permalink
Merge branch 'main' into users/pahallis/sdk-emitter-pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
hallipr authored Oct 16, 2024
2 parents 472d943 + dd38ca7 commit 5e4c0bd
Show file tree
Hide file tree
Showing 22 changed files with 73 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ extends:
template: /eng/pipelines/templates/stages/1es-redirect.yml
parameters:
stages:

# Build stage
# Responsible for building the autorest generator and typespec emitter packages
# Produces the artifact `build_artifacts` which contains the following:
Expand Down
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
10 changes: 10 additions & 0 deletions sdk/iothub/Azure.ResourceManager.IotHub/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Release History

## 1.2.0-beta.2 (Unreleased)

### Features Added

### Breaking Changes

### Bugs Fixed

### Other Changes

## 1.2.0-beta.1 (2024-10-15)

### Features Added
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.2.0-beta.1</Version>
<Version>1.2.0-beta.2</Version>
<!--The ApiCompatVersion is managed automatically and should not generally be modified manually.-->
<ApiCompatVersion>1.1.1</ApiCompatVersion>
<PackageId>Azure.ResourceManager.IotHub</PackageId>
Expand Down
10 changes: 10 additions & 0 deletions sdk/logic/Azure.ResourceManager.Logic/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Release History

## 1.2.0-beta.2 (Unreleased)

### Features Added

### Breaking Changes

### Bugs Fixed

### Other Changes

## 1.2.0-beta.1 (2024-10-15)

### Features Added
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.2.0-beta.1</Version>
<Version>1.2.0-beta.2</Version>
<!--The ApiCompatVersion is managed automatically and should not generally be modified manually.-->
<ApiCompatVersion>1.1.0</ApiCompatVersion>
<PackageId>Azure.ResourceManager.Logic</PackageId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Release History

## 1.3.0-beta.2 (Unreleased)

### Features Added

### Breaking Changes

### Bugs Fixed

### Other Changes

## 1.3.0-beta.1 (2024-10-15)

### Features Added
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.3.0-beta.1</Version>
<Version>1.3.0-beta.2</Version>
<!--The ApiCompatVersion is managed automatically and should not generally be modified manually.-->
<ApiCompatVersion>1.2.2</ApiCompatVersion>
<PackageId>Azure.ResourceManager.OperationalInsights</PackageId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Release History

## 1.2.0-beta.2 (Unreleased)

### Features Added

### Breaking Changes

### Bugs Fixed

### Other Changes

## 1.2.0-beta.1 (2024-10-15)

### Features Added
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.2.0-beta.1</Version>
<Version>1.2.0-beta.2</Version>
<!--The ApiCompatVersion is managed automatically and should not generally be modified manually.-->
<ApiCompatVersion>1.1.1</ApiCompatVersion>
<PackageId>Azure.ResourceManager.RecoveryServices</PackageId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ public DataTransferStatus GetTransferStatus()
/// Sets the completion status
/// </summary>
/// <param name="state"></param>
/// <returns>Returns whether or not the status has been changed/set</returns>
public bool TrySetTransferState(DataTransferState state)
/// <returns>Returns whether or not the status has been changed from its original state.</returns>
public bool SetTransferState(DataTransferState state)
{
if (_status.TrySetTransferStateChange(state))
if (_status.SetTransferStateChange(state))
{
if (DataTransferState.Completed == _status.State ||
DataTransferState.Paused == _status.State)
Expand All @@ -104,9 +104,9 @@ public bool TrySetTransferState(DataTransferState state)
return false;
}

public bool TrySetFailedItemsState() => _status.TrySetFailedItem();
public bool SetFailedItemsState() => _status.SetFailedItem();

public bool TrySetSkippedItemsState() => _status.TrySetSkippedItem();
public bool SetSkippedItemsState() => _status.SetSkippedItem();

internal bool CanPause()
=> DataTransferState.InProgress == _status.State;
Expand All @@ -119,7 +119,7 @@ public async Task PauseIfRunningAsync(CancellationToken cancellationToken)
}
CancellationHelper.ThrowIfCancellationRequested(cancellationToken);
// Call the inner cancellation token to stop the transfer job
TrySetTransferState(DataTransferState.Pausing);
SetTransferState(DataTransferState.Pausing);
if (TriggerCancellation())
{
// Wait until full pause has completed.
Expand Down
12 changes: 6 additions & 6 deletions sdk/storage/Azure.Storage.DataMovement/src/DataTransferStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ protected internal DataTransferStatus(DataTransferState state, bool hasFailureIt
///
/// This should only be triggered when a failed item has been seen.
/// </summary>
/// <returns>True if <see cref="HasFailedItems"/> was updated. False otherwise.</returns>
internal bool TrySetFailedItem()
/// <returns>True if this was the first time <see cref="HasFailedItems"/> was updated. False otherwise.</returns>
internal bool SetFailedItem()
{
return Interlocked.Exchange(ref _hasFailedItemValue, 1) != 1;
}
Expand All @@ -86,8 +86,8 @@ internal bool TrySetFailedItem()
///
/// This should only be triggered when a skipped item has been seen.
/// </summary>
/// /// <returns>True if <see cref="HasSkippedItems"/> was updated. False otherwise.</returns>
internal bool TrySetSkippedItem()
/// /// <returns>True if this was the first time <see cref="HasSkippedItems"/> was updated. False otherwise.</returns>
internal bool SetSkippedItem()
{
return Interlocked.Exchange(ref _hasSkippedItemValue, 1) != 1;
}
Expand All @@ -98,8 +98,8 @@ internal bool TrySetSkippedItem()
///
/// This should only be triggered when the state updates.
/// </summary>
/// <returns>True if <see cref="State"/> was updated. False otherwise.</returns>
internal bool TrySetTransferStateChange(DataTransferState state)
/// <returns>True if <see cref="State"/> was changed from its original state. False otherwise.</returns>
internal bool SetTransferStateChange(DataTransferState state)
{
return Interlocked.Exchange(ref _stateValue, (int)state) != (int)state;
}
Expand Down
6 changes: 3 additions & 3 deletions sdk/storage/Azure.Storage.DataMovement/src/JobPartInternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ internal async Task TriggerCancellationAsync()
/// <param name="transferState"></param>
internal async Task OnTransferStateChangedAsync(DataTransferState transferState)
{
if (JobPartStatus.TrySetTransferStateChange(transferState))
if (JobPartStatus.SetTransferStateChange(transferState))
{
// Progress tracking, do before invoking the event below
if (transferState == DataTransferState.InProgress)
Expand Down Expand Up @@ -355,7 +355,7 @@ await TransferSkippedEventHandler.RaiseAsync(

// Update the JobPartStatus. If was already updated (e.g. there was a failed item before)
// then don't raise the PartTransferStatusEventHandler
if (JobPartStatus.TrySetSkippedItem())
if (JobPartStatus.SetSkippedItem())
{
await PartTransferStatusEventHandler.RaiseAsync(
new TransferStatusEventArgs(
Expand Down Expand Up @@ -409,7 +409,7 @@ await TransferFailedEventHandler.RaiseAsync(

// Update the JobPartStatus. If was already updated (e.g. there was a failed item before)
// then don't raise the PartTransferStatusEventHandler
if (JobPartStatus.TrySetFailedItem())
if (JobPartStatus.SetFailedItem())
{
await PartTransferStatusEventHandler.RaiseAsync(
new TransferStatusEventArgs(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public override async IAsyncEnumerable<JobPartInternal> ProcessJobToJobPartAsync
{
if (!part.JobPartStatus.HasCompletedSuccessfully)
{
part.JobPartStatus.TrySetTransferStateChange(DataTransferState.Queued);
part.JobPartStatus.SetTransferStateChange(DataTransferState.Queued);
yield return part;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public override async IAsyncEnumerable<JobPartInternal> ProcessJobToJobPartAsync
{
if (!part.JobPartStatus.HasCompletedSuccessfully)
{
part.JobPartStatus.TrySetTransferStateChange(DataTransferState.Queued);
part.JobPartStatus.SetTransferStateChange(DataTransferState.Queued);
yield return part;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private TransferJobInternal(
Argument.AssertNotNull(clientDiagnostics, nameof(clientDiagnostics));

_dataTransfer = dataTransfer ?? throw Errors.ArgumentNull(nameof(dataTransfer));
_dataTransfer.TransferStatus.TrySetTransferStateChange(DataTransferState.Queued);
_dataTransfer.TransferStatus.SetTransferStateChange(DataTransferState.Queued);
_checkpointer = checkPointer;
_arrayPool = arrayPool;
_jobParts = new List<JobPartInternal>();
Expand Down Expand Up @@ -344,15 +344,15 @@ public async Task JobPartEvent(TransferStatusEventArgs args)
}
else if (jobPartStatus.HasFailedItems)
{
if (_dataTransfer._state.TrySetFailedItemsState())
if (_dataTransfer._state.SetFailedItemsState())
{
await SetCheckpointerStatus().ConfigureAwait(false);
await OnJobPartStatusChangedAsync().ConfigureAwait(false);
}
}
else if (jobPartStatus.HasSkippedItems)
{
if (_dataTransfer._state.TrySetSkippedItemsState())
if (_dataTransfer._state.SetSkippedItemsState())
{
await SetCheckpointerStatus().ConfigureAwait(false);
await OnJobPartStatusChangedAsync().ConfigureAwait(false);
Expand Down Expand Up @@ -387,7 +387,7 @@ public async Task JobPartEvent(TransferStatusEventArgs args)

public async Task OnJobStateChangedAsync(DataTransferState state)
{
if (_dataTransfer._state.TrySetTransferState(state))
if (_dataTransfer._state.SetTransferState(state))
{
// If we are in a final state, dispose the JobPartEvent handlers
if (state == DataTransferState.Completed ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public override async IAsyncEnumerable<JobPartInternal> ProcessJobToJobPartAsync
{
if (!part.JobPartStatus.HasCompletedSuccessfully)
{
part.JobPartStatus.TrySetTransferStateChange(DataTransferState.Queued);
part.JobPartStatus.SetTransferStateChange(DataTransferState.Queued);
yield return part;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,7 @@ public async Task TryPauseAsync()
Assert.AreEqual(DataTransferState.Pausing, transfer.TransferStatus.State);

// Assert
if (!transfer._state.TrySetTransferState(DataTransferState.Paused))
{
Assert.Fail("Unable to set the transfer status internally to the DataTransfer.");
}
Assert.IsTrue(transfer._state.SetTransferState(DataTransferState.Paused));

await pauseTask;

Expand Down

0 comments on commit 5e4c0bd

Please sign in to comment.