Remove duplicate port check and use endpoint configured builder #9176
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.
Fixes #8589.
Validated in VS 17.14 Preview 6.
This pull request refactors the
WithFunctionsHttp
method inAzureFunctionsProjectResourceExtensions.cs
to simplify conditional logic and improve readability. The changes primarily focus on consolidating conditional expressions and restructuring the handling of theport
parameter.Refactoring and Simplification:
Consolidated the conditional logic for setting up HTTP/HTTPS endpoints by using a ternary operator to assign the appropriate
WithHttpEndpoint
orWithHttpsEndpoint
method to thebuilder
variable. This reduces code duplication and improves readability. ([src/Aspire.Hosting.Azure.Functions/AzureFunctionsProjectResourceExtensions.csL166-R168](https://github.com/dotnet/aspire/pull/9176/files#diff-7739766f9496b7f887e020f33717d1a0402d2003a93a6b561ce86304e2fa9170L166-R168)
)Restructured the logic for handling the
port
parameter by removing redundant checks and separating theport == null
condition into its own block. This ensures clarity and avoids unnecessary nested conditions. ([src/Aspire.Hosting.Azure.Functions/AzureFunctionsProjectResourceExtensions.csL183-R188](https://github.com/dotnet/aspire/pull/9176/files#diff-7739766f9496b7f887e020f33717d1a0402d2003a93a6b561ce86304e2fa9170L183-R188)
)