-
Notifications
You must be signed in to change notification settings - Fork 543
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
Make more things async #2533
Merged
Merged
Make more things async #2533
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
76a942f
Make more things async
davidfowl 292a1ad
Added WithResourceUpdates sync overload
davidfowl 29850cc
Added WithEnvironment async overload
davidfowl 17a464c
Flow cancellation tokens
davidfowl 672ebdb
Made command line args callback async
davidfowl fbc333d
Name things async and add more cancellation tokens
davidfowl 5d5a1b2
Missed one
davidfowl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/Aspire.Hosting/ApplicationModel/CommandLineArgsCallbackAnnotation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace Aspire.Hosting.ApplicationModel; | ||
|
||
/// <summary> | ||
/// Represents an annotation that provides a callback to be executed with a list of command-line arguments when an executable resource is started. | ||
/// </summary> | ||
public class CommandLineArgsCallbackAnnotation : IResourceAnnotation | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="CommandLineArgsCallbackAnnotation"/> class with the specified callback action. | ||
/// </summary> | ||
/// <param name="callback"> The callback action to be executed.</param> | ||
public CommandLineArgsCallbackAnnotation(Func<CommandLineArgsCallbackContext, Task> callback) | ||
{ | ||
Callback = callback; | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="CommandLineArgsCallbackAnnotation"/> class with the specified callback action. | ||
/// </summary> | ||
/// <param name="callback"> The callback action to be executed.</param> | ||
public CommandLineArgsCallbackAnnotation(Action<IList<string>> callback) | ||
{ | ||
Callback = (c) => | ||
{ | ||
callback(c.Args); | ||
return Task.CompletedTask; | ||
}; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the callback action to be executed when the executable arguments are parsed. | ||
/// </summary> | ||
public Func<CommandLineArgsCallbackContext, Task> Callback { get; } | ||
} | ||
|
||
/// <summary> | ||
/// Represents a callback context for the list of command-line arguments associated with an executable resource. | ||
/// </summary> | ||
/// <param name="args"> The list of command-line arguments.</param> | ||
/// <param name="cancellationToken"> The cancellation token associated with this execution.</param> | ||
public sealed class CommandLineArgsCallbackContext(IList<string> args, CancellationToken cancellationToken = default) | ||
{ | ||
/// <summary> | ||
/// Gets the list of command-line arguments. | ||
/// </summary> | ||
public IList<string> Args { get; } = args; | ||
|
||
/// <summary> | ||
/// Gets the cancellation token associated with the callback context. | ||
/// </summary> | ||
public CancellationToken CancellationToken { get; } = cancellationToken; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
src/Aspire.Hosting/ApplicationModel/ExecutableArgsCallbackAnnotation.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a context here would reduce the chance of needing something extra in the future causing a breaking change. Up to you.