Code Navigation & IntelliSense
Semantic Colors
Enhanced syntax highlighting with semantic coloring for specific C# types.
Overview
Section titled “Overview”Semantic colors provide distinct highlighting for interfaces, enums, and namespaces, making code structure more visible.
Colored Elements
Section titled “Colored Elements”Interfaces
Section titled “Interfaces”Interface types are highlighted with a distinct color:
IUserService service; // IUserService in interface colorEnum types have their own color:
Status currentStatus = Status.Active; // Status in enum colorNamespaces
Section titled “Namespaces”Namespace names are highlighted:
using System.Collections.Generic; // System, Collections, Generic in namespace colorConfiguration
Section titled “Configuration”Enabling Semantic Colors
Section titled “Enabling Semantic Colors”Semantic colors are enabled by default. Configure in:
- Open Settings (
Ctrl+,) - Search for
csharp-dev-tools.editor.semanticColors - Enable/disable per type:
semanticColors.interfacesemanticColors.enumsemanticColors.namespace
Customizing Colors
Section titled “Customizing Colors”Define colors per theme in settings.json:
{ "editor.tokenColorCustomizations": { "[Theme Name]": { "textMateRules": [ { "scope": "entity.name.type.interface.cs", "settings": { "foreground": "#b8d7a3" } }, { "scope": "entity.name.type.enum.cs", "settings": { "foreground": "#4ec9b0" } }, { "scope": "entity.name.type.namespace.cs", "settings": { "foreground": "#dcdcaa" } } ] } }}Benefits
Section titled “Benefits”Visual Distinction
Section titled “Visual Distinction”- Quickly identify interfaces vs classes
- Spot enum types at a glance
- Understand namespace structure
Code Navigation
Section titled “Code Navigation”- Easier to scan code
- Faster comprehension
- Better pattern recognition
Team Consistency
Section titled “Team Consistency”- Shared color scheme
- Uniform code appearance
- Professional presentation
Use Cases
Section titled “Use Cases”Interface-Based Development
Section titled “Interface-Based Development”See interfaces clearly when:
- Implementing dependency injection
- Working with abstractions
- Reviewing architectural patterns
Enum Usage
Section titled “Enum Usage”Identify enums quickly:
- State machines
- Configuration values
- Type discrimination
Namespace Organization
Section titled “Namespace Organization”Understand structure:
- Module boundaries
- Package organization
- Code layout
Theme Integration
Section titled “Theme Integration”Semantic colors respect VS Code themes:
- Dark themes get appropriate colors
- Light themes use suitable contrast
- High contrast themes supported
- Custom themes can override
Best Practices
Section titled “Best Practices”- Use distinct colors that don’t clash
- Ensure sufficient contrast
- Test with your preferred theme
- Share color scheme with team
- Document custom colors
Troubleshooting
Section titled “Troubleshooting”Colors Not Appearing
Section titled “Colors Not Appearing”- Ensure semantic highlighting is enabled
- Check C# Language Server status
- Verify theme supports semantic tokens
- Restart VS Code
Colors Look Wrong
Section titled “Colors Look Wrong”- Check theme color customizations
- Verify settings.json syntax
- Use color picker for accuracy
- Test with default theme first
Performance
Section titled “Performance”Semantic coloring:
- Provided by Language Server
- Cached for performance
- Updated incrementally
- Minimal impact