-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
System.Drawing.Color is possibly missing 8 colors #38244
Comments
Tagging subscribers to this area: @safern, @tannergooding |
THanks @HumanEquivalentUnit -- this would be an API proposal because we need to add these new members to For new APIs we need to follow this process: https://github.com/dotnet/runtime/blob/97e553f5c3244b7df65ebfb7de3bb712081228cc/docs/project/api-review-process.md So first we need to format the issue description to show that these are additions to |
@safern I have rewritten the issue description from the API proposal template, as best as I can. I have limited C# experience, and am not sure what the full diff would look like, or whether System.Windows.Media.Colors needs to be involved/included either. NB. If the .Net colors are not intended to track the CSS colors, then I am not strongly advocating to add these. Only if they are supposed to be identical, then it seems like a bug that they differ at all. |
I'm not sure if it has been our intention over the past, but I think it doesn't hurt to add those colors if they help matching other frameworks with default colors. Marked as ready for review. |
If |
That is correct. Will add it to the description as well, thanks @reflectronic |
namespace System.Drawing
{
public enum KnownColor
{
RebeccaPurple
}
public readonly struct Color : IEquatable<Color>
{
public static Color RebeccaPurple;
}
} |
i want to try implementing this |
@FireCubeStudios go for it! |
ok so i can get it done this weekend and i will send a pull request in. |
i added rebecca purple, but what to do with "grey", do i replace "gray" with "grey" or add both or add none? @HumanEquivalentUnit @terrajobst |
@FireCubeStudios my understanding of the post above is they only want Rebecca purple: the others would simply be duplicating existing "grAy" entries with parallel "grEy" which they don't think makes sense to expose in API. Anywhere we parse such colors we should accept both, but we should represent both of them with the "grAy" spelling in the API. |
The thing about missing the 'Grey' spelling variants is that there are a lot of places where color name mappings are populated from the static properties on Example from runtime/src/libraries/System.Drawing.Common/src/System/Drawing/ColorConverter.cs Lines 329 to 343 in 6072e4d
|
Ah, if there's an interop angle then possibly that should be revisited then. cc @safern @tannergooding who are area owners and will have a more interesting response than me. |
Interestingly, runtime/src/libraries/Common/src/System/Drawing/ColorTranslator.cs Lines 248 to 252 in 6072e4d
|
What do you have in mind - who expects, or where is it documented that way? My assumption was "the colour lists are very close, so they probably intend to be identical", but the review video above says .Net Framework used "web" colours as a convenient source for a colour list, but never intended to be in sync with them. |
Given that these are largely the W3C color types, that we define other aliases such as |
Added RebeccaPurple color to the UnitTest and to the ref Added RebeccaPurple a,r,g,b value to unittest in System.Drawing.Primitive. Also updated the ref. dotnet#38244
Added RebeccaPurple color to the System.Drawing.Primitive ref file. "RebeccaPurple = 141" was added. I updated the other colors to their previous number by one. dotnet#38244
Reverted the breaking changes in system.drawing.primivite ref. the numbers of colors were restored back and i removed rebeccapurple. dotnet#38244
I added rebeccapurple to the ref file with value 175. RebeccaPurple was added with value 175 to the bottom of the enum. dotnet#38244
I added rebeccapurple to theend of the file RebeccaPurple was added to the bottom of the enum. dotnet#38244
Added Rebecca Purple color to System.Drawing.Color Added RebeccaPurple (#663399) to KnownColorNames.cs, Color.cs, KnownColortable.cs and KnownColor.cs dotnet#38244
Added RebeccaPurple color to the UnitTest and to the ref Added RebeccaPurple a,r,g,b value to unittest in System.Drawing.Primitive. Also updated the ref. dotnet#38244
Added RebeccaPurple color to the System.Drawing.Primitive ref file. "RebeccaPurple = 141" was added. I updated the other colors to their previous number by one. dotnet#38244
Reverted the breaking changes in system.drawing.primivite ref. the numbers of colors were restored back and i removed rebeccapurple. dotnet#38244
I added rebeccapurple to the ref file with value 175. RebeccaPurple was added with value 175 to the bottom of the enum. dotnet#38244
I added rebeccapurple to theend of the file RebeccaPurple was added to the bottom of the enum. dotnet#38244
Removed a comment in "knowncolor.cs" and moved rebeccapurple to match enum order. moved rebeccapurple in knowncolortable.cs, color.cs, and knowncolornames.cs dotnet#38244
Added a comment in KnownColorNames.cs stating that the array follows order of knowncolor enum. Also removed duplicate rebeccapurple entries dotnet#38244
Added a comment in KnownColortable.cs stating that the code accounts for the system colors and new rebeccapurple color dotnet#38244
* Added Rebecca Purple Added Rebecca Purple color to System.Drawing.Color Added RebeccaPurple (#663399) to KnownColorNames.cs, Color.cs, KnownColortable.cs and KnownColor.cs #38244 * Added RebeccaPurple to UnitTest and Ref Added RebeccaPurple color to the UnitTest and to the ref Added RebeccaPurple a,r,g,b value to unittest in System.Drawing.Primitive. Also updated the ref. #38244 * Added RebeccaPurple to the system.drawing.primitive ref Added RebeccaPurple color to the System.Drawing.Primitive ref file. "RebeccaPurple = 141" was added. I updated the other colors to their previous number by one. #38244 * Reverted breaking changes in drawing.primitive ref Reverted the breaking changes in system.drawing.primivite ref. the numbers of colors were restored back and i removed rebeccapurple. #38244 * Added RebeccaPurple to the ref I added rebeccapurple to the ref file with value 175. RebeccaPurple was added with value 175 to the bottom of the enum. #38244 * Added rebeccapurple to bottom of Knowncolors.cs I added rebeccapurple to theend of the file RebeccaPurple was added to the bottom of the enum. #38244 * Added Rebecca Purple Added Rebecca Purple color to System.Drawing.Color Added RebeccaPurple (#663399) to KnownColorNames.cs, Color.cs, KnownColortable.cs and KnownColor.cs #38244 * Added RebeccaPurple to UnitTest and Ref Added RebeccaPurple color to the UnitTest and to the ref Added RebeccaPurple a,r,g,b value to unittest in System.Drawing.Primitive. Also updated the ref. #38244 * Added RebeccaPurple to the system.drawing.primitive ref Added RebeccaPurple color to the System.Drawing.Primitive ref file. "RebeccaPurple = 141" was added. I updated the other colors to their previous number by one. #38244 * Reverted breaking changes in drawing.primitive ref Reverted the breaking changes in system.drawing.primivite ref. the numbers of colors were restored back and i removed rebeccapurple. #38244 * Added RebeccaPurple to the ref I added rebeccapurple to the ref file with value 175. RebeccaPurple was added with value 175 to the bottom of the enum. #38244 * Added rebeccapurple to bottom of Knowncolors.cs I added rebeccapurple to theend of the file RebeccaPurple was added to the bottom of the enum. #38244 * Fixed some of the requested changes with ordering of Enum Removed a comment in "knowncolor.cs" and moved rebeccapurple to match enum order. moved rebeccapurple in knowncolortable.cs, color.cs, and knowncolornames.cs #38244 * Removed duplicates and added a comment Added a comment in KnownColorNames.cs stating that the array follows order of knowncolor enum. Also removed duplicate rebeccapurple entries #38244 * Fixing up the handling of RebeccaPurple * Added a comment to explain changes Added a comment in KnownColortable.cs stating that the code accounts for the system colors and new rebeccapurple color #38244 Co-authored-by: Tanner Gooding <tagoo@outlook.com>
|
I think we should add the aliases as @tannergooding mentioned. |
Does this need to go through another round of API review then? In @terrajobst's comment only the RebeccaPurple change was approved: #38244 (comment) |
I think that's a reasonable rationale and probably doesn't result in explosion. However, we should contain it here. I don't believe a general praxis of adding aliases for BE vs AE spelling makes any sense. Another compromise would be to add the properties with AE but accept AE and BE when parsing. @dotnet/fxdc, does anybody feel strongly here? |
I believe most, if not all, of the BCL is American English spelling, so I think my vote is for making the parser here support both while leaving IntelliSense consistent as American English (even though I usually spell grey with an e). |
I think supporting parsing both without exposing both would be reasonable. We can then chalk the existing duplicates up as legacy/back-compat |
I'm going to close this as it fixed what was approved. If we want to add |
Background and Motivation
It appears that the
System.Drawing.Color
names are intended to track the CSS color names; if that is correct, there are some colors which need to be added. Two reasons for thinking the names are supposed to track CSS colors are:The Documentation for System.Drawing.Color says "For more information about these colors, see Colors by Name." which links to Mozilla's documentation on CSS color names.
Pull Request Update the hex value for DarkSeaGreen color corefx#41561 where one of the color values differed from the CSS value, and the .Net color value was changed to agree with CSS.
Proposed API
Affecting at least KnownColor.cs and KnownColorNames.cs and KnownColorTable.cs and Affecting at least Color.cs, the significant differences are the addition of the new RebeccaPurple color, and the variant spellings of
grAy
colors asgrEy
:Possibly related, System.Windows.Media.Colors
Usage Examples
Alternative Designs
I have not considered any particular designs, only intending to report this as a bug where the existing behaviour differs from the intended behaviour.
Risks
This will change the total number of items in the Color enum, and (depending on whether the new ones are added in order, or to the end) might change the existing color locations.
I think the missing color values are:
#663399
#a9a9a9
#2f4f4f
#696969
#808080
#d3d3d3
#778899
#708090
The text was updated successfully, but these errors were encountered: