A powerful VS Code extension that automatically adds all missing using statements in C# files with a single command. No more manually adding namespaces one by one!
✨ Features
One-Click Fix: Automatically detects and adds ALL missing using statements in a single operation
Smart Detection: Scans for CS0246 errors and other "missing namespace" diagnostics
Duplicate Prevention: Avoids adding existing using statements
Alphabetical Sorting: Keeps your using statements organized
Fast Performance: Collects all fixes and applies them in a single edit operation
Progress Feedback: Shows real-time status updates during processing
Multiple Access Methods: Available via Quick Fix, Command Palette, Context Menu, and Keyboard Shortcut
🚀 Usage
Method 1: Quick Fix (Recommended)
Open a .cs file with missing namespace errors
Look for the lightbulb (💡) icon that appears when there are errors
Click it or press Ctrl+. (Cmd+. on Mac)
Select "Import missing references in the file"
Method 2: Command Palette
Open a .cs file with missing namespace errors
Press Ctrl+Shift+P (Cmd+Shift+P on Mac) to open the command palette
Type "Import missing" and select "C#: Import missing references in the file"
Method 3: Context Menu
Right-click anywhere in a .cs file
Select "Import missing references in the file" from the context menu
Method 4: Keyboard Shortcut
Open a .cs file with missing namespace errors
Press Ctrl+Alt+F to instantly fix all missing usings
📋 Example
Before:
namespace MyApp
{
public class Program
{
public static void Main(string[] args)
{
var list = new List<string>(); // CS0246: Missing System.Collections.Generic
Console.WriteLine("Hello!"); // CS0246: Missing System
var json = JsonSerializer.Serialize(list); // CS0246: Missing System.Text.Json
}
}
}
After (with one click):
using System;
using System.Collections.Generic;
using System.Text.Json;
namespace MyApp
{
public class Program
{
public static void Main(string[] args)
{
var list = new List<string>(); // ✅ Fixed!
Console.WriteLine("Hello!"); // ✅ Fixed!
var json = JsonSerializer.Serialize(list); // ✅ Fixed!
}
}
}
⚙️ Requirements
VS Code: Version 1.85.0 or higher
C# Extension: The official C# extension (ms-dotnettools.csharp) must be installed and active
.NET SDK: A compatible .NET SDK for your project
OmniSharp: Must be running (automatically started by the C# extension)
🔧 How It Works
Scans the current C# file for CS0246 and related "missing namespace" errors
Analyzes available code actions from the C# language server
Extracts namespace names from "using XYZ;" quick fixes
Filters out duplicates and existing using statements
Applies all missing using statements in a single edit operation
Saves the document automatically
🎯 Supported Error Types
CS0246: The type or namespace name could not be found
Generic "missing using directive" messages
"Are you missing a using directive" suggestions
🚨 Troubleshooting
Extension doesn't appear in Quick Fix menu
Ensure you have CS0246 errors in your file
Make sure the C# extension is installed and OmniSharp is running
Check that your file is saved with a .cs extension
No using statements are added
Verify that the C# language server suggests "using" fixes for your errors
Some types may not have available namespace fixes
Check the Output panel (View → Output → "Import All Missing Usings C#") for diagnostic logs