Universal change of namespace across projects - c#

We have a solution with ca. 60 projects.
The standard we have used for namespaces is CompanyName.ProjectName.Area.VisualStudioProjectname.
Now the project has changed name.
Is there a way to change the name of the namespace across all projects, wcf services and service references?
We have ReSharper if that could help.

There are different ways u can achieve this result.
Beginning from ReSharper version 5.0 and above u can simply use
ReSharper -> Refactor -> Adjust Namespaces...
but in your situation I do not think this is what u are looking for.
There is another solution as well simply open one of your code-files select portion of the namespace u want to change hit CTRL + R + R and then rename. it will go through all your project files and adjust and rename new namespace.
the same result can be achieve to update them fairly quickly through the Class View window. Open class view window, click on the namespace you want to rename, hit CTRL + R + R and then rename.
as u mentioned you are using ReSharper so u have everything u need to get the result.

How about a good old Edit / Find and Replace / Replace in Files?

ReSharper -> Refactor -> Adjust Namespaces might do the trick.

Possibly a good use for the Block Sync Edit Visual Studio extension.

Related

Find method in current file/class in VS2015/C#

I can use the Ctrl+, shortcut to search for methods but will search among the entire project:
This lists all the classes in all files that have this method, and I want to search only in the current file, similar to Alt+M in VAssistX. Is there a shortcut for that?
I found Is there an easy way to jump right to a method within a file?, but it's for VS2012, and they only suggest Ctrl+F or Ctrl+,.
Note: I'm looking for true navigation, not Ctrl+F, and only within the current file, unlike Ctrl+,.
To expand on the answer by Matt Schley:
Ctrl + F2 -> Tab -> then start typing and it'll sift through the functions in the file.
I know you were probably looking for something else, but this is as good as it gets for what's built into Visual Studio. Maybe there's extensions available.
EDIT
This is a mapping for C#. The command name is Window.MovetoNavigation
For C++, it's default is Ctrl + F8
Not sure if this is what you're looking for, but there is a dropdown menu right above the code editor window that lists all methods and properties in the current file.
Try Ctrl + F2 to active the navigation bar, then tab over twice and you can scroll through the dropdown.
For VS2019 you can use Alt + \ for object search.
From https://learn.microsoft.com/en-us/visualstudio/ide/go-to?view=vs-2019, it says Ctrl+1, Ctrl+M for Go to the specified member. You can add your own combination to this command by going to Tools -> Options -> Keyboard and choosing Edit.GoToMember. For me it works just perfect.

Visual Studio 2013 - is there a way to re-structure the code?

I've written some messy laid out code, is there a way in VS2013 to re-structure it with the click of a button?
In general the keystroke is CTRL + E, D. However, if you're in an Express version I believe it's CTRL + K, D. But bear in mind this can really determine on how your environment is setup.
It depends on the file type, but Edit -> Advanced -> Format Document often knocks C# and VB.NET files into much better shape. Keyboard shortcut is (usually) Ctrl+E, D.
Resharper, a popular (but not free) Visual Studio plugin, offers a ton of interesting code formatting features as well, whereby you can define all the rules by which code "should" be laid out, then you run one command and it'll clean everything up. You can even save those settings in a configuration file inside the project, so that your whole team can share it.
Ctrl + K + D (Entire document)
Ctrl + K + F (Selection only)

Get question mark instead property name and value in Debug Mode in Visual Studio

My issue is: during Debug Mode in Visual Studio I can not see property name and it value. Any suggestions? UPD This bug/feature is reproducible in college PC.
UPD(15.06.2012)
The base class is placed to separated lib. Base class is abstract. And... Two times Debug was working fine, after making changes in source file (in screen-shots) and then running the project.
Please notice that Immediate window can not evaluate this expression.
MailProcessingViewModelContext inherits that base class that I have mentioned in the top of UPD.
It's a bug in Visual Studio that's caused when you scroll through the properties list with a mouse. Click the down arrow at the bottom of the menu instead.
As somebody on top already mentioned, you need the debugging symbol files (.pdb's) for every dll that you are using which is not your code, otherwise VS can't look 'inside'.
and if it's obfuscated you won't see anything at all
This would happen if you were debugging an ASP.NET wizard and wanted to check a collection of something, all elements in the collection that are in the current wizard step (current context) would be visible while the others are there but not in context just now hence marked as questionmarks -> ?
Maybe it could be something like that in your case. I guess it could be the same scenario
For me, this happened when I had a getter property in a class model pointing to itself. It was a copy paste error, notice the property name is ShouldNotProcess, and in the getter it's returning itself. The return was supposed to be: return !this.ShouldProcess;
public bool ShouldNotProcess
{
get { return !this.ShouldNotProcess; }
}
Are you trying to debug your own code or someone else's?
If it's not your code, the code has probably been obfuscated so you cannot see the private members or use reflector to reverse engineer it.
This also might happen if you're using a trackpad to scroll through the member list. Try using the keyboard instead.
You cannot access these menu items or display these windows in design mode. To display these menu items, the debugger must be running or in break mode.
REF:
http://msdn.microsoft.com/en-us/library/bhawk8xd
Is there a possibility that the object you are referring to belongs to another project (library template) and you added it as a file reference and not project reference?
Please share the details about the structure of the projects in your solution. Also the location of the class you are trying to access.
Make sure you're running in debug mode, I know I'm probably stating the obvious there. Also, check that expression you're evaluating - is it right? Are you casting to the right object. Finally, is the assembly that contains the class you are looking at included as a project in the solution, or just referenced as an external assembly? Make sure it's part of the sln.
If it's recreatable on another copy of visual studio then I'd guess it's not a problem with Visual Studio, but the object you are looking at.
Not sure if this is the case in your situation, but here is a post with a similar issue. Hope it helps

Visual studio autocomplete to find a file?

In the Visual Studio, do we have a tool to find a file based on file name insdie a project, like typing a few letters of beginging of a file, it will autocomplete to show all files starting with that letters. In the Java Eclipse, we can use Ctrl+Shift+R , do we have similar in the VS ?
Thanks
Yes, there is something like that.
You can use the Find text box you use for normal searches as input for the Command Window. Then in the Command Window you have the of command to search files.
To do it:
CTRL + /to select the Find text box.
Type > of then the file name (or part of) you want to search for.
A dropdown list will show all files that match your typing (so you do not have to know the full file name as with CTRL + SHIFT + R).
If file list is pretty long you may use the normal Find in Files dialog, simply set Use to Wildcards, in Find what type * and write the search pattern in Look at these file types. Check the Display file name only option. Using the Look in field you can limit the search to current project, entire solution or whatever you need.
Try ctrl-spacebar, it's the normal shortcut for intelisense. If it doesn't work for file path and name, there is surely a plugin out there just for this.
I use VS with only resharper as a plugin and I can do this, I don't know if its resharper that does it or if its prebuilt.
EDIT: It is resharper that does it. I would recommend using it if you intent to work with VS as it greatly helps out on a lot of refactoring and shortcuts.

Is there a way in ReSharper to suppress all errors/warnings in one file?

I have a number of generated .cs files (originating from WSTL files). ReSharper isn't happy and I'm getting so many errors/warnings that its tough to separate the signal from the noise.
Is there a way to work around this? Can I suppress all the warnings/errors in an easy way?
My goal is to keep from (or minimize) changes to the generated files.
Turn code analysis on/off => Ctrl + Shift + Alt + 8 (with Visual Studio key bindings; otherwise it could just be Ctrl + 8 )
There are different ways to mark code as generated in Resharper the documentation explain them all but i guess that for your case changing the name of the files to match the default *.generated.cs would be the simpler.

Categories