Reduce boilerplate code by automatically including common namespaces in your .NET projects. No more repetitive
using statements at the top of every file!
The Solution
Add <ImplicitUsings>enable</ImplicitUsings> to your .csproj to automatically include common namespaces like System, System.Linq, System.Collections.Generic, etc.
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
π‘ What this does
Instead of writing these using statements in every file:
using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;
They're automatically included! Your files become cleaner and you can focus on the actual code.
Before vs After
β Before (with explicit usings)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace MyApp
{
public class UserService
{
public async Task<List<string>> GetUserNamesAsync()
{
// Your code here
}
}
}
β After (with implicit usings)
namespace MyApp
{
public class UserService
{
public async Task<List<string>> GetUserNamesAsync()
{
// Your code here - no boilerplate!
}
}
}
π Pro Tips
- This works for .NET 6+ projects only
- You can still add explicit
usingstatements for less common namespaces - Different project types (Console, Web, etc.) include different implicit usings
- Use
<Using Remove="System.Net.Http" />to exclude specific namespaces if needed
π¬ Comments & Reactions