I have a file of a user control but it's not in a project, It's just read by a webpart in sharepoint and I was editing it but suddenly the AutoComplete for classes and variables like controls, SQL .. were gone. Only the common keywords are available like if, int, while ...
How can I get them back?
When you just have a single file, I believe Visual Studio just opens it in the code editor, and not the IDE/Compiler. The editor is just syntax highlighting basically, though you do have the drop downs available to navigate subclasses and methods. As when you're dealing with projects, it does use the IDE/Compiler, so Intellisense is available as well as full editor/ide features for that language.
Create a new empy ASP.NET Website and then add existing item and choose this user control.
Related
I want to achieve that when the user installs the WP7 control library he will find it in the Visual Studio toolbox automatically without manually adding it. In addition I would like to organize toolbox tabs in a logical manner.
I know it can be done for other platforms. For example I tried writing *.design.dll as described here - it does not work for WP7.
Any pointers how to work with toolbox for VS 2010 / WP7?
Nobody answered, so here is my brief summary:
The control library cannot be added to the Toolbox automatically unless you program VS plugin (package). Too much work for me...
*.design.dll (see the link above) basically works.
2a) You can hide controls from the Toolbox (BrowsableAttribute) and you can define control icons. That's probably everything you can do for Toolbox. The user has to add Toolbox tabs and "choose items" manually.
Well, I am not quite sure here, because when you drop the control dll file onto the Toolbox, then at least ToolboxTabNameAttribute works, i.e. corresponding Toolbox tabs are created automatically. Unfortunately, the tab is empty.
Also, when the control library is properly installed, then some of the controls are added to Choose items Toolbox dialog. Unfortunately, in my case most of the controls are missing and have to be added by manual browsing.
2b) Designer support (Properties window for the control) is better. You can hide properties (BrowsableAttribute), define categories (CategoryAttribute) and define descriptions (DescriptionAttribute).
Descriptions can be extracted from you documentation xml file, so that you don't need to write them again. To get the code google for MetadataBase.cs. Just be carefull, the files you'll find contain fatal bugs (ParseDescription method) and ignore some properties (getters that return a collection).
After all, the result is not that bad.
I'd like to create an extension for Visual Studio 2010. The functionalities I need are these:
Add a context menu item for Project (when user right clicks project name in his solution, he'll get my context item in the list).
When he clicks, a new WinForms form appears, where he can input some data, and an option to save that data for future reuse.
When he clicks OK on that Form I'll generate some files and add those files to be a part of his project that he rightclicked.
The WSCF.blue is exactly the kind of behaviour I want to immitate in VS, but it's source was written in VS2008, and I'd like to use VS2010 Extension options which are quite changed as I understand...
I found some resources on the msdn, but I found it confusing with incomplete info (e.g. MenuAndCommands example).
Can anyone shed some light on how to achieve what I'm after?
I really don't know where to point out so you can get specific examples of what you are trying to achieve. However, in the following resources you will find complete and detailed information about the overall process, and some help to achieve 1. and 2.
VS 2010 Package Development – Chapter 1: Visual Studio Packages
VS 2010 Package Development – Chapter 2: Commands, Menus and Toolbars
I know that for clarity in codes, I have to write first fields then constructor and then methods etc. But how can I automate it in Visual Studio?
I think CodeMaid is the best free option for code formatting in Visual Studio.
To sort your file, open the file via solution explorer:
Right click the open file
Code Maid menu (likely near the top of the right click menu)
Click Reorganize Active Document
Alternatively, using the default CodeMaid hotkeys CTRL+M,Z to sort your active file.
ReSharper can sort your class members (fields, constructors, methods, delegates) by name, accessibility, type, readonly, etc... You can also surround specific members with regions. What I like the most is the ability to group interface members (e.g., #region IDisposable with void Dispose() method in it) and methods that handle an event.
ReSharper provides both - an easy way to configure and trigger the sorting of class members.
Configuration
Create a XML file within Visual Studio and copy-paste the default type member layout (ReSharper Options > Languages > C# > Type Members Layout) into that file. Download the latest XSD schema. Add the schema file to Visual Studio's schema files (Menu > XML > Schemas... > Add). You should be able now, to edit the XML file with the help of IntelliSense.
Triggering
If you use the Visual Studio keyboard scheme (ReSharper Options > Visual Studio Integration) and press Ctrl+E,F for Silent Code Cleanup. A dialog will pop up, where you can select a Code Cleanup setting. For this setting you should check Reorder type members. The second time you press the shortcut, ReSharper will automatically reorder your class members.
1: ReSharper Type Members XSD Schema
Visual Studio has no feature that allows re-ordering already written code. That's the domain of add-ons. Resharper has a "Reordering type members" feature but that's only supported for C#, not for VB.NET code. NArrange seems to be able to do this. No idea, never used it myself.
Limited sorting of lines is included with Visual Studio 2022.
To use: select the lines you want to sort and in the top menu click:
Edit > Advanced > Sort Lines
Another option I found is XArrange. It is free and can be installed from the Extension Manager.
Issues I took with it...
It puts methods before constructors.
It removes any comments between members,properties,methods, etc.
It's configuration is very limited. No way to change sorting order.
If Code Sorting is your only concern, you can try the Visual Studio Extension CodeSorter
CodeSorter is highly customizable extension that allows its users to
sort C# code itby various conditions such as names, types (method,
class, struct, ...), visibility modifiers (private, public, ...),
constness modifiers (const, static, readonly) and virtuality modifiers
(virtual, override, new, ...).
It is possible to assign multiple search criteria to have the same
priority, for example place protected and private members first, and
then publics and internals.
Names are compared in a way that leading "m_" and "_" is stripped.
This allows fields and properties (eg. _foo and Foo) to be right next
to each other.
One-lined declarations are placed without delimiting blank line, while
multi-lined declarations are separated by a blank line. The exception
is that one-lined field followed by a multi-lined property without
comment of the same name will be placed without the delimiting blank
line.
Is there any way to associate a web page with a project in Visual Studio, and have it load up in the IDE? For example, I have a project who's task list is maintained on a web site. It would be ideal to see those tasks within the IDE instead of a separate page. I can accomplish that now by following these steps:
Press Ctrl-Alt-R to open a Web Browser page
Change the URL to my desired path
Position the page as desired (like in its own tab group, off to the right of my code)
It would be nice to have a link somewhere in my project that I could click and open this page in the IDE without changing the URL every time. I have several different projects that would benefit from this. Any ideas?
Something like this happens with Visual Studio Team Foundation Server. The various documents and guidance associated with your current Team Project area accessible from within Visual Studio, in the Team Explorer window.
You can also create a Guidance Package to apply various commands and pieces of documentation at appropriate places within your projects. see Guidance Automation Extensions and Guidance Automation Toolkit.
Nice idea. The only thing that I can think of is via Visual Studio Extensibility. Basically,
Define an MSBuild property in the project file or a custom field in the solution file that has the project url.
Write a VS package that subscribes to the solution load event or something similar (I am not familiar with VS object model but I am sure there is an event like that) and looks for that custom field and extracts the url if it exists in the solution or the project file and then opens a web browser within VS that points to that url.
Here's my quick hack around this problem:
Create a text file in the project. I called my "notes.txt", and I use it to store notes, ideas, etc. that don't have a home elsewhere in the project.
Add the web link to the top of the file.
Open the text file in the IDE and put it in a new tab group. I put mine in a vertical tab group off to the right.
Drag the separator as far over as it will go to "hide" the tab group. This way it's always open and available but not taking up much space.
When you want the web page, "show" the tab group (i.e. drag the separator back) and ctrl-click the link.
This has the added benefit of opening the web page in the same tab group as the text file, so you can push them both aside when not using them.
I'm sure there's more that could be done by writing packages as others have suggested, but this was a low-effort way to get me close enough to what I wanted. I'd love to hear other suggestions or modifications that might make this setup better.
When developing in a VS2005+ with C# project and I right click on a framework method/property/type and select ‘Go To Definition’, by default we get a new locked tab with code that has been generated from the framework, labelled appropriately [from metadata].
However when we do the same in a VB.NET project, you get taken to a new tab with the relevant Object Browser view.
This has always struck me as peculiar and was hoping there was a good reason behind it. IMO the object browser is nicer.
Is there a logical reason for the difference in default visual studio behaviour? If so, what is it?
It's a choice each team made based on what they believe their respective customers wanted to see. VB users have a historical attachment to the object browser and many VB features are integrated into it (Go To Def being one of them). C# made a switch in VS2005 to generate metadata on the fly for their version of GoTo def because they believed their customers would like the behavior better.
You can install Resharper for this.
It'll allow you to choose the default behavior when clicking the "go to definition".