feat: Add theme-aware WCAG colors with automatic Light/Dark switching#10
Merged
willibrandon merged 5 commits intomainfrom Sep 7, 2025
Merged
feat: Add theme-aware WCAG colors with automatic Light/Dark switching#10willibrandon merged 5 commits intomainfrom
willibrandon merged 5 commits intomainfrom
Conversation
… 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.
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
#007ACCthat 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:
Type of change
Checklist
.\scripts\test.ps1)Additional notes
Fixes #9