I recently organized the classes in my project into folders and would like to have the namespaces of the classes renamed according to their folders. I have tried to rename them using 'Rename' (F2) but the compiler throws errors at me (even after rebuilding the solution). What would be the best way to do this? As the title states, I'm using Visual C# 2010 Express.
EDIT: I'd like to know how to do this manually in case I need to modify namespaces beyond a month from now. Resharper looks very nice, but I couldn't justify buying it at this point. Also, why the downvotes to my question?
EDIT: Is there really nobody who can tell me how to do this? Or at least tell me it's more trouble than it's worth? Or a workaround of sorts? Anything at all?
You can always install ReSharper by JetBrains:
http://www.jetbrains.com/resharper/download/
They have a trial that works well for about a month, it can accomplish exactly what you want by right clicking anywhere and selecting "Adjust Namespaces", it will do the needed refactoring and you might find it to be a great tool to buy.
Related
Visual Studio has a "Refactor Rename" feature where I can right-click any type or member and rename it, and it will update all references within a project or solution to match. Is this functionality accessible from MSBuild command line tools, without having to open Visual Studio?
(I'm doing this because I have a project that is so large that Visual Studio runs out of memory while attempting to calculate where the rename is needed).
As far as I'm aware that's not something that's available outside of Visual Studio; although you probably have a couple of avenues available for getting it done.
The first thing that I'd try is using a lighter editor, VSCode, Atom, etc. Something that uses less memory, but will still hopefully let you get the rename done. You might have to use a regex find/replace to get it done; whether that's an option kind of comes down to if you can make an accurate regex.
If you can actually get the project open in VS with no (or less, at least) problems, then you could also start unloading projects that aren't relevant to the rename. If you know that it's only available in certain projects then unload everything else, perform your rename, and reload the projects. If it's everywhere then you might still be able to do something similar to this, perform the rename in a few projects, unload them, load the next few, rename, etc. Although I'm honestly not 100% sure that'll work, I've never attempted it.
Regardless of what you try, if you haven't already be sure to have your code in source control just in case. I'm sure this is doable, but maybe not via the VS command line.
No. There is no shipping msbuild target, task or tool to rename variables from the command line.
You could of course write yourself. :)
But I highly suggest using Visual Studio Code as an alternative to Visual Studio for loading large numbers of projects. It's an outstanding cross platform IDE. And who knows, perhaps someone wrote a plugin for it to rename variables...??
I need to generate a custom type of wrapper class from any existing one. An existing C# application is doing this very well, but its usage is quite annoying as it involves opening the application with the right file path, moving the generated file to the target location, modify the namespace and adding it to the Visual Studio solution.
I know that there might be other solutions, but I decided that I want an extension to do this (also for educational purpose). Target IDE is Visual Studio 2017 and it does not need to be backwards compatible.
For the usability it would be best to somehow extend the quick action menu when a class name is focused. There should be a possibility to do it, but I failed to find any resources on it.
Okay, for everyone that struggled like me:
My problem was that I searched for "quick action" instead of "light bulb". So after browsing the msdn documentation on extensibility, I finally found what I was looking for:
https://learn.microsoft.com/en-us/visualstudio/extensibility/walkthrough-displaying-light-bulb-suggestions?view=vs-2022
I'm trying to rename a C# namespace in Visual Studio 2015, and after a moment Visual Studio helpfully (?) tells me there are 216 unresolvable conflicts.
That's all the information it seems to provide, though.
How can I see what these conflicts actually are?
The preview button doesn't show anything obvious.
I have spent a lot of time but concluded that there is no way to see the conflicts but in all of the encounters I found out that it is because of one of the Documentation Comments Tag. The rename somehow is unable to rename values inside these tags.
I have just installed VS2010 in order to do some XNA development and I have noticed, coming from using Eclipse on a day to day basis, that one very useful feature appears to be missing. When I start typing a class name from another namespace, intellisense doesn't display it so I cannot autocomplete. I have to type in the full name, hover over the typed class name with my cursor, then click the menu that appears in order for the using directive to be added.
Is there a way to get a similar behaviour like in Eclipse where it shows all class names in the current project and automatically adds the import when you autocomplete?
you must use visual studio + resharper.
Resharper is the best addin for vs. It's a productivity booster! Although it's not free, It's worth it and there's also a free 30 days trial.
When you start working with resharper, you can't leave it.
Also, i recommend you to use stylecop too. It's an open soucee code rule validations and enforcement
It is a well known issue with Resharper that it fails to recognize generated C# files using Custom Tasks (making intellisense fail). Does anyone know how to fix this without adding the files to the project?
(BTW, including the generated files in the project or creating a separate assembly and other such flawed suggestions are totally out of the question).
Can we write a Resharper plugin for this? We have a fairly large number of developers that cannot use Resharper, so this would well be worth the effort.
Can we somehow add the obj/*.g.cs files to
Resharpers non msbuild based csproj parser (lurking somewhere within Resharper)?
Is the method used by Resharper on how to resolve the list of .cs files to include documented somewhere?
As this issue is experienced and reported again and again for years, surely there must be someone who has cracked it by now?
I found an extension for Resharper: ReSharper.ExternalCode.
Tip for Antlr: add obj\Debug in Resharper -> Code Inspection -> External Code and reload solution.
It's works for me.