Resharper: Don't Develop with out it. : Optimize Using's
Today's highlighted Resharper feature.
Optimize Using's. I love this. Love it, Love it, Love it.
A default C# code behind of an aspx page looks like this.
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace myKB.CRMServer.Web
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
After you code against the page for awhile, you'll consume some of those "using statements", but mostly not all of them. Resharper has an auto format command with CTRL+ALT+F. That shows this dialog.

Click reformat, and you're left with.
using System;
using System.Web.UI;
namespace myKB.CRMServer.Web
{
public partial class WebForm1 : Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
The System is there for the Parameters in the Page_Load method, and System.Web.UI is left behind, for the Page that WebForm1 is inheriting from.
Does this help any? Yes. Reflection is much faster, without having to look through all the using assemblies that aren't in reference.
Doesn't that make it harder to use objects not referenced, since they won't show up in intellisense? Oh but they can, and they will in my next blog post :)
Thanks Resharper for such a great product.