Skip to content

Lookup HtmlColors before ConsoleColors#536

Merged
dahlbyk merged 2 commits intodevelopfrom
rkeithhill/reorder-clr-lookup
Jan 18, 2018
Merged

Lookup HtmlColors before ConsoleColors#536
dahlbyk merged 2 commits intodevelopfrom
rkeithhill/reorder-clr-lookup

Conversation

@rkeithhill
Copy link
Copy Markdown
Collaborator

@rkeithhill rkeithhill commented Jan 18, 2018

Turns out ConsoleColors are a lot easier to specify than HtmlColors (that happen to match ConsoleColor names).

Add PSEdition_Core tag so that posh-git shows up if someone searches for that tag - https://www.powershellgallery.com/items?q=tags%3Apsedition_core&x=0&y=0

Turns out ConsoleColors are a lot easier to specify than HtmlColors (that happen to match ConsoleColor names).

Add PSEdition_Core tag so that posh-git shows up if someone searches for that tag - https://www.powershellgallery.com/items?q=tags%3Apsedition_core&x=0&y=0
@rkeithhill rkeithhill requested a review from dahlbyk January 18, 2018 02:58
$color = $ColorTranslatorType::FromHtml($color)
}
elseif ($null -ne ($color -as [System.ConsoleColor])) {
$color = [System.ConsoleColor]$color
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is the anti-pattern of converting twice - you should either use -as or the cast, but not both.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

OK, caught me being lazy but at least we fixed the bug where [System.ConsoleColor]::Black (value of 0) was not registering as a ConsoleColor. :-)

Actually this found a bit of a corner case issue where a string that was not a valid HTML color name BUT a valid ConsoleColor name (DarkYellow) wouldn't work because we blew by the ConsoleColor code straight to the catch.
@dahlbyk dahlbyk merged commit 46c47d7 into develop Jan 18, 2018
@dahlbyk dahlbyk deleted the rkeithhill/reorder-clr-lookup branch January 18, 2018 09:02
@dahlbyk dahlbyk added this to the v1.0 milestone Apr 17, 2018
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.

3 participants