Code Navigation & IntelliSense
Unused Symbol Detection
Identify and eliminate dead code with unused symbol highlighting.
Overview
Section titled “Overview”Unused symbol detection automatically highlights code that isn’t being used anywhere in your project.
What Gets Detected
Section titled “What Gets Detected”Private Methods
Section titled “Private Methods”Private methods with no references:
private void UnusedMethod() // Appears grayed out{ // This method is never called}Properties
Section titled “Properties”Public and private properties not accessed:
private string UnusedProperty { get; set; } // Grayed outFields
Section titled “Fields”Fields that are declared but never used:
private int _unusedField; // Grayed outEvents
Section titled “Events”Events that are never subscribed to or raised:
private event EventHandler UnusedEvent; // Grayed outVisual Indication
Section titled “Visual Indication”Unused symbols appear with reduced opacity (grayed out), making them easy to spot.
Configuration
Section titled “Configuration”Enable/Disable
Section titled “Enable/Disable”- Open Settings (
Ctrl+,) - Search for
csharp-dev-tools.editor.highlightUnusedSymbols - Toggle on/off
Or use Command Palette: “Toggle Unused Symbol Highlighting”
Adjust Opacity
Section titled “Adjust Opacity”Control how grayed out unused symbols appear:
- Search for
csharp-dev-tools.editor.unusedSymbolOpacity - Set value between 0.1 (very faint) and 1.0 (normal)
Detection Method
Section titled “Detection Method”The extension uses:
- Primary: C# Language Server diagnostics (IDE0051, etc.)
- Fallback: Reference counting for larger files
- Scope: File-level detection for performance
Exclusions
Section titled “Exclusions”Public Methods
Section titled “Public Methods”Public methods are excluded from detection as they might be:
- API endpoints
- Library methods
- Called from external projects
- Used via reflection
Interface Implementations
Section titled “Interface Implementations”Methods implementing interfaces are excluded even if not directly called.
Virtual/Override Methods
Section titled “Virtual/Override Methods”Virtual and override methods are excluded as they may be called via polymorphism.
Use Cases
Section titled “Use Cases”Code Cleanup
Section titled “Code Cleanup”- Identify methods to remove
- Find unused properties
- Eliminate dead code
- Reduce technical debt
Refactoring
Section titled “Refactoring”- Safely remove unused code
- Simplify classes
- Improve maintainability
Code Review
Section titled “Code Review”- Spot accidentally unused code
- Find leftover experimental code
- Identify incomplete refactorings
Best Practices
Section titled “Best Practices”- Review grayed out code before deleting
- Check if code is intentionally unused (future use)
- Consider making unused public methods private
- Remove truly dead code to reduce complexity
Troubleshooting
Section titled “Troubleshooting”False Positives
Section titled “False Positives”If actively used code appears unused:
- May be called via reflection
- Used in other projects/assemblies
- Called from markup (Blazor, XAML)
- Toggle off the feature for those files
Not Detecting Unused Code
Section titled “Not Detecting Unused Code”- Ensure C# Language Server is running
- Check file is part of project
- Verify diagnostic level includes information
- Rebuild project if needed
Performance
Section titled “Performance”- Lightweight detection
- Incremental updates
- Optimized for large files
- Minimal performance impact