Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/libraries/Common/src/System/Drawing/KnownColorTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<byte> ColorKindTable => new byte[]
Comment thread
stephentoub marked this conversation as resolved.
{
// "not a known color"
KnownColorKindUnknown,
Expand Down Expand Up @@ -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);
}
Expand All @@ -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];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down