Locked Visual Studio 2010 Source Control Automation Question

  • Wednesday, August 31, 2011 3:38 PM
     
      Has Code

    Hello -

     In Visual Studio 2003  I had created a Visual Studio Add-In (using C#) which allowed me to hook into Visual Studio Events to know when a file was being checked in.   

      Within the the IDTExtensibility2 interfaces OnConnection method I created handlers for the EventDTE.CommandEvents objects AfterExecute and BeforeExecute events.  Within the AfterExecute and BeforeExecute handlers you can tell what type of event is firing.      In these handlers I could see what type of event was firing and do certain things.   In my case I wanted to know when a file was being checked into source control, and I was able to do some things, such as cancel the event, which can be done in the BeforeExecute handler.

      here is the signature for the BeforeExecute handler

       public void BeforeExecute(string Guid, int ID, object CustomIn, object CustomOut, ref bool CancelDefault)
    

      The ID parameter was a number that you could check to see what the was being done (you had to figure out the numbers, their use to be a VS Add-In that let you see these numbers).

     

      Anyway, my question is, does the Visual Studio 2010 Add In API give a person better access to Source Control events such as check in, check out?   

      My goal is NOT to write a Source Control Plugin or VSPPackage for source control - I just want to listen to Check In / Check Out events from Visual Studio regardless of the Source Control being used.

     Is this possible?

     Thanks!

     

All Replies

  • Thursday, September 01, 2011 6:37 AM
    Moderator
     
     

    Hi

     

    I think what you mentioned is to use DTE.CommentEvents, these are also available in VS2010. However, in VS2010, these methods are for Microsoft internal use only. We don’t recommend you use this way.

     

    As far as I know VS2010 doesn’t offer a general way to hook a command event. If it is used for your business, you may create your own “check in/out” command and implement all the checking logical inside.

     

    Work with a specific source control is more reasonable to me. Generally for VS2010, we use TFS as the major source control, since TFS SDK exports lots of APIs for automation, we can handle some events from TFS like VersionControlServer Class to get more detailed information about the event.

     

    Regards,

    Yi


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Thursday, September 01, 2011 2:29 PM
     
     

    Hi -

     Thanks for your response.   Unfortunately we are not using TFS yet for all our development projects.    For some of our projects we have to use  Source Safe.   

     My Add-In is actually a Source Safe and Visual Studio Add-In.  So my Add-In does hook into the Source Safe events, but i was just curious as to why Microsoft does not allow Add-Ins to hook into commands fired from the IDE before source control receives them.   Why doesn't the Visual Studio IDE offer us more source control events?  what is the reason for this?

     What I don't understand is that Microsoft offers http://msdn.microsoft.com/en-us/library/envdte.sourcecontrol.aspx.     Which lets you do a few things but not very much.     Why would it hurt to let the IDE fire Before check In, Before Check Out events which we could listen to from our Add-Ins?         The IDE communicates w/ Source Control in a similiar manner if you look at the Source Control Plug In API.

    I do appreciate your response, but it did not help for my situation. :-).

     Thanks 

  • Friday, September 02, 2011 1:53 AM
    Moderator
     
     

    Hi,

     

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.

     Yi


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Wednesday, September 28, 2011 8:23 AM
     
     Proposed Answer

    Hi,

    As far as I know, unfortunately there is no such way to listen to check in/out events. Couple of methods (http://msdn.microsoft.com/en-us/library/k9chd8tx.aspx) is available but hooking up events is not feasible.

     

    Thanks & Regards,

    Leon


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    • Proposed As Answer by YvonneS Wednesday, November 28, 2012 11:23 AM
    •