Visual Studio Pro 2008: Equivalent of Eclipse's member list? - c#

In Eclipse, when you are viewing a class (such as Java), there is a window available to list all the fields and functions of that class. Is there an equivalent for Visual Studio 2008 Pro, for C# (XNA)?
(I'm looking for an easy way to locate and jump between functions. Is there a better way to do this in VS?)

It's called the class browser in Visual Studio.
Go to View -> Class View

If you have ReSharper try ReSharper->Windows->File Structure Window

Yes: View + Object Browser. Click around a bit more to discover these kind of features by yourself, it's worth your time.

Sounds like the Object Browser. Click View-Object Browser.

You're looking for the Source Code Outliner Power Toy.
(source: 280z28.org)

Related

Components for WPF similar to the simplified Visual Studio

I would like to make a support plug-ins in my program.
For example in my program there are several tabs in one tab is the editor in which the code is written also in that tab has a button run.
After pressing the button run occurs a compilation of source code and its execution.
The results of work are displayed in the other tab.
I would like to find such a component in which there are:
Syntax Highlighting, Debugger, Analogue of solution explorer
Thank you very much for your answers.
I would like to bring more of clarity to my question.
I want to do something similar to that is shown in the screenshots below
On a single tab there is the editor and at the other tab displays the results.
To write plug-ins I'd like to use C #.
I guess the best place to start is AvalonDock from CodePlex, specifically what you are trying to do is a Tabbed User Interface.
Keep in mind that even with a TabbedWindows framework build/debug and syntax highlighting are not for free and you will have to find icons and design the UI mostly yourself.
for code coloring there are also many components, also free, like Scintilla .NET
You obviously understand that Visual Studio is a very complex application, so rewriting portions of it will be difficult. There are components available to help you, like the ICSharpCode text editor. In fact, that whole project is probably quite valuable.
However, when thinking of plugins and actually writing code for it, I'd personally go down the MEF route. In fact, this is the very framework that VS.NET 2010 uses for extensibility. Provide your user/developer with a set of libraries to code against (like an SDK), and let them use a Visual Studio Express edition to write proper code :)
As source code editor you can use AvalonEdit (it is great, in some aspects even better than VS code editor), solution explorer is fairly easy to create and debugger is way too language-specific to be a reusable component (you didn't specify what language are you developing for!).
The whole thing can be packaged into AvalonDock, so you get the draggable and dockable panels - it even has VS 2010-like skin (and again - is very easy to implement even with only very basic WPF knowledge).
Or you can use the Visual Studio Isolated Shell - it allows you to use the Visual Studio interface in your program (the end users don't have to have VS installed!), but it requires extensive knowledge of VS API (if you ever developed VS extension you know what I am talking about). For example Civilization V used this approach for it's modding environment, but the result smells as stripped VS with custom splash screen, not as professional product. There are many buttons and config. options that don't work, some features that would be expected from such program (and easy to do in custom app) didn't get in because it would be nigh impossible to implant them into the VSIS etc...
EDIT: You may also eventually be interested in this.

How to display a form inside another form like Visual Studio

How does Visual Studio and other similar programs display a form in their IDE?
Is it possible to achieve the same or a similar effect using C# or VB.NET?
Please see the picture below to get what I mean.
If you are talking about hosting a Winforms editor in your code, it is entirely possible and is actually built in to the .NET framework!
The Essence is the IDesignerHost interface. The whole system is complicated, but can be done (I have done it in production code for runtime layout configuration editing). There is a sample of code from Microsoft here.
I'm sure if you search fir 'IDesignerHost' you'll find enough reference material to figure it out.
Are you speaking about UI creating tools?
Refer to http://www.icsharpcode.net/opensource/sd/ - SharpDevelop for deep dive. It's open sourse, so you'll be able to find out more details.
I believe what you want is a multiple document interface (MDI) see http://msdn.microsoft.com/en-us/library/ms973874.aspx for more info.

Extending Visual Studio with a Custom Designer

How do I create a custom Visual Studio 2008 UI designer for a C# file?
For example, when you double click on a DataSet in the Solution Explorer, a UI screen appears that allows you to edit the DataSet, even though it is defined in XML/code (which you can right click and "View Code").
Usually this code is separated from user code in some way, either by region ("Windows Forms Designer Generated Code"), by codegen (".g.cs" for WPF XAML files), or some other means like partial classes.
For some hints on Visual Studio Extensibility, see "Visual Studio 2010 addin writing articles/tutorials?". The Visual Studio SDK may have the information you need.
Well, you'd have to buy into the Visual Studio extension model. There are things you can do with the EnvDTE class. They are however fairly limited, not good enough to do what you want to do.
The next stop is the unmanaged extensibility model, based on COM. That requires writing unmanaged COM code, based on IVxxxx interfaces. Available to 3rd party addon developers like the company that makes Resharper. You have to get a license to write that kind of code, Microsoft won't be convinced you won't crash their product until you show some kind of proof you know what you are doing. You'll have to call, I think it is called the VSIP licence. That's possible, obviously it has been done.
Ask your company's legal counsel to take care of those hurdles.

Is there a utility that can monitor open windows/ in .net winforms?

This is a general question, but I'll explain my specific need at the moment:
I want to find the framework class that enables one to choose an image at design-time. I can find the editor that is used at run-time - its the Drawing.Design.ImageEditor. At design time, however, a different editor pops up which allows one to choose an image from resources.
I'm guessing I could run some kind of program, then open up the image editor, from the property grid, and see what new windows/classes have been created?
Thanks
Yes, you can see what's being used by using another instance of Visual Studio and use Tools + Attach to Process (managed) to look at the call stack. It is a Microsoft.VisualStudio.Windows.Forms.ResourcePickerDialog. That is not something you can use in your own code, the Visual Studio designer assemblies are not re-distributable. Nor would they be useful, they monkey with the design-time state of the project.
Making you own isn't that hard, just use Reflection to iterate the properties of Properties.Resources and find the ones that have the Bitmap or Icon type. Display them in a ListView to allow the user to pick one. Adding resources at runtime isn't an option.
A tool with similar functionality to what you mention is Spy++ which you can find in your Visual Studio folder on the start menu (under the sub menu Visual Studio Tools).
However, if I understand you correctly, I don't think the design time editor you're talking about is written in managed code and even if it was, I'm fairly sure it's not in the framework. It's just part of Visual Studio itself and as far as I know you can't get hold of the source code for that.

Visual Studio C# statement collapsing

When editing really long code blocks (which should definitely be refactored anyway, but that's beyond the scope of this question), I often long for the ability to collapse statement blocks like one can collapse function blocks. That is to say, it would be great if the minus icon appeared on the code outline for everything enclosed in braces. It seems to appear for functions, classes, regions, namespaces, usings, but not for conditional or iterative blocks. It would be fantastic if I could collapse things like ifs, switches, foreaches, that kind of thing!
Googling into that a bit, I discovered that apparently C++ outlining in VS allows this but C# outlining in VS does not. I don't really get why. Even notepad++ will so these collapses if I select the C# formatting, so I don't get why Visual Studio doesn't.
Does anyone know of a VS2008 add-in that will enable this behavior? Or some sort of hidden setting for it?
Edited to add: inserting regions is of course an option and it did already occur to me, but quite frankly, I shouldn't have to wrap things in a region that are already wrapped in braces... if I was going to edit the existing code, I would just refactor it to have better separation of concern anyway. ("wrapping" with new methods instead of regions ;)
Starting with Visual Studio 2017, statement collapsing is built-in.
There are several extensions that perform this task for pre-2017 versions of VS, starting with VS 2010 version:
C# outline
C# outline
2012 (#MSDN)
C# outline
2013 (#MSDN)
C# outline
2015 (#MSDN)
Visual Basic and C# Outliner
The last extension supports only VS 2015 and VS 2017, but it's the most powerful one.
It supports syntax coloring inside collapsed blocks, it is more fault-tolerant and optimized.
If the extension doesn't seem to install after you used a browser to download it, try using the built-in Visual Studio extension manager.
I'm not aware of add-ins, but you mentioned regions and I see nothing wrong with doing something like this...
foreach (Item i in Items)
{
#region something big happening here
...
#endregion
#region something big happening here too
...
#endregion
#region something big happening here also
...
#endregion
}
EDIT: In response to the question's EDIT: You're right, sticking a bunch of regions everywhere isn't ideal and refactoring is probably the way to go. But it seems that you're looking for something magical that will "organize" the code for you, and I don't think that exists.
You can collapse specific blocks of text within visual studio, but you have to turn off automatic outlining.
Right click in your code window and select (Outlining | Stop Outlining)
Then, select some text, right click and select (Outlining | Hide Selection)
When you turn on automatic outlining again, your custom "Regions" will no longer collapse.
Visual Studio 2008 supports regions inside of functions as long as you keep them in the same code hierarchical level
#region Won't work
for(int i = 0; i<Count; i++)
{
//do something
#endregion
}
for(int i=0; i<Count; i++)
{
#region Works fine
//do lots of stuff
#endregion
}
Let me say something different: press(ctrl+m,ctrl+h) or in edit>outlining>hide selection
its so useful.
This feature has been added to Visual Studio 2010's C# editor. I can't find the source verifying it was actually put in, but I remember seeing it on one of the Dev 10 team member blogs talking about changes since Beta 1 or something. As a consolation, here's one Microsoft comment suggesting they wanted to add it.
I will add here that in VS 2010 Microsoft has added WPF adorner capabilities using Managed Extensibility Framework (MEF), this will allow us to extend the source code editor to organize them in a much better way to make it more readable and accessible.
For instance the Summary Comments visualizer that Scott Gu demoed at PDC 2008.
So look forward to a better tomorrow for developers :)
Coderush will outline all code blocks for you. Not sure if it allows you to expand/collapse the blocks, but outlining is the next best thing. I use resharper instead of coderush which as far as I know doesn't provide block collapsing either :(
I have found this for Visual Studio 2013 and found it very helpful. It works even if you put simple braces around your code with { ..... }
After sharing I found somebody else also mentioned this link. My vote is for this tool also.
C# Outlining Tool for Visual Studio 2013
In VS2017 you can highlight a section of code, right-click, Outlining > Hide selection. This will collapse the code and provide a toggle to the section highlighted.
In Visual Studio 2019, if you want to collapse braces in catch & finally, collapse switch, case, default, collapse multiple lines of comments, etc.
Try to use C# outline 2019
# region ,#endregion is the smart option.

Categories

Resources