In ASP.NET MVC3, if I select multiple Controller files (by holding CTRL and click on each file) and select `Remove and Sort Using` then the exception is thrown: OBJECT REFERENCE NOT SET TO AN INSTANCE OF AN OBJECT.
I just downloaded and tried this plugin for VS2010 SP1. At the project level, it only seems to work on files that are "visible". I.e. I had to expand all folder nodes within a project for this to work.
Hi, I am glad that this does exactly as specified in the description (like a charm).
Few Suggestions: 1) Can we add functionality in the extension to exclude Designer.cs files when run at a project level. This is because we better not touch the designer files. I tried running it on a project and ended up with a few unexpected errors related to the designer.cs files. 2) If we want just a few files to be sorted, by holding the Ctrl key and selecting multiple files and then running the extension. It prompts a "Object variable not set exception." 3)Also can we add a shortcut key to perform the same action.
Thanks for developing such a brilliant piece of code. Appreciate it.
The extension is a great idea but needs some more work.
1. You should be able to select a sub-folder in a project and be able to execute the plugin.
2. The plugin should be aware of source controlled files. I've got my SCC provider (Vault) set keep my files read-only and to auto-checkout. The plugin throws an "Object instance not set to an instance of an object." error dialog when attempting to execute against checked-in (read-only) files.
Thanks for the interest but this extension probably won't be updated. Productivity Power Tools offers this feature and many more.
We (Mike and I) originally created this extension because Power Commands 2008 wasn't updated for Visual Studio 2010 at launch. We decided to create extensions for the features we liked/needed/missed/ the most.
You can get Productivity Power Tools here:
It's basically several extension packaged as one. You can disable the ones you don't wont.
Would it be possible for this extension not to process files which are generated? In other words ignore those which are dependent upon a file with the custom tool set to 'TextTemplatingFileGenerator'.
As currently it makes a bit of mess of source control constantly having namespaces being added/removed every time the code is generated or the extension is run.
Thank you for this excellent visual studio extension! :)
I noticed there are a few limitations:
1. does not support System.Linq namespace. So even if I use a Select() or Single() method on a collection, the "using System.Linq;" will still get removed.
2. does not support custom extension methods. For example, if I use an extension method that is in another namespace, it will remove "using MyApplication.Helpers.Extensions;"
3. does not support collapsed nested .cs file. For example, in a silverlight application, .cs files are nested in .xaml files. if the .xaml file is not expanded and I attempt to perform a "Remove and Sort Using (this project)", the hidden nested .cs file will not get touched.
I am wondering if this is the best place to report issues, etc.
I am wondering if this extension can be put on codeplex for example?
Thanks for the feedback. I'll look at getting the code push out to Codeplex.
As for the shortcomings, the extension is exposing shortcomings in Visual Studio. This extension automates a built in Visual Studio command against multiple files - one file at a time. I don't have any plans on improving upon the built in VS command. Sorry if our extension causes you any problems.
Thanks again for the feedback, it is appreciated.
One thing I did come across is that you have to save the project you're working on as a solution to get it to work properly. This might be stated somewhere but was not evident and I don't always save my projects as solutions especially websites.
Once I saved the project to a solution it worked flawlessly. Nice Plugin...
If you can provide some details on the solution structure (project types, nesting structure, etc) then I maybe be able to reproduce the problem (and fix it).
Very few people have reported any problems with this extension or any another that I have published. When given the right information I can usually fix the bugs.
I just tried using this tool on a rather large web project and although it worked great on all the .cs files it did not remove the usings in the aspx.cs files. Is there an option I have not set to have it do this too?
I had a similar experience - first pass didn't catch every file but the second attempt worked.
I updated the code to look at every project regardless of type. It seems to be more consistent now.
The latest version is 1.4. If you have any issues please let me know.
"Imports" statements are not supported.
This extension automates a Visual Studio feature which doesn't work for VB import statements.
If the Visual Studio team decides to add support for VB then I will update the extension to take advantage of it. Currently, the extension will skip all non-C# projects.
Sure it does. It opens each code file within each C# project and executes the "Remove And Sort" command.
Essential, it will remove any unused "using" statements. Additionally, it will sort the using statements alphabetically.
It's designed to keep the solution tree in the same collapsed/expanded state after it runs. So solution explorer should look the same before and after it runs. Also, there won't be any files left open either. If a file was open before you ran the command it will remain open.