Skip to content

Commit e7e717b

Browse files
vlada-shubinabekir-ozturk
authored andcommitted
removed obsolete ToLower calls, if -> switch, -or -> -contains. fixed error messages
1 parent 45ddacf commit e7e717b

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

src/dotnet-install.ps1

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,11 @@ function Get-NormalizedQuality([string]$Quality) {
234234
return ""
235235
}
236236

237-
switch ($Quality.ToLower()) {
238-
{ ($_ -eq "daily") -or ($_ -eq "signed") -or ($_ -eq "validated") -or ($_ -eq "preview")} { return $Quality.ToLower() }
237+
switch ($Quality) {
238+
{ @("daily", "signed", "validated", "preview") -contains $_ } { return $Quality.ToLower() }
239239
#ga quality is available without specifying quality, so normalizing it to empty
240240
{ $_ -eq "ga" } { return "" }
241-
default { throw "'$Quality' is not a supported value for --quality option, supported values are: daily, signed, validated, preview, ga. If you think this is a bug, report it at https://github.com/dotnet/install-scripts/issues." }
241+
default { throw "'$Quality' is not a supported value for -Quality option, supported values are: daily, signed, validated, preview, ga. If you think this is a bug, report it at https://github.com/dotnet/install-scripts/issues." }
242242
}
243243
}
244244

@@ -249,28 +249,23 @@ function Get-NormalizedChannel([string]$Channel) {
249249
return ""
250250
}
251251

252-
switch ($Channel.ToLower()) {
252+
switch ($Channel) {
253253
{ $_ -eq "lts" } { return "LTS" }
254+
{ $_ -eq "current" } { return "current" }
254255
default { return $Channel.ToLower() }
255256
}
256257
}
257258

258259
function Get-NormalizedProduct([string]$Runtime) {
259260
Say-Invocation $MyInvocation
260261

261-
if ($Runtime.ToLower() -eq "dotnet") {
262-
$Product = "dotnet-runtime"
262+
switch ($Runtime) {
263+
{ $_ -eq "dotnet" } { return "dotnet-runtime" }
264+
{ $_ -eq "aspnetcore" } { return "aspnetcore-runtime" }
265+
{ $_ -eq "windowsdesktop" } { return "windowsdesktop-runtime" }
266+
{ [string]::IsNullOrEmpty($_) } { return "dotnet-sdk" }
267+
default { throw "'$Runtime' is not a supported value for -Runtime option, supported values are: dotnet, aspnetcore, windowsdesktop. If you think this is a bug, report it at https://github.com/dotnet/install-scripts/issues." }
263268
}
264-
elseif ($Runtime.ToLower() -eq "aspnetcore") {
265-
$Product = "aspnetcore-runtime"
266-
}
267-
elseif ($Runtime.ToLower() -eq "windowsdesktop") {
268-
$Product = "windowsdesktop-runtime"
269-
}
270-
elseif ([string]::IsNullOrEmpty($runtime)) {
271-
$Product = "dotnet-sdk"
272-
}
273-
return $Product
274269
}
275270

276271

@@ -805,7 +800,7 @@ function Get-AkaMSDownloadLink([string]$Channel, [string]$Quality, [string]$Prod
805800
Say-Invocation $MyInvocation
806801

807802
#quality is not supported for LTS or current channel
808-
if (![string]::IsNullOrEmpty($Quality) -and ($Channel -eq "LTS" -or $Channel -eq "current") ) {
803+
if (![string]::IsNullOrEmpty($Quality) -and (@("LTS", "current") -contains $Channel)) {
809804
$Quality = ""
810805
Say-Warning "Specifying quality for current or LTS channel is not supported, the quality will skipped."
811806
}

0 commit comments

Comments
 (0)