Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Apr 3, 2025

Backport of #8533 to release/9.2

/cc @sebastienros

Customer Impact

New API, non-breaking changes.

Testing

Risk

Regression?

@danmoseley danmoseley added area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication Servicing-approved Approved for servicing release labels Apr 4, 2025
@danmoseley danmoseley merged commit eaa7869 into release/9.2 Apr 4, 2025
174 checks passed
@danmoseley danmoseley deleted the backport/pr-8533-to-release/9.2 branch April 4, 2025 15:33
/// <param name="operation">Indicates whether the AppHost is running in Publish mode or Run mode.</param>
/// <param name="publisherName">The publisher name if in Publish mode.</param>
public DistributedApplicationExecutionContextOptions(DistributedApplicationOperation operation, string? publisherName = null)
public DistributedApplicationExecutionContextOptions(DistributedApplicationOperation operation, string publisherName)
Copy link
Member

Choose a reason for hiding this comment

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

Why couldn't this stay as

public DistributedApplicationExecutionContextOptions(DistributedApplicationOperation operation, string? publisherName)

Copy link
Member

Choose a reason for hiding this comment

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

Had a call with @mitchdenny and if you want to no set a valid publishname you can use the other ctor.

Copy link
Member

Choose a reason for hiding this comment

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

In general, that kind of API pattern makes using the API harder to use. It maybe doesn't matter much for this API, but in general, the pattern isn't great.

void Foo() { ... }
void Foo(string v) { ... }

// consume:

string? someV = GetSomeV();

if (someV is null)
{
    Foo();
}
else
{
    Foo(someV);
}

vs.

void Foo() { ... }
void Foo(string? v) { ... }

// consume:

string? someV = GetSomeV();
Foo(someV);

Copy link
Member

Choose a reason for hiding this comment

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

Got it. In that case the usage is based on the first argument, operation, and if you are creating a Publish operation you have to set a non-null publisherName. So maybe the API could have been more specific about it, even maybe preventing from setting a publisherName if you create another type (Run or Inspect). For instance ctor(string publisherName) would be more adapted, it would infer the Publish operation. Or maybe these should be sub-classes.

@github-actions github-actions bot locked and limited conversation to collaborators May 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication Re-opened Github-Action PR Servicing-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants