c# - Programmatically get TFS blame (annotation) data -


i'm trying implement plugin team foundation server 2010 create reports users in team project. conceptually, need in order implement plugin access same data when use "annotate" feature in visual studio: need able tell last person author given line of code.

i've scoured internet documentation or code samples, can find either suggestions such using tfs command-line tools or seemingly incomplete code samples.

i don't mind doing lot of heavy lifting in client code, there doesn't seem obvious way useful authorship data contents of code in changeset, nor merge details return.

meanwhile found working solution executes team foundation power tools process , parses output:

private readonly regex m_regex = new regex(@"^(?<changeset>\d+)(?<codeline>.*)", regexoptions.compiled | regexoptions.multiline);  public list<changeset> getannotations(string filepath, string codetext)     {         var versioncontrolserver = createversioncontrolserver();          return m_regex.matches(executepowertools(filepath))             .cast<match>()             .where(m => m.groups["codeline"].value.contains(codetext))             .select(v => versioncontrolserver.getchangeset(int.parse(v.groups["changeset"].value), false, false))             .tolist();     }      private static versioncontrolserver createversioncontrolserver()     {         var projectcollection = new tfsteamprojectcollection(new uri(@"tfs url"));         var versioncontrolserver = projectcollection.getservice<versioncontrolserver>();         return versioncontrolserver;     }      private static string executepowertools(string filepath)     {         using (var process = process.start(tfptlocation, string.format("annotate /noprompt {0}", filepath)))         {             process.waitforexit();             return process.standardoutput.readtoend();         }     } 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -