-
Notifications
You must be signed in to change notification settings - Fork 144
Refactor AddDbGate method to use default name #1007
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -57,13 +57,13 @@ public static IResourceBuilder<DbGateContainerResource> WithDataBindMount(this I | |||
| /// Adds a DbGate container resource to the application. | ||||
| /// </summary> | ||||
| /// <param name="builder">The resource builder.</param> | ||||
| /// <param name="name">The name of the resource. This name will be used as the connection string name when referenced in a dependency.</param> | ||||
| /// <param name="name">The name of the resource. This name will be used as the connection string name when referenced in a dependency. Optional; defaults to <c>dbgate</c>.</param> | ||||
| /// <param name="port">The host port to bind the underlying container to.</param> | ||||
| /// <remarks> | ||||
| /// Multiple <see cref="AddDbGate(IDistributedApplicationBuilder, string, int?)"/> calls will return the same resource builder instance. | ||||
| /// </remarks> | ||||
| /// <returns>A reference to the <see cref="IResourceBuilder{T}"/>.</returns> | ||||
| public static IResourceBuilder<DbGateContainerResource> AddDbGate(this IDistributedApplicationBuilder builder, [ResourceName] string name, int? port = null) | ||||
| public static IResourceBuilder<DbGateContainerResource> AddDbGate(this IDistributedApplicationBuilder builder, [ResourceName] string name = "dbgate", int? port = null) | ||||
| { | ||||
| ArgumentNullException.ThrowIfNull(builder); | ||||
| ArgumentNullException.ThrowIfNull(name); | ||||
|
||||
| ArgumentNullException.ThrowIfNull(name); |
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.
That does not prevent a null value to be sent.
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.
The XML documentation for the
nameparameter is inconsistent with the actual behavior. The documentation states the parameter is "Optional; defaults to dbgate", but it's actually a required parameter in the sense that it must be explicitly provided if you want to specify the port (due to parameter ordering).Consider either:
int portto make the name truly optional when specifying a portbuilder.AddDbGate(port: 9090)Additionally, given the default value and the
[ResourceName]attribute, theArgumentNullException.ThrowIfNull(name)check at line 69 is unnecessary since the parameter can never be null.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.
The parameter is mandatory, but the argument is optional on invocation.
It's false that the parameter can never be null.