Skip to content

Add extension methods to PublishingStep & PublishingTask for direct Complete/Update operations #9995

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

Merged
merged 8 commits into from
Jun 24, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 23, 2025

This PR adds extension methods to PublishingStep and PublishingTask that allow users to directly perform completion and update operations without needing to manually interact with the IPublishingActivityProgressReporter.

Changes Made

New Extension Methods

Added PublishingExtensions class with the following methods:

For PublishingStep:

  • UpdateStatusAsync(string statusText) - Updates the step's status text
  • SucceedAsync(string? message) - Completes the step successfully
  • WarnAsync(string? message) - Completes the step with a warning
  • FailAsync(string? errorMessage) - Completes the step with an error

For PublishingTask:

  • UpdateStatusAsync(string statusText) - Updates the task's status text
  • SucceedAsync(string? message) - Completes the task successfully
  • WarnAsync(string? message) - Completes the task with a warning
  • FailAsync(string? errorMessage) - Completes the task with an error

Infrastructure Changes

  • Added internal Reporter property to both PublishingStep and PublishingTask to store reference to the creating progress reporter
  • Added StatusText property to PublishingStep to support status updates
  • Extended IPublishingActivityProgressReporter with UpdateStepAsync method
  • Updated both PublishingActivityProgressReporter and NullPublishingActivityProgressReporter to set reporter references and implement the new interface method

Usage Example

// Before: Manual reporter interaction
var step = await reporter.CreateStepAsync("Building images", cancellationToken);
await reporter.UpdateStepAsync(step, "Processing...", cancellationToken);
await reporter.CompleteStepAsync(step, "Build completed", cancellationToken);

// After: Direct extension methods
var step = await reporter.CreateStepAsync("Building images", cancellationToken);
await step.UpdateStatusAsync("Processing...", cancellationToken);
await step.SucceedAsync("Build completed", cancellationToken);

All existing tests continue to pass, and comprehensive tests have been added for the new extension methods.

Fixes #9994.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] Add extension methods to PublishingStep & PublishingTask for direct Complete/Update operations Add extension methods to PublishingStep & PublishingTask for direct Complete/Update operations Jun 23, 2025
Copilot finished work on behalf of captainsafia June 23, 2025 16:14
@Copilot Copilot AI requested a review from captainsafia June 23, 2025 16:14
Copy link
Member

@captainsafia captainsafia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start! Remove the StatusText property on PublishingStep and any APIs related to it.

Copy link
Contributor Author

Copilot AI commented Jun 23, 2025

Good start! Remove the StatusText property on PublishingStep and any APIs related to it.

Done! Removed the StatusText property from PublishingStep and all related APIs including the UpdateStepAsync method and UpdateStatusAsync extension method. The extension methods for completion operations (SucceedAsync, WarnAsync, FailAsync) remain and work correctly. (347e5a7)

Copilot finished work on behalf of captainsafia June 23, 2025 16:44
@Copilot Copilot AI requested a review from captainsafia June 23, 2025 16:44
Copy link
Member

@captainsafia captainsafia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a new API on PublishingStep that will let me create a Task parented to it.

var step = await reporter.CreateStepAsync("Test Step", CancellationToken.None);
var task = await step.CreateTaskAsync("Initial status", CancellationToken.None)

Copy link
Contributor Author

Copilot AI commented Jun 23, 2025

Add a new API on PublishingStep that will let me create a Task parented to it.

...

Added the CreateTaskAsync extension method to PublishingStep. You can now create tasks directly from steps:

var step = await reporter.CreateStepAsync("Test Step", CancellationToken.None);
var task = await step.CreateTaskAsync("Initial status", CancellationToken.None);

The method includes proper error handling and comprehensive tests. (70d9c39)

@Copilot Copilot AI requested a review from captainsafia June 23, 2025 16:58
Copilot finished work on behalf of captainsafia June 23, 2025 16:58
@captainsafia captainsafia marked this pull request as ready for review June 23, 2025 17:02
@captainsafia captainsafia requested a review from mitchdenny as a code owner June 23, 2025 17:02
@captainsafia captainsafia requested a review from davidfowl June 23, 2025 17:02
@captainsafia
Copy link
Member

@copilot Can you update this branch with the latest changes from main and update the AzurePublishingContext, DockerComposePublishingContext, and ResourceContainerImageBuilder to use the new APIs.

Copy link
Contributor Author

Copilot AI commented Jun 24, 2025

@copilot Can you update this branch with the latest changes from main and update the AzurePublishingContext, DockerComposePublishingContext, and ResourceContainerImageBuilder to use the new APIs...

Updated branch with latest changes from main and updated the AzurePublishingContext, DockerComposePublishingContext, and ResourceContainerImageBuilder to use the new extension methods APIs. All implementations now use the streamlined approach instead of manual reporter interactions. (eee0222)

Copilot finished work on behalf of captainsafia June 24, 2025 00:21
Copy link
Member

@captainsafia captainsafia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undo the changes in Aspire.Hosting.Azure and Aspire.Hosting.Docker.

Copy link
Contributor Author

Copilot AI commented Jun 24, 2025

Undo the changes in Aspire.Hosting.Azure and Aspire.Hosting.Docker.

Changes in Aspire.Hosting.Azure and Aspire.Hosting.Docker have been reverted to their original state. The new extension methods remain available but these components now use the original publishing APIs instead. (c4ce5b1)

Copilot finished work on behalf of captainsafia June 24, 2025 00:38
@Copilot Copilot AI requested a review from captainsafia June 24, 2025 00:38
Copilot AI and others added 2 commits June 23, 2025 22:45
Co-authored-by: captainsafia <1857993+captainsafia@users.noreply.github.com>
Copilot AI and others added 4 commits June 23, 2025 22:45
Co-authored-by: captainsafia <1857993+captainsafia@users.noreply.github.com>
Co-authored-by: captainsafia <1857993+captainsafia@users.noreply.github.com>
…kerComposePublishingContext to use new PublishingExtensions APIs

Co-authored-by: captainsafia <1857993+captainsafia@users.noreply.github.com>
Co-authored-by: captainsafia <1857993+captainsafia@users.noreply.github.com>
@captainsafia
Copy link
Member

@davidfowl @mitchdenny This is rebased and ready for review.

/// <summary>
/// The progress reporter that created this step.
/// </summary>
internal IPublishingActivityProgressReporter? Reporter { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ctor is public for this class, but this property is internal...?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the accessibility inconsistency by making the Reporter properties public to match the public constructors. This ensures consistent API design where users can create instances directly and all public members are accessible. (173b7cb)

Co-authored-by: eerhardt <8291187+eerhardt@users.noreply.github.com>
@Copilot Copilot AI requested a review from eerhardt June 24, 2025 21:32
Copilot finished work on behalf of eerhardt June 24, 2025 21:32
@@ -72,7 +72,7 @@ public sealed class PublishingStep(string id, string title)
/// <summary>
/// The progress reporter that created this step.
/// </summary>
internal IPublishingActivityProgressReporter? Reporter { get; set; }
public IPublishingActivityProgressReporter? Reporter { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I meant to make the constructor internal, not make these public.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the constructors internal and restored the Reporter properties to internal access. This ensures proper encapsulation where only the progress reporter implementations can create instances, while the extension methods can still access the Reporter property within the same assembly. (8db3dc5)

…ore internal Reporter properties

Co-authored-by: eerhardt <8291187+eerhardt@users.noreply.github.com>
Copilot finished work on behalf of eerhardt June 24, 2025 21:41
@Copilot Copilot AI requested a review from eerhardt June 24, 2025 21:41
@captainsafia captainsafia enabled auto-merge (squash) June 24, 2025 22:28
@captainsafia captainsafia merged commit 3372141 into main Jun 24, 2025
496 of 498 checks passed
@captainsafia captainsafia deleted the copilot/fix-9994 branch June 24, 2025 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add extension methods to PublishingStep & PublishingTask for direct Complete/Update operations
3 participants