-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[C] support more color format in ColorTypeConverter #784
Conversation
case "WhiteSmoke": return Color.WhiteSmoke; | ||
case "Yellow": return Color.Yellow; | ||
case "YellowGreen": return Color.YellowGreen; | ||
switch (color.ToLowerInvariant()) { |
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 bet this was fun.
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.
@samhouts I bet it was fun to review, trying to find the one place an uppercase was left, or the one time I mixed gray
with blue
, accidentally creating the glue
color.
Assert.AreEqual(Color.Blue.MultiplyAlpha(.8), converter.ConvertFromInvariantString("hsla(240,100%, 50%, .8)")); | ||
Assert.AreEqual(Color.Default, converter.ConvertFromInvariantString("Color.Default")); | ||
Assert.AreEqual(Color.Accent, converter.ConvertFromInvariantString("Accent")); | ||
var hotpink = Color.FromHex("#FF69B4"); | ||
Color.Accent = hotpink; | ||
Assert.AreEqual (Color.Accent, converter.ConvertFromInvariantString ("Accent")); | ||
Assert.Throws<InvalidOperationException> (() => converter.ConvertFromInvariantString ("")); |
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.
Maybe also add some Assert.Throws
for parentheses violations (e.g., ColorTypeConverter, L28).
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'm still unsure about how this should behave on error. While parsing Xaml, we throw, but while parsing css any-other-markup, we might want to revert to default.
adding a test nonetheless
Assert.AreEqual(Color.Blue, converter.ConvertFromInvariantString("rgb(0,0, 255)")); | ||
Assert.AreEqual(Color.Blue, converter.ConvertFromInvariantString("rgb(0,0, 300)")); | ||
Assert.AreEqual(Color.Blue, converter.ConvertFromInvariantString("rgb(0,0, 300)")); | ||
Assert.AreEqual(Color.Blue.MultiplyAlpha(.8), converter.ConvertFromInvariantString("rgba(0%,0%, 100%, .8)")); |
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 one is failing.. :(
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.
WORKSFORME... investigating...
Description of Change
[C] support more color format in ColorTypeConverter
Bugs Fixed
/
API Changes
/
Behavioral Changes
/
PR Checklist