DEV Community

Mark Arteaga for RedBit Development

Posted on • Originally published at redbitdev.com

1

Quick Tip - Remove Unused Using References in Visual Studio

When working on a C# project be it Xamarin, ASP.NET Core etc within Visual Studio, developers sometimes forget to clean up using statements. Now Visual Studio does a good job of showing you visually unused using statements as follows

Screenshot 2021-08-01 150011

When you are working on bigger projects (in my current case, working on a project with 774 files), sometimes as a developer we forget to clean up our using statements as we go through code refactoring.

Well, thanks to Visual Studio, we can quickly clean up using statements in a file in two ways.

First is putting your cursor on one of the grayed out lines and clicking the light bulb, then clicking "Remove Unnecessary Usings". (NOTE: The shortcut key for this is CTRL-.)

Screenshot 2021-08-01 150730

When the action is executed the references will be cleaned up. But what happens when you have 700+ files? 

Well if you noticed in the dialog, there is a section at the bottom that says

Screenshot 2021-08-01 151508

Here you can see the options are

  1. Document
  2. Project
  3. Solution

Now it's pretty obvious, what the options are, but in all my years of using Visual Studio, I have not noticed these options and no one wants to go through 700+ files to clean them up!

This is what the dialog looks like when you click Solution

Screenshot 2021-08-01 164316

So I don't know if this is a Visual Studio 2019 feature or if it's always been there. But this makes it a little more 'enjoyable' to go in and clean up lines of code that are no longer required in your source code!

Warp.dev image

Warp is the highest-rated coding agent—proven by benchmarks.

Warp outperforms every other coding agent on the market, and gives you full control over which model you use. Get started now for free, or upgrade and unlock 2.5x AI credits on Warp's paid plans.

Download Warp

Top comments (0)

Feature flag article image

Create a feature flag in your IDE in 5 minutes with LaunchDarkly’s MCP server 🏁

How to create, evaluate, and modify flags from within your IDE or AI client using natural language with LaunchDarkly's new MCP server. Follow along with this tutorial for step by step instructions.

Read full post

👋 Kindness is contagious

Explore this insightful write-up, celebrated by our thriving DEV Community. Developers everywhere are invited to contribute and elevate our shared expertise.

A simple "thank you" can brighten someone’s day—leave your appreciation in the comments!

On DEV, knowledge-sharing fuels our progress and strengthens our community ties. Found this useful? A quick thank you to the author makes all the difference.

Okay