-
Notifications
You must be signed in to change notification settings - Fork 138
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
Conversation
@@ -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 |
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.
Did you verify that getRuntimes always returns them in the same order?
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.
Mine always does. I will look into it some more to see how we are exactly getting it.
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.
Yes please 👍
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.
I think if we are going the prompt route as mentioned below it won't matter either way.
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. |
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. |
targetFramework
so that te latest runtime is chosen targetFramework
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.
We should also add tests that cover this scenario in this PR
test/api.test.ts
Outdated
|
||
suite(`AzureFunctionsExtensionApi`, () => { | ||
suite.only(`AzureFunctionsExtensionApi`, () => { |
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.
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 |
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.
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:
- Why
api.createFunction
doesn't throw here, since selecting version 8 shouldn't be possible - What last two inputs do you mean, do you mean the next steps in the createFunction wizard?
- 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
// 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. |
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.
// 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. |
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. |
test/MockIProjectWizardContext.ts
Outdated
@@ -0,0 +1,45 @@ | |||
/* eslint-disable no-restricted-imports */ |
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.
Do you need this still?
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.