Renaming Namespace in Visual Studio? - visual-studio-2010

In my visual studio sharepoint 2010 visual web part project, while creating the project, I typed the name that I want, yet when it went to the class file for editing, the namespace code says:
namespace PDFLibrary.VisualWebPart1
The PDFLibrary is the name I put which is ok, but I want to rename VisualWebPart1 if possible.
Does anyone know how to do this? Please share if this is possible.
Thanks.

You can select the VisualWebPart part of the name and right click it, then select Refactor->Rename, or select that part and press Ctrl+R+R which should have the same effect.

You can also use "search and replace" in entire solution. Just search all "PDFLibrary.VisualWebPart1" in your solution and replace with your new string. This is what Refacor -> Rename does as well.

Related

Is there a way to auto select filename when creating file in Visual Studio 2019?

When I create a new file in Visual Studio with the wizard, I expect it to "auto-select" the filename, so I can immediately start typing the filename. I automatically do this as I use a lot of programs and such that do have this feature and let me type it directly after clicking on a new file, for example, Windows Explorer.
I hope I am clear about the problem, it would be great if someone knows someway to do it.
If you want to create a class. You could right click on a location in your Solution Explorer -> Add -> Class. This way the file creation wizard knows the type to create and thus will focus on the filename.
The "New Item" file creation wizard requires you to find a file type to create first. That's why the filename is not selected at first.
I hope this answers your question.

Visual Studio 2017: Disable Intellisense for CodeSnippets

I'm using Visual Studio 2017 Enterprise, Version 15.3.3
I looks like IntelliSense has some new features for code completion. On of this feature is, that a field name is automatically suggested when a type is written.
SpacePosition s.. // starting with s, Intellisense suggest "space", "position" and "spacePosition"
I like this feature in general but not for code snippets. Using a code snipped I have the problem, that the name of a literal is automatically replaced by IntelliSense after pressing tab (which is used for navigate to the next literal).
In my example I want to name the property "other" and then jump the the next literal inside the snippet. But because of IntelliSense, the property name is replaced by "spacePosition".
Is there any way to disable the IntelliSense feature inside code snippets?
I found a solution for the same problem in Visual Studio Code:
stackoverflow article but not for Visual Studio
Disable the name suggestions in Tools/Options/TextEditor/C#/IntelliSense. That's what is causing this nonsense. Seems MS realized later that they flipped coders up by adding that feature that changes old behaviour greatly without giving them a way to disable it. Now there is such a checkbox.
I nearly uninstalled this studio because of this lol. Not sure, may be it's a good feature, but i'm too used to Tab code snippets around, that I'm better without it.
How to: Manage Code Snippets
To access the Code Snippets Manager
1.) On the Tools menu, click Code Snippets Manager. Shortcut Ctrl+K,Ctrl+B
How to: Change snippet behavior
To change snippet behavior.
1.) Go to Tools > Options > Text Editor > IntelliSense > Snippet Behavior
2.) See images.
Now there has no such option to disable this intellisense feature inside code snippets, but you can try to click 'Esc' key after type 'other', then click 'Tab' key to jump to next literal, please check the following:
This actually works correctly in Visual Studio 2019 for classes if it is a class that is valid for the current context (i.e. Doesn't exist in a namespace not in the current class namespace or in the using statements for the file).
Here is my example snippet
Snippet Definition
Snippet Use
And here is an example where I use two different classes as the second snippet, one that is a valid class name and works to use tab to autocomplete, and one doesn't work because the class requires adding an additional namespace using statement that is currently missing from the file:
So I see two options.
Use the sucky to cancel any auto-complete logic.
Ensure you have the proper using statements. You can even add using statements to your snippet using the imports declaration:

How to select usage suggestion hint

When I type the name of a class without specifying the full namespace and the class is not made available by the using statements, Visual Studio guesses which class I mean and shows the fully namespaced class name in a hint.
For example:
If I click it it adds the necessary using statement.
How can I select that hint using the keyboard?
So it turns out that this actually a ReSharper feature (not something that is built into Visual Studio) and I can press Alt+Enter to select it.

ReSharper: Rename namespace not available?

I'm trying to rename a namespace. For some reason, ReSharper isn't giving me the option to do so. I right click on it and choose Refactor, but everything except "Convert" is greyed out. I try the key combination CTRL R + R, and it says the command is unavailable. What am I doing wrong?
Here is documentation suggesting that what I am trying to do should work:
http://www.jetbrains.com/resharper/documentation/help20/Refactoring/renaming.html#renameNamespace
I'm using Visual Studio 2008 with R# 4.5
I have come across this before and the answer is very subtle. Do not select (eg by double clicking) the entire method name(or namespace if renaming a namespace). Instead, ensure the method name is deselected and place the caret over the method name.
eg
NOT this
When you select the Convert menu the items should now be available for methods, and 'Rename' will become available if you had the caret over a namespace.
In my mind this should be changed, it is not obvious.
Apparently, the way to do this now is via ReSharper => Refactor => Adjust Namespaces menu or open the Class View, right click on the namespace you wanted to rename and again select Refactor => Adjust Namespaces.
See also: Fastest way to update namespaces with ReSharper?
For what it's worth, I just had this problem. Closing Visual Studio and re-opening it fixed the problem for me. HTH.
This is an old issue but I just had this and perhaps know a workaround.
Since someone has commented just yesterday timing could not be more perfect.
Anyways,
I had the same issue and was finally able to do a rename refactoring on my namespace.
I chose one of the classes in my project and did the move to another namespace refactor.
Then I was able to go to another class and do the rename namespace refactor.
Perhaps a bug in Resharper that if the namespace is consistent throughout the class then it's disabled? Unlikely since this was reported as far back as 4.5...

VS2008 Navigate to class definition add-in

I am looking for a Visual Studio add-in that would analyze the text around the cursor position and navigate to the corresponding class definition.
For example I have this XML file that is currently open:
<object id="abc" type="MyProject.Foo.Bar, MyProject"/>
If I put the cursor somewhere between the double quotes on the type attribute the add-in should obtain the string "MyProject.Foo.Bar, MyProject" and search for all projects and project references in the current solution for the given type and if it finds one, it should navigate to the class definition (or metadata if the source code is not available in the current solution).
If such add-in doesn't exist I would greatly appreciate some pointers that could help me writing one.
Well you could use the 'Code Definition Window' that comes with the VS2008 IDE. When you place your cursor, the Code Def window dynamically updates with the source code for that type. Works with regular source files.. don't have the IDE at hand to verify with XAML/XML
Also you could 'Jump to Symbol' key combo but you would need CodeRush Express add in for that. Shift+Ctrl+Q. More details here.
Use the Alt+G command in Visual Assist.

Resources