Color type is now a `class` instead of `struct`
See original GitHub issueI have been back and forth on this one, but it is still a large breaking change that will affect users. Maybe. I am not sure exactly how this affects all the code when recompiled, but it is different.
This will matter though when there are new null ref exceptions popping up, but hopefully tooling can aid with that.
Most frameworks are structs - except for iOS - and this may be unexpected.
@jonlipsky did mention that he noticed some perf improvements with TouchDraw, but this might need a check on say Android with the GC. It may be that it is fine and the GC is OK and that copying structs is more expensive.
@Clancey mentions a nicer reading:
var foo = color?.ToNative() ?? defaultColor
// vs
var foo = color == Color.Default ? defaultColor : color.ToNative()
This is true, but it is also the same with Color? as a nullable.
This also relates to #57 where there is no longer a Default “color” and null is used.
Relates to parent issue: #58
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:6 (4 by maintainers)

Top Related StackOverflow Question
That’s only if we decide to use a
structAND keep aColor.Default. If we removeColor.Default, makeColorastruct, and go with the convention that cross-platform colors default tonull, then we end up with your cleaner-looking code. E.g., if my cross-platform property isThen my translation to a native color looks something like
Where
GetNativeDefaultColoris doing the work of determining what “default” means given the control type, usage, current theme, etc.+1 should be a struct