DotNetCurry Logo

Code Search using Visual Studio Team Services a.k.a VSO

Posted by: Gouri Sohoni , on 12/7/2015, in Category Visual Studio, VSTS & TFS
Views: 8568
Abstract: Code Search is a cool feature available only with Visual Studio Team Services a.k.a Visual Studio Online. It allows you to search code across TFVS and Git projects in Visual Studio Team Services.

Code Search is a new feature to search code across TFVS (Team Foundation Version Control) and Git projects in Visual Studio Team Services. It is scoped to your VS Team Services account you apply. It provides full text search as well as allows you to search for specific contexts like class definitions, comments etc.

In case you are wondering if Visual Studio Team Services is a new product, please note that Visual Studio Online (VSO) has been renamed to Visual Studio Team Services or also known as VS Team Services (VSTS). VSO as a name was a little confusing as people used to think it is something related to Visual Studio, but actually it was TFS as a service in the cloud. Apart from the name change everything basically remains same.

 

Installing Code Search

Code Search is available in the Visual Studio market place as a free download and install. As the feature is only available with VS Team Services, you need to apply it for all or a particular VSTS account. In order to install it you can go to https://marketplace.visualstudio.com/  select the tab for Visual Studio Team Services and you get Code Search.

get-codesearch-marketplace

You can also go to market place from your Visual Studio Team Services account by selecting a small icon from right hand corner as shown below

marketplace-on-vsts

Once you click on Install and select the account for which to apply, it checks for permissions. If you are account administrator it will immediately allow to install and apply, but otherwise it requests for installation. This request is sent to account administrator which can be verified by him/her and approved. This Code Search feature is available as one of the extensions for VSTS.

Once you have installed the feature, it will take some time to index your projects before you can actually start using it. Please wait till the indexing is complete to try how it works.

After installing Code Search for an account you will get a text box on the right hand side as shown below

code-search-textbox

Key Features

The key features provided by Code Search are as follows:

  • Full Text search across all non-binary files
  • Query can be added with filters like by code type, projects, file names, file extensions.
    • The operators like AND OR NOT can be used
  • Provides integration with Version Control in terms of
    • Tracing who changed the line of code
    • Tracking change history
  • File permissions checks

Searching Code with Code Search

Let us see code search in action. Enter the keyword to be searched in the text and click on enter. The default behaviour is to show all the occurrences across all projects within the current account.

code-search-accross-projects

If we select a particular project, it shows the path under which the code belongs

code-search-path

Right clicking on the search string will bring up the following menu:

code-search-right-click

Selecting Command Palette provides options like the following:

command-palette

 

We can filter it for a particular project or even refine the search by Code Type like Class, Comment, Definitions etc. as seen below. Let us select String Literal to refine the search

code-search-refined

We can get various options to filter by clicking in the search text box

code-search-textbox-query

Clicking on annotate button will let us know the person who changed the code. The diagram also shows file extension added to the search.

code-search-annotate

You can also select the history tab to give more information as well as use Compare to compare between two changesets. Selecting a particular entry will take you to the actual changeset.

code-search-history

code-search-compare

The boolean operators like AND, OR and NOT can be used for advanced search. Even wildcards like * and ? can be used.

Limitations

Though Code Search provides a lot of features and Microsoft is constantly improving upon it, there are some limitations. It searches with the default branch (mostly mater). It searches only for files less than 10 MB. The filter works for C#, C and C++ code and support for other languages may be added in the near future.

Conclusion

Overall Code Search is a cool feature currently available only with Visual Studio Team Services a.k.a Visual Studio Online.

Was this article worth reading? Share it with fellow developers too. Thanks!
Share on LinkedIn
Share on Google+
Further Reading - Articles You May Like!
Author
Gouri Sohoni is a Trainer and Consultant for over two decades. She specializes in Visual Studio - Application Lifecycle Management (ALM) and Team Foundation Server (TFS). She is a Microsoft MVP in VS ALM, MCSD (VS ALM) and has conducted several corporate trainings and consulting assignments. She has also created various products that extend the capability of Team Foundation Server.


Page copy protected against web site content infringement 	by Copyscape




Feedback - Leave us some adulation, criticism and everything in between!