获取从TFS文件的变化来实现自定义&QUOT历史;怪"异常-behaviour [英] Get history of file changes from TFS to implement custom "blame"-behaviour of exceptions

查看:247
本文介绍了获取从TFS文件的变化来实现自定义&QUOT历史;怪"异常-behaviour的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让搞清楚向谁怪的时候抛出一个异常在我们的应用程序(的工作)的一些方法。这可能是我造成,当然,但我可以接受:)。但要做到这一点,我需要在TFS文件的历史记录,以便我可以检查谁最后做出了改变,在异常的线路。它当然不是总是在异常插入错误变化的行,所以我可能还需要检查任何更改相同的文件,最后所有签到取得了非常最近。我不知道我怎么会制定出这一点,但我想检查与社会第一,如果有这个任何现有的解决方案?我与TFS API没有经验,但让我没有办法告诉什么可能的,什么不是。我想我会融入到这一点我们在未处理的异常处理程序的应用程序。当除了一些考生发现,我需要通过电子邮件通知他们。在这个过程中它会是不错的记录了多少次了一定异常被抛出的任何用户对我们的内联网,谁,何时,如何等,这可以为我们节省了大量的时间和金钱。

I'm trying to make some way of figuring out who to "blame" when an exception is thrown in our application (at work). It could be me causing it of course but I can accept that :). But to do this I need the history of a file in TFS so I can check who last made a change at the line of the exception. Its of course not always at the row of the exception that the erroneous change was inserted, so I would probably also need to check any changes to the same file and lastly any check-ins made very recently. I'm not sure how I will work out this but I would like to check with the community first if there is any already existing solutions for this? I have no experience with the TFS API yet so I have no way of telling whats possible and whats not. I guess I would integrate this into our app in the unhandled exceptions-handler. When some candidates of the exception is found I need to inform them by email. In the process it would be nice to log how many times a certain exception has been thrown by any user on our intranet, who, when, how etc. It could save us a lot of time (and money).

推荐答案

我喜欢的精神! TFS的API是非常强大的,你可以去任意的深度为你感兴趣的信息。

I like the spirit! The TFS API is very powerful and you can go to any level of depth for the information you are interested in.

  • 您可以创建一个应用程序,可以让呼叫你的应用程序TFS API的应用程序,看看如何可以连接到TFS编程<一href="http://geekswithblogs.net/TarunArora/archive/2011/06/18/tfs-2010-sdk-connecting-to-tfs-2010-programmaticallyndashpart-1.aspx" rel="nofollow">http://geekswithblogs.net/TarunArora/archive/2011/06/18/tfs-2010-sdk-connecting-to-tfs-2010-programmaticallyndashpart-1.aspx.

TFS的API,可以让你查​​询TFS的对文件所做的所有更改(变更)。因此,可以说,ClassAbc.cs抛出一个例外,如果你有引发此例外您的TFS API的应用程序的事件总线,可以使用在versionControlService GetChangeset方法,该方法以获得在该文件执行的所有的变更。看看如何做到这一点这里<一href="http://geekswithblogs.net/TarunArora/archive/2011/06/26/tfs-2010-sdk-smart-merge-programmatically-create-your-own-merge.aspx" rel="nofollow">http://geekswithblogs.net/TarunArora/archive/2011/06/26/tfs-2010-sdk-smart-merge-programmatically-create-your-own-merge.aspx.

The TFS API allows you to Query TFS for all changes (Changesets) made to a file. So, lets say, ClassAbc.cs raises an exception, if you have an event bus that raises this exception to your TFS API application, you can use the method in the versionControlService GetChangeset method to get all changesets performed on that file. Check out how to do that here http://geekswithblogs.net/TarunArora/archive/2011/06/26/tfs-2010-sdk-smart-merge-programmatically-create-your-own-merge.aspx.

在这一点上,你可以做2变更集之间的增量,用这样的事情得到code的变化。

At this point you could do a delta between the 2 changesets and get the code changes using something like this.

public static void GetMergeDetailsForChangeSet()
{
    var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("Enter the url of team project"));
    var versionControl = tfs.GetService<VersionControlServer>();


    var a = versionControl.GetChangeset(12322);

    VersionSpec changeSpec = new ChangesetVersionSpec(a.Changes[0].Item.ChangesetId);

    var abc = a.Changes[0].Item.VersionControlServer.QueryMergesWithDetails(
        null,
        null,
        0,
        a.Changes[0].Item.ServerItem,
        changeSpec,
        a.Changes[0].Item.DeletionId,
        changeSpec,
        changeSpec,
        RecursionType.Full);

}

  • 现在,你将有实际的code,可以运行一组了StyleCop的 HTTP://www.$c$cproject.com/KB/cs/StyleCop.aspx 针对该code块,并在发现可能的异常或一般code规则分析结果可以记录在数据库中,并通过电子邮件发送给用户。

  • Now that you would have the actual code, you can run a set of StyleCop http://www.codeproject.com/KB/cs/StyleCop.aspx rules against that code block and on finding possible exceptions or general code analysis results could be recorded in a database and emailed to the user.

    听起来很有趣。但是,或者,您可以使用TFS的Annote功能查看该系列由开发上的文件和准code分析做你的CI构建认定中的变化并获得了做code的变化不断的反馈开发商在你的团队。

    Sounds interesting. But, alternatively, you could use the Annote feature in TFS to see the series of changes done by a developer on a file and associate code analysis to your CI build defination and get constant feedback on code changes done by the developers in your team.

    这篇关于获取从TFS文件的变化来实现自定义&QUOT历史;怪&QUOT;异常-behaviour的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆