Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[C] support more color format in ColorTypeConverter #784

Merged
merged 3 commits into from
Mar 1, 2017

Conversation

StephaneDelcroix
Copy link
Member

@StephaneDelcroix StephaneDelcroix commented Feb 23, 2017

Description of Change

[C] support more color format in ColorTypeConverter

Bugs Fixed

/

API Changes

/

Behavioral Changes

/

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Rebased on top of master at time of PR
  • Changes adhere to coding standard
  • Consolidate commits as makes sense

case "WhiteSmoke": return Color.WhiteSmoke;
case "Yellow": return Color.Yellow;
case "YellowGreen": return Color.YellowGreen;
switch (color.ToLowerInvariant()) {
Copy link
Member

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.

Copy link
Member Author

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 (""));
Copy link
Member

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).

Copy link
Member Author

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)"));
Copy link
Member

Choose a reason for hiding this comment

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

This one is failing.. :(

Copy link
Member Author

Choose a reason for hiding this comment

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

WORKSFORME... investigating...

@jassmith jassmith merged commit 8379294 into master Mar 1, 2017
@StephaneDelcroix StephaneDelcroix deleted the colorConversion branch March 3, 2017 11:58
@samhouts samhouts modified the milestones: 2.3.0, 2.3.5 Jun 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants