-
Notifications
You must be signed in to change notification settings - Fork 705
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
Cache parsed W3C colors #3983
base: v2_develop
Are you sure you want to change the base?
Cache parsed W3C colors #3983
Conversation
The |
sigh I'll mark this as draft and open the can of worms... |
@tig On second thought are there any plans to actually support localized names for the W3C color names? At the moment there are only en-US/neutral strings for the W3C colors. As far as I know, the W3C color names are meant to have standardized color names for design/development purposes, so I'm not sure it makes any sense to pass the localized names past the UI level. Ideally the localized name would be first "neutralized" before passing it further down the system so culture-specific quirks are avoided. |
for w3c names they should not be translated imo. Its like a ux enum for designers and web devs - should be consistent |
Figures, now I'm more confused and wondering why this whole thing is not just a static class containing named Color instances (static readonly fields) supported by enum mapping. The enum then could be further mapped to name/localization strings if really needed. At least at quick glance, it seems odd to go through all the hoops to parse the named colors through resource strings if localization is not needed. I'm most likely missing some critical information. |
I'm all for simplicity, thoughts @tig? switching the w3c names out of resx? |
I don't remember. I was probably over thinking it. |
I vote to remove it. |
I'll leave this open for now. Feel free to close the PR if you decide to |
If you don't mind, I could also take a look at the redesign as I'm sure people are already busy with other stuff. I could at least do some sort of rough draft of the new interface(s) and create an issue based on that. |
Absolutely, this would be great :) |
I wasn't sure if the ColorStrings is meant to be thread-safe or not but just to be sure I used concurrent dictionary to at least keep it internally consistent.
Also I'm not sure if the cache should be purged in case the UI culture is changed. I added TODO comment about it. In general it is quite error prone to switch the current UI culture on-the-fly anyways so I'm not sure we want to open that can of worms. In case it needs to be supported, I think I have a somewhat simple solution to it but I would first need to probably create microbenchmarks for it.
Fixes
Proposed Changes/Todos
Pull Request checklist:
CTRL-K-D
to automatically reformat your files before committing.dotnet test
before commit///
style comments)Allocations
String and DictionaryEntry allocations dropped nicely.