-
Notifications
You must be signed in to change notification settings - Fork 695
[release/9.2] Remove null/nullable parameter from DistributedApplicationExecutionContext #8539
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
Conversation
/// <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) |
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.
Why couldn't this stay as
public DistributedApplicationExecutionContextOptions(DistributedApplicationOperation operation, string? publisherName)
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.
Had a call with @mitchdenny and if you want to no set a valid publishname you can use the other ctor.
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.
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);
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.
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.
Backport of #8533 to release/9.2
/cc @sebastienros
Customer Impact
New API, non-breaking changes.
Testing
Risk
Regression?