Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Show quickpicks if there are multiple runtime matches for targetFramework #4165

Merged
merged 11 commits into from
Jul 8, 2024

Conversation

motm32
Copy link
Contributor

@motm32 motm32 commented Jun 3, 2024

Related to microsoft/vscode-azurestaticwebapps#899

Currently the runtime is chosen using .find so the first match will be chosen. We should allow users to choose which runtime they want.

@motm32 motm32 requested a review from a team as a code owner June 3, 2024 17:14
@@ -16,7 +16,7 @@ export class DotnetRuntimeStep extends AzureWizardPromptStep<IProjectWizardConte
public static async createStep(context: IProjectWizardContext): Promise<DotnetRuntimeStep> {
if (context.targetFramework) {
context.targetFramework = typeof context.targetFramework === 'string' ? [context.targetFramework] : context.targetFramework;
const runtimes = await getRuntimes(context);
const runtimes = (await getRuntimes(context)).reverse(); // reverse so that the latest version is first
Copy link
Member

Choose a reason for hiding this comment

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

Did you verify that getRuntimes always returns them in the same order?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mine always does. I will look into it some more to see how we are exactly getting it.

Copy link
Member

Choose a reason for hiding this comment

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

Yes please 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think if we are going the prompt route as mentioned below it won't matter either way.

@nturinski
Copy link
Member

nturinski commented Jun 3, 2024

I'm a little perplexed why it would have that behavior. Shouldn't it being an exact match on the .NET framework? So looking for .NET 8.0, and .NET 6.0 shouldn't match?

Edit: Oh, I think I understand what you mean. Since the targetFramework can be an array as well, it's matching the very first element of the array.

I think we should probably either a.) prompt the user if there are multiple matches or b.) add a property to the elements that indicates which is default

There are some concerns such as what Alex brought up that I have with the current logic.

@motm32
Copy link
Contributor Author

motm32 commented Jun 3, 2024

I think we should probably either a.) prompt the user if there are multiple matches or b.) add a property to the elements that indicates which is default

I think originally the SWA team wanted to prompt so I could see "a" being the best option. And I do think the list is always returned the same way but either way makes more sense to me to prompt than to automatically choose.

@motm32 motm32 changed the title Fix targetFramework so that te latest runtime is chosen Show quickpicks if there are multiple runtime matches for targetFramework Jun 4, 2024
Copy link
Member

@alexweininger alexweininger left a comment

Choose a reason for hiding this comment

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

We should also add tests that cover this scenario in this PR

test/api.test.ts Outdated

suite(`AzureFunctionsExtensionApi`, () => {
suite.only(`AzureFunctionsExtensionApi`, () => {
Copy link
Member

Choose a reason for hiding this comment

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

Gotta remove dis

test/api.test.ts Outdated
await validateProject(folderPath, validateOptions);
});

// When passing in a language version that is not in the target framework the last two inputs should not be prompted if they are this test will fail
Copy link
Member

@alexweininger alexweininger Jun 14, 2024

Choose a reason for hiding this comment

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

This test is ensuring that target framework property is properly used to filter the picks from all available framework versions.

From this comment, it's not clear to me:

  1. Why api.createFunction doesn't throw here, since selecting version 8 shouldn't be possible
  2. What last two inputs do you mean, do you mean the next steps in the createFunction wizard?
  3. How do you know this test will fail if 8 is a valid pick?

I think a better comment would start like:

// Intentionally pass a version (8) that hasn't been specified in targetFramework (6 & 7) to verify it isn't a possible pick. In the correct case (when 8 isn't a pick)... And in the incorrect case (when 8 is available)...

test/api.test.ts Outdated
Comment on lines 99 to 100
// Intentionally pass a version (8) that hasn't been specified in targetFramework (6 & 7) to verify it isn't a possible pick. In the correct case (when 8 isn't a pick) this will cause an error to be thrown so no more picks are needed.
// In the incorrect case (when 8 is a pick) this will cause the test to fail as there are no further picks being passed in.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Intentionally pass a version (8) that hasn't been specified in targetFramework (6 & 7) to verify it isn't a possible pick. In the correct case (when 8 isn't a pick) this will cause an error to be thrown so no more picks are needed.
// In the incorrect case (when 8 is a pick) this will cause the test to fail as there are no further picks being passed in.
// Intentionally pass a version (8) that hasn't been specified in targetFramework (6 & 7) to verify it isn't a possible pick. In the correct case (when 8 isn't a pick) we throw an error. api.createFunction swallows the error and returns undefined.
// In the incorrect case (when 8 is a pick) the test fails since the 2 provided test inputs have already been used, but there are more prompts.

alexweininger
alexweininger previously approved these changes Jun 26, 2024
@alexweininger
Copy link
Member

alexweininger commented Jun 26, 2024

Make sure these tests are passing in the Actions before merging. Also is the plan that this should not change any existing Functions UX right? We might want to inform CTI of this change and have them watch out for it.

@motm32
Copy link
Contributor Author

motm32 commented Jun 28, 2024

Make sure these tests are passing in the Actions before merging. Also is the plan that this should not change any existing Functions UX right? We might want to inform CTI of this change and have them watch out for it.

I am investigating right now since one of the tests I added is failing. And you are correct this should only change when a targetFramework exists which at the moment should only be in SWA. I will inform CTI of the change.

nturinski
nturinski previously approved these changes Jul 3, 2024
@@ -0,0 +1,45 @@
/* eslint-disable no-restricted-imports */
Copy link
Member

Choose a reason for hiding this comment

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

Do you need this still?

@motm32 motm32 merged commit 6867559 into main Jul 8, 2024
2 checks passed
@motm32 motm32 deleted the meganmott/targetFrameworkFix branch July 8, 2024 17:41
@microsoft microsoft locked and limited conversation to collaborators Aug 23, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants