Skip to content

Fix incorrect output of Get-Location when using UseCanonical #99

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

Merged
merged 1 commit into from
Dec 5, 2018

Conversation

anton-evseev
Copy link
Contributor

If $resourceType passed in Get-Location isn't found and UseCanonical is used, the function returns null instead of default location.

Since no resource type was found, locations array is $null. So when each element of locations is being normalized through ForEach-Object the following statement returns non-empty array: $null | ForEach-Object. Because of that, if-statement $locations.Count -ne 0 is true and $locations[0] returns @($null)[0] i.e. $null

Example:

PS C:\> Get-Location "Microsoft.Network" "Usages" "westus"
West US
PS C:\> Get-Location "Microsoft.Network" "Usages" "westus" -UseCanonical

@anton-evseev
Copy link
Contributor Author

@MiYanni please take a look

@MiYanni
Copy link
Contributor

MiYanni commented Dec 3, 2018

@number213 Good find. I'll be making a PR to this repo this week. I'll merge this and my PR, and cut another build. I'll have to coordinate when we consume the new package since it won't include net452 assemblies.

@MiYanni MiYanni changed the base branch from dev to master December 5, 2018 00:41
Copy link
Contributor

@MiYanni MiYanni left a comment

Choose a reason for hiding this comment

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

LGTM

@MiYanni MiYanni merged commit dbaf847 into Azure:master Dec 5, 2018
@anton-evseev anton-evseev deleted the canonical branch December 6, 2018 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants