diff --git a/src/libraries/Common/src/System/Drawing/KnownColorTable.cs b/src/libraries/Common/src/System/Drawing/KnownColorTable.cs index a315067628937..281f246d13ade 100644 --- a/src/libraries/Common/src/System/Drawing/KnownColorTable.cs +++ b/src/libraries/Common/src/System/Drawing/KnownColorTable.cs @@ -238,7 +238,7 @@ internal static class KnownColorTable }; // All known color kinds (in order of definition in the KnownColor enum). - public static readonly byte[] s_colorKindTable = new byte[] + public static ReadOnlySpan ColorKindTable => new byte[] { // "not a known color" KnownColorKindUnknown, @@ -466,11 +466,11 @@ internal static class KnownColorTable internal static Color ArgbToKnownColor(uint argb) { Debug.Assert((argb & Color.ARGBAlphaMask) == Color.ARGBAlphaMask); - Debug.Assert(s_colorValueTable.Length == s_colorKindTable.Length); + Debug.Assert(s_colorValueTable.Length == ColorKindTable.Length); for (int index = 1; index < s_colorValueTable.Length; ++index) { - if (s_colorKindTable[index] == KnownColorKindWeb && s_colorValueTable[index] == argb) + if (ColorKindTable[index] == KnownColorKindWeb && s_colorValueTable[index] == argb) { return Color.FromKnownColor((KnownColor)index); } @@ -484,7 +484,7 @@ public static uint KnownColorToArgb(KnownColor color) { Debug.Assert(color > 0 && color <= KnownColor.RebeccaPurple); - return s_colorKindTable[(int)color] == KnownColorKindSystem + return ColorKindTable[(int)color] == KnownColorKindSystem ? GetSystemColorArgb(color) : s_colorValueTable[(int)color]; } diff --git a/src/libraries/System.Drawing.Primitives/src/System/Drawing/Color.cs b/src/libraries/System.Drawing.Primitives/src/System/Drawing/Color.cs index 68364fd674411..f711d9a5fe662 100644 --- a/src/libraries/System.Drawing.Primitives/src/System/Drawing/Color.cs +++ b/src/libraries/System.Drawing.Primitives/src/System/Drawing/Color.cs @@ -374,7 +374,7 @@ private Color(long value, short state, string? name, KnownColor knownColor) public bool IsSystemColor => IsKnownColor && IsKnownColorSystem((KnownColor)knownColor); internal static bool IsKnownColorSystem(KnownColor knownColor) - => KnownColorTable.s_colorKindTable[(int)knownColor] == KnownColorTable.KnownColorKindSystem; + => KnownColorTable.ColorKindTable[(int)knownColor] == KnownColorTable.KnownColorKindSystem; // Used for the [DebuggerDisplay]. Inlining in the attribute is possible, but // against best practices as the current project language parses the string with