Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
133 lines (109 loc) · 5.01 KB
/
Copy pathProgram.cs
File metadata and controls
133 lines (109 loc) · 5.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CodeCounter;
using System.IO;
using DevProjects;
using DataHelpers;
using BusinessObjects;
namespace TestCodeCounter
{
class Program
{
static void Main(string[] args)
{
// test DevProjects
var mp = new MaintainProject();
//mp.UpdateSLNPathInDevProjects();
mp.PopulateSyncTableFromDevProjects();
var path = @"C:\VS2019 Projects\DevTracker\.git\config";
DHMisc hlpr = new DHMisc();
List<NotableFileExtension> notableFileExtensions = hlpr.GetNotableFileExtensions();
// Tuple<string, string, string> tuple = mp.GetProjectFromGitConfigSaved(path, notableFileExtensions);
path = @"C:\VS2019 Projects\DevTracker\Classes\FileWatcher.cs";
//Tuple<string, string, string> tuple = mp.GetProjectFromDevFileActivity(path, notableFileExtensions, "cs");
var url = mp.GetGitURLFromConfigFile(@"C:\GitRepo\hell-world\.git\config");
url = mp.GetGitURLFromPath(@"C:\GitRepo\hell-world\helloworld.csproj");
Console.WriteLine(url);
// test fileanalyzer
//var cc = new CodeCounter.FileLineCounter();
//var ret = cc.Process(@"C:\VS2019 Projects\DevTracker\Forms\MiscContainer.cs");
string projectPath = string.Empty;
string devProjectName = GetProjectPath(@"C:\DevTrkr DLLs\MaintainDevProject\Properties\AssemblyInfo.cs", out projectPath, "csproj");
Console.WriteLine("Project: " + devProjectName + "Path: " + projectPath);
Console.ReadLine();
}
private static string GetProjectPath(string fileFullPath, out string projectName, string projFileExt)
{
if (string.IsNullOrWhiteSpace(Path.GetFileName(fileFullPath)))
{
projectName = string.Empty;
return string.Empty;
}
var fullPath = fileFullPath;
var dirName = string.Empty;
while (!string.IsNullOrWhiteSpace(fullPath))
{
fullPath = Path.GetDirectoryName(fullPath);
if (string.IsNullOrWhiteSpace(fullPath))
{
projectName = string.Empty;
return string.Empty;
}
dirName = new DirectoryInfo(fullPath).Name;
// Vb and c# newly created projects will have the following folders
// that have to be bypassed, they are not interesting
if ("bin_obj_properties_my project_debug_release_temppe_".Contains(dirName.ToLower()))
continue;
object prj = /*Globals.ProjectList.Find(x => x.DevProjectName.ToLower() == dirName.ToLower())*/ null;
// we think we have a project path
if (prj != null)
{
projectName = dirName;
// we think we have a project path, chek for a xxproj file in the path
// projFileExt can have multiple delimited extensions
// mainly b/c c++ proj extension changed in later version
string[] extensions = projFileExt.Split('|');
for (int i = 0; i < extensions.Length; i++)
{
var projFile = projectName + "." + extensions[i];
if (File.Exists(Path.Combine(fullPath, projFile)))
{
projectName = dirName;
return fullPath;
}
}
continue;
}
}
projectName = string.Empty;
return string.Empty; // did not find a project file in the supposed project directory
}
//public string GetProjectPath(string fileName, bool isIDE)
//{
// const string slash = @"\";
// var idxLast = fileName.LastIndexOf(slash);
// var fullPath = fileName;
// // strip the filename and last slash if extant
// if (fullPath.Length > idxLast + 1)
// fullPath = fullPath.Substring(0, idxLast);
// // now we have the fullPath like
// //C:\VS2019 Projects\DataLayerUtility\DataLayerUtility\Forms
// // since this is an ide, strip all paths from the end != ProjectPath
// var name = string.Empty;
// while (true)
// {
// idxLast = fullPath.LastIndexOf(slash);
// if (idxLast < 0)
// break;
// name = fullPath.Substring(idxLast + 1);
// if (name.ToLower() == ProjectName.ToLower())
// return fullPath;
// fullPath = fullPath.Substring(0, idxLast);
// }
// return fullPath;
//}
}
}