Skip to content

feat: Add theme-aware WCAG colors with automatic Light/Dark switching#10

Merged
willibrandon merged 5 commits intomainfrom
feature/theme-aware-wcag-colors
Sep 7, 2025
Merged

feat: Add theme-aware WCAG colors with automatic Light/Dark switching#10
willibrandon merged 5 commits intomainfrom
feature/theme-aware-wcag-colors

Conversation

@willibrandon
Copy link
Owner

Description

The extension's colors failed WCAG AA compliance across both Light and Dark Visual Studio themes, using single hex colors that worked in one theme but were inaccessible in the other. This implementation adds automatic theme-aware color switching to ensure ≥4.5:1 contrast ratio in both themes without requiring user intervention.

Root cause: The SerilogClassificationFormats.cs used static colors like #007ACC that worked well in Light theme but failed accessibility standards in Dark theme. The README.md incorrectly claimed WCAG AA compliance when colors weren't actually accessible across both themes.

Solution:

  • Implemented SerilogThemeColors service with VSColorTheme.ThemeChanged event handling for automatic theme detection
  • Created SerilogClassificationFormatBase base class enabling automatic color updates when themes change
  • Added WCAG AA compliant color palettes with semantic grouping (properties: blue family, operators: warm colors, functions: purple family)
  • Converted all 15 classification format definitions to use modern C# 12 primary constructors with dependency injection
  • Fixed ExpressionTemplate multi-line highlighting regression with deduplication logic to prevent overlapping classifications

Type of change

  • Bug fix
  • New feature
  • Performance improvement
  • Documentation update

Checklist

  • Tests pass (.\scripts\test.ps1)
  • Benchmarks checked (if performance-related)
  • Documentation updated (if needed)

Additional notes

Fixes #9

… switching

- Implement SerilogThemeColors service with VSColorTheme.ThemeChanged event handling
- Add WCAG AA compliant color palettes (4.5:1+ contrast ratios)
- Create SerilogClassificationFormatBase for automatic theme updates
- Convert all format definitions to modern C# 12 primary constructors
- Fix ExpressionTemplate multi-line highlighting regression with deduplication
- Update README with theme-aware features and accessibility details

All colors now automatically adapt to VS theme changes without restart required.
@willibrandon willibrandon self-assigned this Sep 7, 2025
@willibrandon willibrandon added enhancement New feature or request visual-studio Visual Studio extension functionality and integration accessibility Accessibility improvements and WCAG compliance wcag Web Content Accessibility Guidelines compliance labels Sep 7, 2025
@willibrandon willibrandon requested a review from Copilot September 7, 2025 02:28
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds automatic theme-aware WCAG AA compliant colors for Serilog syntax highlighting. The extension now detects Visual Studio theme changes and automatically switches between Light and Dark color palettes without user intervention, ensuring ≥4.5:1 contrast ratio in both themes.

Key changes:

  • Implemented automatic theme detection and color switching system
  • Created WCAG AA compliant color palettes for both Light and Dark themes with semantic color grouping
  • Modernized classification format definitions to use C# 12 primary constructors with dependency injection

Reviewed Changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
SerilogSyntax.csproj Added new classification classes and System.Drawing reference for color handling
ExpressionDetector.cs Fixed ExpressionTemplate multi-line highlighting by removing specific string pattern requirement
SerilogThemeColors.cs Core theme-aware color management service with VS theme detection and WCAG AA color palettes
SerilogTextProperties.cs Data structure for text formatting properties (color, bold, italic)
SerilogClassifier.cs Enhanced ExpressionTemplate detection with deduplication logic to prevent overlapping classifications
SerilogClassificationFormats.cs Converted all format definitions to use theme-aware base class with dependency injection
SerilogClassificationFormatBase.cs Base class enabling automatic color updates when themes change
ISerilogClassificationDefinition.cs Interface for theme-aware classification definitions
README.md Updated documentation to reflect theme-aware colors and WCAG compliance
ExampleService.cs Cleaned up XML documentation comments

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

- Replace magic number 100 with named constant ThemeDetectionBlueThreshold
- Improve GUID comment with descriptive explanation for Text Editor category
- Remove explicit null assignments from MEF imported fields
- Add comment explaining ExpressionTemplate regex simplification fix
@willibrandon willibrandon merged commit ae34bce into main Sep 7, 2025
1 check passed
@willibrandon willibrandon deleted the feature/theme-aware-wcag-colors branch September 7, 2025 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accessibility Accessibility improvements and WCAG compliance enhancement New feature or request visual-studio Visual Studio extension functionality and integration wcag Web Content Accessibility Guidelines compliance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement theme-aware colors for WCAG AA compliance

1 participant