Extending Visual Studio Code Review Functionality - visual-studio

I am interested in writing an extension for Visual Studio 2013+ that enhances the current code review functionality available in TFS. This extension would add an additional control next to each comment in the Team Explorer - Code Review window. It would also need to hook into the event that saves a comment, and update the text of the comment based on the value of the control.
I have already written some extensions for Visual Studio that create tool windows and the like, so this is not an entirely new area for me. However, I am unclear how to go about adding content of hooking into events for an existing window (such as the code review window), and the documentation seems to be very light on how to approach this. My questions are:
-Is it possible to add controls to existing windows with Visual Studio extensions? Or is the extension functionality limited to adding new tool windows with custom UI? Would this be possible as an extension on top of the existing code review functionality, or would it have to completely re-implement the code review functionality, as extensions like Review Assistant appear to do?
-Is there anything documented specifically about the code review windows within the Visual Studio IDE, or any classes that allow extensions to interface with them? If there are any events documented in the IDE related to code reviews (ie: an event that fires upon saving a comment) that would be especially helpful.
Thanks for any help!

A few months back we were also in the same situation but for disabling a control in the CodeReviewPage.
What we did was added a hidden section to the CodeReviewPage. When this section Initialize(object sender,...), and from the sender object received as an argument we used Reflection to reveal the CodeReviewPage object and then further explored the control inside that we wanted to disable. This object was then type cased to the Control class and then we had all the properties exposed for that control and then simply we applied the ctrlObj.IsEnable = false.
For your case you can expose the Section from the CodeReviewPage object from sender object and then modify the section or add a new control and bind some events to it.

Related

Visual Studio Team Explorer Extension

I am trying to create an extension for Team Explorer window in VS2017.
I want to put another button on the changes screen, or even hook into the commit method, so that I can take the comments, and integrate with a Kanbanize board.
It seems like it should be possible to but a button onto the Team Explorer window, but there doesn't seem to be any documentation I can find, or examples.
I have looked around and can only really find this link below, which I tried but doesn't seem to work, but isn't really what I am wanting to do.
https://hamidshahid.blogspot.com/2017/09/extending-team-explorer-in-vs2017.html
The Team Explorer extensibility is designed to enable adding new sections to an existing page, but altering the existing sections to change their UI/behavior is not allowed. Given this design constraint, you can add your own UI, but it'll need to be in a separate section. You should be able to read the selection data from other sections on the Git Changes page via IChangesExt.
Hope this helps.

How to add controls from a control library to VS studio toolbox automatically (WP7)?

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.

Visual Studio - easy way to bring up type definition as source code

Oftentimes I want to bring up a system class in a source view, so that I can browse the properties and methods exposed by the class. Below is the screenshot of what I mean:
Srting from metadata http://img443.imageshack.us/img443/940/stringfrommetadata.png
Usually I do this by selecting the class name and pressing F12 (or right click>Go To Definition). However, if I haven't got it anywhere ready, i have type it up and then do Go To Definition. Most of the time I have to delete what I typed later on.
Is there a way to bring up this view without having to type the class name? The VS2010 Navigate To dialog doesn't support this.
EDIT: When I posted the question I didn't use any Visual Studio plugins. Now that I realised that I have full CodeRush license (thanks to StackOverflow promotion for users with 10K rep) I will accept answers that use CodeRush or Refactor!.
EDIT: At this stage I haven't really got anywhere with trying to answer this question. I am going to leave it open and let the bounty auto-award itself to Rory as he explained what's happening the best. In the meantime(schedule allowing) I will investigate doing this with DXCore as I think it should be possible.
The view you're looking at appears to have been built by some sort of analysis of the IL of the framework. Without knowing the type you intend to look at, no deconstruction can be done. Therefore I feel that, you are unlikely to find exactly what you have said you are looking for.
Allow me to suggest a few alternatives though.
Disclaimer: I work for DevExpress as a CodeRush Community Evangelist.
The Object Browser (Ctrl+Alt+J) This screen will load without attempting to show you any particular type, it will therefore be down to you to find the type in question. However all types are available and full search functionality is provided. once the type you're looking or is found, all members are listed and available.
Update: If you use the (Ctrl+K, Ctrl+R) shortcut to launch the object browser, then it will launch focused on the Search box. This is invaluable.
There are a number of CodeRush features which can prove useful when trying to locate code.
TabToNextReference (Tab) Whilst the caret is positioned within a type, strike the tab key and the next reference to that type will be located. More Details
References ToolWindow (Shift+F12) When activated the References ToolWindow will show you any references to the current type or member. This toolwindow can also be used to navigate said references. The References Toolwindow can be used in both on demand and Live mode. this allows you to have the window update as you navigate your code (via mouse or keyboard) and locate all references of any symbol the caret lands upon.
QuickNav (Ctrl+Shift+Q): This feature is closest in style to VS2010's NavigateTo feature. QuickNav will locate symbols matching whatever you type into it's filter box. This facility also supports Camel Case search. More details
QuickNav is also much more configurable than it's VS counterpart
Finally
Please also keep in mind that CodeRush is build upon the DXCore, a framework which allows users to create their own plugins for use alongside each other and CodeRush.
This framework has been repeatedly been leveraged by the community to add additional functionality. So even if you don't see any thing quite to your needs, consider suggesting something to the community by way of the forums or even contact me directly RoryB at DevExpress dot Com
I'm sure there's something we can do to help you out :)
I was not aware of that new "Navigate To" feature, but I used to use Reflector for this sort of things. The pro version offers some integration with Visual Studio (Right clicking the method and selecting "Open In .NET Reflector"). It will open the reflector window and won't show the code in the VS itself. You can watch the demo that shows this feature and some others.
This is not the best answer that I'd expect but is a good option to know.
There is no way that I know of to do this in Visual Studio 2010. However, you can do this in ReSharper via the 'navigate to' menu. I suggest you try the 30 day trial from them, then if you really do need this then purchase it.
A number of add-ins allow you to browse objects (though usually in an object-browser treeview manner rather than in a "header" file form - I believe Resharper, CodeRush and Visual Assist X all have variations on this theme).
However, one add-in to consider (as it's free) is the VS Productivity Power Tools. It adds a Solution Navigator window that gives a view onto your solution just like Solution Explorer, but (among other enhancements):
can search & filter the files listed, e.g. show only those files that are named Test.
can "expand" any file entry to show the types and members within it.

Visual Studio 2010 with Managed Extensiblity Framework

I've been looking into into MEF (Managed Extensibility Framework), but I am not entirely sure if it is something that I need and can help me accommplish what I need to do.
Can someone provide an easy to understand description of MEF, provides good resources and tutorials (aside from MSDN), and/or know if it can do the task I am trying to do under Visual Studio?
The task I am trying to do is to "log" a string of text to a text file whenever the user selects a string of text. I also need this functionality to run passively and real-time, which Visual Studio Add-in's do not support this functionality, as their behavior is "click the button to work".
It looks like the docs here
http://msdn.microsoft.com/en-us/library/dd885240(v=VS.100).aspx
may be one useful starting point.
See my response to a similar question.
The answer is "yes", this is possible/supported. Look for the following in samples/documentation/walkthroughs:
IWpfTextViewCreationLister - for detecting when editor instances are created.
ITextView.Selection - the selection object
ITextSelection.SelectionChanged - raised whenever the selection changes (though not for the empty-selection tracking the caret)
I'm sure this is possible in .NET without going 'close to the metal', probably a reference to 'lower level code'. The .NET Method TextPattern.GetSelection Method will help you to accomplish your task if combined with a MouseEvent Handler.

Visual Studio ‘Go To Definition’ menu option behaviour - Why is it inconsistent between C# and VB projects

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".

Resources