Skip to content
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

Add port environment variables for Aspire integration #1942

Merged
merged 4 commits into from
Jan 27, 2025

Conversation

normj
Copy link
Member

@normj normj commented Jan 25, 2025

Description of changes:
In Aspire we don't know the ports that it will allocate for the test tool till after the command line parameters have been set for the executable. To work around this I added environment variables that can be set by Aspire for the executable to pick up and use for ports.

I had trouble loading the test tool project for debugging due to the recent commit adding the wwwroot folder for packaging. To get around that I have the property only be set in Release mode allowing the project to be loaded in visual studio and dotnet pack which is run in release mode to find the static content. Not a perfect solution because it means VS will have issues in release mode. Unblocks for now but open to better solution.

I also addressed the remaining warnings in the project.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@normj normj added the Release Not Needed Add this label if a PR does not need to be released. label Jan 25, 2025
@@ -107,7 +107,7 @@ public static (IDictionary<string, string>, IDictionary<string, IList<string>>)
{
var key = lowerCaseKeyName ? header.Key.ToLower() : header.Key;
singleValueHeaders[key] = header.Value.Last() ?? "";
multiValueHeaders[key] = [.. header.Value];
multiValueHeaders[key] = [.. header.Value!];
Copy link
Member Author

Choose a reason for hiding this comment

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

I think the null warnings happening in this file were a false positive. They warnings only show up when doing dotnet pack not in VS. And the Value is a struct so it can't be null.

var encodedPathParameters = pathParameters.ToDictionary(
kvp => kvp.Key,
kvp => Uri.EscapeUriString(kvp.Value)); // intentionally using EscapeURiString over EscapeDataString since EscapeURiString correctly handles reserved characters :/?#[]@!$&'()*+,;= in this case
kvp => Uri.EscapeUriString(kvp.Value)); // intentionally using EscapeUriString over EscapeDataString since EscapeUriString correctly handles reserved characters :/?#[]@!$&'()*+,;= in this case
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there no better way for us to have the same behavior without using an obsolete method? What if they drop it in .NET10?

Copy link
Member Author

Choose a reason for hiding this comment

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

@gcbeattyAWS Can you answer this question since this was your change?

Copy link

Choose a reason for hiding this comment

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

so i tried looking for an alternative function that was not deprecated and produced the same output that we needed - but i could not find any. i think i tried 5 or 6 different ways and spent a couple hours on it. If we want to ensure the function never gets dropped I think we could just re-implement/copy their source code for it no?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not worried about the method being dropped. Methods being dropped from the BCL is a big deal that is rarely done.

@@ -19,4 +19,17 @@
config.SetApplicationName(Constants.ToolName);
});

return await app.RunAsync(args);
var arguments = new List<string>(args);
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@normj normj merged commit 52125c4 into feature/lambdatesttool-v2 Jan 27, 2025
5 checks passed
@normj normj deleted the normj/port-env-variables branch January 27, 2025 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release Not Needed Add this label if a PR does not need to be released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants