Skip to content

DW-35: Align Color FromName with System.Drawing#141

Merged
mee-ironsoftware merged 2 commits intodevelopfrom
DW-35-Align-Color-FromName-With-SystemDrawing
Aug 18, 2025
Merged

DW-35: Align Color FromName with System.Drawing#141
mee-ironsoftware merged 2 commits intodevelopfrom
DW-35-Align-Color-FromName-With-SystemDrawing

Conversation

@Sawraz-IS
Copy link
Copy Markdown
Collaborator

@Sawraz-IS Sawraz-IS commented Aug 6, 2025

Title

Align Color.FromName behavior with System.Drawing and add support for RebeccaPurple.

Description

This PR updates the Color class in IronSoftware.Drawing to align its FromName behavior with the standard System.Drawing.Color implementation.

Key changes:

  • Updated Color.FromName(string name) to return a fully transparent black color (ARGB = 0) instead of throwing an exception for unknown color names.

  • Introduced a new property IsKnownColor to indicate whether a color is from the predefined list.

  • Added support for the RebeccaPurple color:

    • Added to KnownColor enum.

    • Added to ArgbValues and Names arrays in KnownColors.cs.

  • Updated FromKnownColor() method to properly set IsKnownColor.

These changes improve compatibility with the System.Drawing namespace, prevent unnecessary exceptions, and support extended color definitions (e.g., "Light1", "Accent1").

Fixes DW-35

Type of change

Please select the relevant option by placing an 'x' inside the brackets, like this: [x].

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 🏗️ Internal/structural update (non-breaking change that improves code quality, organization, or performance)
  • 📚 This change requires a documentation update
  • 🚀 DevOps build chain modification for release
  • 🤖 DevOps build chain modification for CI

How Has This Been Tested?

Unit tests were added and updated in Should_Create_FromName() to verify:

  • RebeccaPurple returns ARGB (255, 102, 51, 153) and sets IsKnownColor = true.

  • Unknown color name like NotAColor returns a color with ARGB = (0, 0, 0, 0) and IsKnownColor = false.

Checklist:

Please run through the checklist as much as possible and mark the items completed by placing an 'x' inside the brackets, like this: [x].

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have successfully run all unit tests on Windows
  • I have successfully run all unit tests on Linux

Additional Context

N/A

Copy link
Copy Markdown
Member

@mee-ironsoftware mee-ironsoftware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check my feedback.

Copy link
Copy Markdown
Member

@mee-ironsoftware mee-ironsoftware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mee-ironsoftware mee-ironsoftware merged commit 42dfdf6 into develop Aug 18, 2025
9 checks passed
@mee-ironsoftware mee-ironsoftware deleted the DW-35-Align-Color-FromName-With-SystemDrawing branch August 18, 2025 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants