At times you get a file that is littered with unnecessary this-qualifiers, casts and namespace qualifiers. The refactorings to remove these are available, but there does not appear to be a way to remove all of these at once? Couldn't find it in the code cleanup, and it would be nice to have a "Remove all" in the refactoring menu itself.
If this is possible in the current version, I would appreciate some information on how to perform this, otherwise consider this a feature request. :)
Hello Peter,
We have Code CleanUp rules for 'this' qualifiers and redundant type casts. I have attached a screencast that illustrates how you can configure this.
As for redundant type qualifiers, we do not have such a Code CleanUp rule at present, but we plan to add it in future releases.
You will be notified when we make any progress.
How did I ever miss the "Remove redundant type casts" option? Sometimes you miss the most obvious things. Thank you very much for a great explanation of how to accomplish this. Looking forward to the redundant type qualifiers in the future as well. :)
You are welcome, Peter!
I kindly ask you to rate CodeRush for Roslyn in Visual Studio Gallery: CodeRush for Roslyn.
Thank you in advance.
Peter,
We have recently released a new CodeRush for Roslyn 16.1.8 version that includes the "Remove Type Qualifier" refactoring.
It would be great if you can try it out and share your feedback with us. Please refer to the what's new list for more details.
It does not appear to work very well, using my CodeRush settings anyway.I don't see a refactoring invokable from the context menu that does this, but it seems to be available in the code-cleanup, "Remove reduntant type qualifier". However, consider the following program:
using System; namespace ConsoleApplication38 { class Program { System.DateTime dateTime; void Test() { System.DateTime s = DateTime.Now; Console.WriteLine(s); } } }
When I run CodeCleanup on this using the attached settings, the following is the result:
using System; namespace ConsoleApplication38 { internal class Program { private System.DateTime dateTime; private void Test() { System.DateTime s = DateTime.Now; Console.WriteLine(s); } } }
Note that the redundant "System" qualifier of the DateTime variables are still there.
Hello Peter,
I've created a separate ticket on your behalf (The "Remove Type Qualifier" refactoring does not work in some scenarios). It has been placed in our processing queue and will be answered shortly.