forked from GitTools/GitLink
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GitTools#203 Added the option to index pdb files using srctool
Srctool is used to list the raw source file information from the pdb and files not found in git or with an invalid extension are ignored.
- Loading branch information
1 parent
5fd8912
commit 81c1bd2
Showing
3 changed files
with
96 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// <copyright file="SrcToolHelper.cs" company="CatenaLogic"> | ||
// Copyright (c) 2014 - 2016 CatenaLogic. All rights reserved. | ||
// </copyright> | ||
|
||
namespace GitLink | ||
{ | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using Catel; | ||
using Catel.Logging; | ||
using GitTools.Git; | ||
|
||
internal static class SrcToolHelper | ||
{ | ||
private static readonly ILog Log = LogManager.GetCurrentClassLogger(); | ||
|
||
internal static List<string> GetSourceFiles(string srcToolFilePath, string projectPdbFile) | ||
{ | ||
Argument.IsNotNullOrWhitespace(() => projectPdbFile); | ||
List<string> sources = new List<string>(); | ||
|
||
var processStartInfo = new ProcessStartInfo(srcToolFilePath) | ||
{ | ||
Arguments = string.Format("-r \"{0}\"", projectPdbFile), | ||
CreateNoWindow = true, | ||
UseShellExecute = false, | ||
RedirectStandardOutput = true, | ||
}; | ||
|
||
using (var process = new Process()) | ||
{ | ||
process.OutputDataReceived += (s, e) => | ||
{ | ||
if (e.Data != null) | ||
{ | ||
var sourceFile = e.Data.ToLower(); | ||
|
||
if (Linker.ValidExtension(sourceFile)) | ||
{ | ||
var repositoryDirectory = GitDirFinder.TreeWalkForGitDir(Path.GetDirectoryName(sourceFile)); | ||
|
||
if (repositoryDirectory != null) | ||
{ | ||
sources.Add(sourceFile); | ||
} | ||
} | ||
} | ||
}; | ||
|
||
process.EnableRaisingEvents = true; | ||
process.StartInfo = processStartInfo; | ||
process.Start(); | ||
process.BeginOutputReadLine(); | ||
process.WaitForExit(); | ||
|
||
var processExitCode = process.ExitCode; | ||
if (processExitCode != 0) | ||
{ | ||
throw Log.ErrorAndCreateException<GitLinkException>("SrcTool exited with unexpected error code '{0}'", processExitCode); | ||
} | ||
} | ||
|
||
return sources; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters