From ef03395b9f1ecf2be9b5cf3ea613f23bef9ece53 Mon Sep 17 00:00:00 2001 From: Julien Grossrieder Date: Fri, 22 Jul 2016 09:38:28 +0200 Subject: [PATCH] Adding solution First commit of the solution --- ConsoleRunner/App.config | 6 + ConsoleRunner/ConsoleRunner.csproj | 74 +++++++++ ConsoleRunner/Program.cs | 28 ++++ ConsoleRunner/Properties/AssemblyInfo.cs | 36 +++++ CyclicReferenceFinder.Model/Chain.cs | 23 +++ .../CyclicReferenceFinder.Model.csproj | 55 +++++++ CyclicReferenceFinder.Model/Project.cs | 51 +++++++ .../Properties/AssemblyInfo.cs | 36 +++++ .../CyclicReferenceFinder.Parser.csproj | 60 ++++++++ CyclicReferenceFinder.Parser/Parser.cs | 89 +++++++++++ .../Properties/AssemblyInfo.cs | 36 +++++ .../CyclicFinder.cs | 57 +++++++ ...cReferenceFinder.ReferencesAnalyzer.csproj | 60 ++++++++ .../Properties/AssemblyInfo.cs | 36 +++++ CyclicReferenceFinder.sln | 52 +++++++ GuiRunner/App.config | 6 + GuiRunner/App.xaml | 9 ++ GuiRunner/App.xaml.cs | 17 +++ GuiRunner/GuiRunner.csproj | 142 +++++++++++++++++ GuiRunner/MainWindow.xaml | 36 +++++ GuiRunner/MainWindow.xaml.cs | 28 ++++ GuiRunner/MainWindowViewModel.cs | 144 ++++++++++++++++++ GuiRunner/Properties/AssemblyInfo.cs | 55 +++++++ GuiRunner/Properties/Resources.Designer.cs | 71 +++++++++ GuiRunner/Properties/Resources.resx | 117 ++++++++++++++ GuiRunner/Properties/Settings.Designer.cs | 30 ++++ GuiRunner/Properties/Settings.settings | 7 + GuiRunner/packages.config | 5 + README.md | 5 + 29 files changed, 1371 insertions(+) create mode 100644 ConsoleRunner/App.config create mode 100644 ConsoleRunner/ConsoleRunner.csproj create mode 100644 ConsoleRunner/Program.cs create mode 100644 ConsoleRunner/Properties/AssemblyInfo.cs create mode 100644 CyclicReferenceFinder.Model/Chain.cs create mode 100644 CyclicReferenceFinder.Model/CyclicReferenceFinder.Model.csproj create mode 100644 CyclicReferenceFinder.Model/Project.cs create mode 100644 CyclicReferenceFinder.Model/Properties/AssemblyInfo.cs create mode 100644 CyclicReferenceFinder.Parser/CyclicReferenceFinder.Parser.csproj create mode 100644 CyclicReferenceFinder.Parser/Parser.cs create mode 100644 CyclicReferenceFinder.Parser/Properties/AssemblyInfo.cs create mode 100644 CyclicReferenceFinder.ReferencesAnalyzer/CyclicFinder.cs create mode 100644 CyclicReferenceFinder.ReferencesAnalyzer/CyclicReferenceFinder.ReferencesAnalyzer.csproj create mode 100644 CyclicReferenceFinder.ReferencesAnalyzer/Properties/AssemblyInfo.cs create mode 100644 CyclicReferenceFinder.sln create mode 100644 GuiRunner/App.config create mode 100644 GuiRunner/App.xaml create mode 100644 GuiRunner/App.xaml.cs create mode 100644 GuiRunner/GuiRunner.csproj create mode 100644 GuiRunner/MainWindow.xaml create mode 100644 GuiRunner/MainWindow.xaml.cs create mode 100644 GuiRunner/MainWindowViewModel.cs create mode 100644 GuiRunner/Properties/AssemblyInfo.cs create mode 100644 GuiRunner/Properties/Resources.Designer.cs create mode 100644 GuiRunner/Properties/Resources.resx create mode 100644 GuiRunner/Properties/Settings.Designer.cs create mode 100644 GuiRunner/Properties/Settings.settings create mode 100644 GuiRunner/packages.config diff --git a/ConsoleRunner/App.config b/ConsoleRunner/App.config new file mode 100644 index 0000000..8324aa6 --- /dev/null +++ b/ConsoleRunner/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ConsoleRunner/ConsoleRunner.csproj b/ConsoleRunner/ConsoleRunner.csproj new file mode 100644 index 0000000..0279f68 --- /dev/null +++ b/ConsoleRunner/ConsoleRunner.csproj @@ -0,0 +1,74 @@ + + + + + Debug + AnyCPU + {8A561FC1-4BB8-4824-943A-C0A1DAF4AC39} + Exe + Properties + ConsoleRunner + ConsoleRunner + v4.6 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + {45BCACD4-4A5D-4E90-ADB5-A573F0A53661} + CyclicReferenceFinder.Model + + + {A3404987-04EB-4996-81B1-BCB9D0CD73BB} + CyclicReferenceFinder.Parser + + + {7698D958-E481-4F6E-B348-B78107BD8005} + CyclicReferenceFinder.ReferencesAnalyzer + + + + + \ No newline at end of file diff --git a/ConsoleRunner/Program.cs b/ConsoleRunner/Program.cs new file mode 100644 index 0000000..e857267 --- /dev/null +++ b/ConsoleRunner/Program.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CyclicReferenceFinder.Model; +using CyclicReferenceFinder.Parser; +using CyclicReferenceFinder.ReferencesAnalyzer; + +namespace ConsoleRunner +{ + class Program + { + static void Main(string[] args) + { + IEnumerable projects = Parser.Instance.Parse(@"D:\Dev\WS_1\Branches\ReworkedServer\Solution\XMS_VS2010.sln"); + Console.WriteLine($"Parsed {projects.Count()} projects"); + Project sourceProject = projects.First(p => p.Name.Equals("Xms.DataManagement")); + Project projectToReference = projects.First(p => p.Name.Equals("XmsClientCore")); + IList chains = CyclicFinder.Instance.FindCylicChains(sourceProject, projectToReference).Result; + + foreach (Chain chain in chains){ + Console.WriteLine(chain); + } + Console.ReadLine(); + } + } +} diff --git a/ConsoleRunner/Properties/AssemblyInfo.cs b/ConsoleRunner/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b455251 --- /dev/null +++ b/ConsoleRunner/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ConsoleRunner")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("MSS - CH")] +[assembly: AssemblyProduct("ConsoleRunner")] +[assembly: AssemblyCopyright("Copyright © MSS - CH 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("8a561fc1-4bb8-4824-943a-c0a1daf4ac39")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/CyclicReferenceFinder.Model/Chain.cs b/CyclicReferenceFinder.Model/Chain.cs new file mode 100644 index 0000000..6d69bfb --- /dev/null +++ b/CyclicReferenceFinder.Model/Chain.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CyclicReferenceFinder.Model +{ + public class Chain + { + public IList Projects { get; }= new List(); + + public void InsertProject(Project project) + { + Projects.Insert(0,project); + } + + public override string ToString() + { + return String.Join(" -> ", Projects); + } + } +} diff --git a/CyclicReferenceFinder.Model/CyclicReferenceFinder.Model.csproj b/CyclicReferenceFinder.Model/CyclicReferenceFinder.Model.csproj new file mode 100644 index 0000000..3de05c1 --- /dev/null +++ b/CyclicReferenceFinder.Model/CyclicReferenceFinder.Model.csproj @@ -0,0 +1,55 @@ + + + + + Debug + AnyCPU + {45BCACD4-4A5D-4E90-ADB5-A573F0A53661} + Library + Properties + CyclicReferenceFinder.Model + CyclicReferenceFinder.Model + v4.6 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CyclicReferenceFinder.Model/Project.cs b/CyclicReferenceFinder.Model/Project.cs new file mode 100644 index 0000000..c4c6ac8 --- /dev/null +++ b/CyclicReferenceFinder.Model/Project.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CyclicReferenceFinder.Model +{ + public class Project:IEquatable + { + public String Name { get; } + public String ProjectPath { get; } + public Guid ProjectId { get; } + + public IList References { get; } + + public Project(String name, string projectPath, Guid projectId) + { + Name = name; + ProjectPath = projectPath; + ProjectId = projectId; + References = new List(); + } + + public bool Equals(Project other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return ProjectId.Equals(other.ProjectId); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + Project other = obj as Project; + return other != null && Equals(other); + } + + public override int GetHashCode() + { + return ProjectId.GetHashCode(); + } + + public override string ToString() + { + return Name; + } + + } +} diff --git a/CyclicReferenceFinder.Model/Properties/AssemblyInfo.cs b/CyclicReferenceFinder.Model/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..1172080 --- /dev/null +++ b/CyclicReferenceFinder.Model/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("CyclicReferenceFinder.Model")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("MSS - CH")] +[assembly: AssemblyProduct("CyclicReferenceFinder.Model")] +[assembly: AssemblyCopyright("Copyright © MSS - CH 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("45bcacd4-4a5d-4e90-adb5-a573f0a53661")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/CyclicReferenceFinder.Parser/CyclicReferenceFinder.Parser.csproj b/CyclicReferenceFinder.Parser/CyclicReferenceFinder.Parser.csproj new file mode 100644 index 0000000..3e98877 --- /dev/null +++ b/CyclicReferenceFinder.Parser/CyclicReferenceFinder.Parser.csproj @@ -0,0 +1,60 @@ + + + + + Debug + AnyCPU + {A3404987-04EB-4996-81B1-BCB9D0CD73BB} + Library + Properties + CyclicReferenceFinder.Parser + CyclicReferenceFinder.Parser + v4.6 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + {45BCACD4-4A5D-4E90-ADB5-A573F0A53661} + CyclicReferenceFinder.Model + + + + + \ No newline at end of file diff --git a/CyclicReferenceFinder.Parser/Parser.cs b/CyclicReferenceFinder.Parser/Parser.cs new file mode 100644 index 0000000..e96d371 --- /dev/null +++ b/CyclicReferenceFinder.Parser/Parser.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using System.Xml.Linq; +using System.Xml.Serialization; +using CyclicReferenceFinder.Model; + +namespace CyclicReferenceFinder.Parser +{ + public class Parser + { + + public static Parser Instance { get; } = new Parser(); + + private Parser() { } + + + public IEnumerable Parse(string slnPath) + { + List projects = LoadProjectsFromSln(slnPath); + + LoadReferences(projects); + return projects; + } + + private void LoadReferences(List projects) + { + XNamespace ns = "http://schemas.microsoft.com/developer/msbuild/2003"; + foreach (Project project in projects) + { + XDocument xDocument = XDocument.Load(project.ProjectPath); + IEnumerable projectReferences = xDocument.Descendants(ns + "ProjectReference"); + foreach (XElement projectNode in projectReferences.Descendants(ns + "Project")) + { + string idString = projectNode.Value; + Guid id; + if (Guid.TryParse(idString, out id)) + { + Project referencedProject = projects.FirstOrDefault(p => p.ProjectId == id); + if (referencedProject != null) + { + project.References.Add(referencedProject); + } + } + } + } + } + + private List LoadProjectsFromSln(string slnPath) + { + string slnDirectory = Path.GetDirectoryName(slnPath); + if (slnDirectory == null) + { + throw new ArgumentException("Unable to parse SLN", nameof(slnPath)); + } + List projects = new List(); + Regex regex = new Regex(@"Project\(""{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}""\) = ""([^""]+)"", ""([^""]+)"", ""{([^}]+)}"""); + using (StreamReader streamReader = new StreamReader(slnPath)) + { + string line; + while ((line = streamReader.ReadLine()) != null) + { + Match match = regex.Match(line); + if (match.Success) + { + string name = match.Groups[1].Value; + string path = match.Groups[2].Value; + string stringId = match.Groups[3].Value; + path = Path.Combine(slnDirectory, path); + Guid id; + if (Guid.TryParse(stringId, out id)) + { + projects.Add(new Project(name, path, id)); + } + else + { + Console.WriteLine($"Unable to parse {stringId} as a valid Guid"); + } + } + } + } + return projects; + } + } +} diff --git a/CyclicReferenceFinder.Parser/Properties/AssemblyInfo.cs b/CyclicReferenceFinder.Parser/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..9002456 --- /dev/null +++ b/CyclicReferenceFinder.Parser/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("CyclicReferenceFinder.Parser")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("MSS - CH")] +[assembly: AssemblyProduct("CyclicReferenceFinder.Parser")] +[assembly: AssemblyCopyright("Copyright © MSS - CH 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a3404987-04eb-4996-81b1-bcb9d0cd73bb")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/CyclicReferenceFinder.ReferencesAnalyzer/CyclicFinder.cs b/CyclicReferenceFinder.ReferencesAnalyzer/CyclicFinder.cs new file mode 100644 index 0000000..e238700 --- /dev/null +++ b/CyclicReferenceFinder.ReferencesAnalyzer/CyclicFinder.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CyclicReferenceFinder.Model; + +namespace CyclicReferenceFinder.ReferencesAnalyzer +{ + public class CyclicFinder + { + public static CyclicFinder Instance { get; } = new CyclicFinder(); + + /// + /// This search the projects references that prevent referencing "referencedProject" from "sourceProject" + /// + /// The source project. + /// The referenced project. + /// + public async Task> FindCylicChains( Project sourceProject,Project referencedProject) + { + return await FindChains(sourceProject, referencedProject); + } + + /// + /// Finds the chains. + /// + /// The project to find. + /// The current project. + /// + private async Task> FindChains(Project projectToFind, Project currentProject) + { + List projectsChains = new List(); + //We are trying to find a reference from referencedProject --> sourceProject which would prevent to add the opposite reference + foreach (Project reference in currentProject.References ) + { + if (reference.Equals(projectToFind)) + { + Chain chain = new Chain(); + chain.InsertProject(reference); + projectsChains.Add(chain); + } + else + { + projectsChains.AddRange( await FindChains(projectToFind, reference)); + } + } + + foreach (Chain projectsChain in projectsChains) + { + projectsChain.InsertProject(currentProject); + } + + return projectsChains; + } + } +} diff --git a/CyclicReferenceFinder.ReferencesAnalyzer/CyclicReferenceFinder.ReferencesAnalyzer.csproj b/CyclicReferenceFinder.ReferencesAnalyzer/CyclicReferenceFinder.ReferencesAnalyzer.csproj new file mode 100644 index 0000000..186bc2c --- /dev/null +++ b/CyclicReferenceFinder.ReferencesAnalyzer/CyclicReferenceFinder.ReferencesAnalyzer.csproj @@ -0,0 +1,60 @@ + + + + + Debug + AnyCPU + {7698D958-E481-4F6E-B348-B78107BD8005} + Library + Properties + CyclicReferenceFinder.ReferencesAnalyzer + CyclicReferenceFinder.ReferencesAnalyzer + v4.6 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + {45BCACD4-4A5D-4E90-ADB5-A573F0A53661} + CyclicReferenceFinder.Model + + + + + \ No newline at end of file diff --git a/CyclicReferenceFinder.ReferencesAnalyzer/Properties/AssemblyInfo.cs b/CyclicReferenceFinder.ReferencesAnalyzer/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e244a5b --- /dev/null +++ b/CyclicReferenceFinder.ReferencesAnalyzer/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("CyclicReferenceFinder.ReferencesAnalyzer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("MSS - CH")] +[assembly: AssemblyProduct("CyclicReferenceFinder.ReferencesAnalyzer")] +[assembly: AssemblyCopyright("Copyright © MSS - CH 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("7698d958-e481-4f6e-b348-b78107bd8005")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/CyclicReferenceFinder.sln b/CyclicReferenceFinder.sln new file mode 100644 index 0000000..732e38c --- /dev/null +++ b/CyclicReferenceFinder.sln @@ -0,0 +1,52 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CyclicReferenceFinder.Model", "CyclicReferenceFinder.Model\CyclicReferenceFinder.Model.csproj", "{45BCACD4-4A5D-4E90-ADB5-A573F0A53661}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CyclicReferenceFinder.Parser", "CyclicReferenceFinder.Parser\CyclicReferenceFinder.Parser.csproj", "{A3404987-04EB-4996-81B1-BCB9D0CD73BB}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Runners", "Runners", "{E96A42F2-E376-4C45-A5DA-B17869426526}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleRunner", "ConsoleRunner\ConsoleRunner.csproj", "{8A561FC1-4BB8-4824-943A-C0A1DAF4AC39}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CyclicReferenceFinder.ReferencesAnalyzer", "CyclicReferenceFinder.ReferencesAnalyzer\CyclicReferenceFinder.ReferencesAnalyzer.csproj", "{7698D958-E481-4F6E-B348-B78107BD8005}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GuiRunner", "GuiRunner\GuiRunner.csproj", "{F2B11CF5-FD73-420E-B796-9342743F0BD5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {45BCACD4-4A5D-4E90-ADB5-A573F0A53661}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {45BCACD4-4A5D-4E90-ADB5-A573F0A53661}.Debug|Any CPU.Build.0 = Debug|Any CPU + {45BCACD4-4A5D-4E90-ADB5-A573F0A53661}.Release|Any CPU.ActiveCfg = Release|Any CPU + {45BCACD4-4A5D-4E90-ADB5-A573F0A53661}.Release|Any CPU.Build.0 = Release|Any CPU + {A3404987-04EB-4996-81B1-BCB9D0CD73BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A3404987-04EB-4996-81B1-BCB9D0CD73BB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A3404987-04EB-4996-81B1-BCB9D0CD73BB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A3404987-04EB-4996-81B1-BCB9D0CD73BB}.Release|Any CPU.Build.0 = Release|Any CPU + {8A561FC1-4BB8-4824-943A-C0A1DAF4AC39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8A561FC1-4BB8-4824-943A-C0A1DAF4AC39}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8A561FC1-4BB8-4824-943A-C0A1DAF4AC39}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8A561FC1-4BB8-4824-943A-C0A1DAF4AC39}.Release|Any CPU.Build.0 = Release|Any CPU + {7698D958-E481-4F6E-B348-B78107BD8005}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7698D958-E481-4F6E-B348-B78107BD8005}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7698D958-E481-4F6E-B348-B78107BD8005}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7698D958-E481-4F6E-B348-B78107BD8005}.Release|Any CPU.Build.0 = Release|Any CPU + {F2B11CF5-FD73-420E-B796-9342743F0BD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F2B11CF5-FD73-420E-B796-9342743F0BD5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F2B11CF5-FD73-420E-B796-9342743F0BD5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F2B11CF5-FD73-420E-B796-9342743F0BD5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {8A561FC1-4BB8-4824-943A-C0A1DAF4AC39} = {E96A42F2-E376-4C45-A5DA-B17869426526} + {F2B11CF5-FD73-420E-B796-9342743F0BD5} = {E96A42F2-E376-4C45-A5DA-B17869426526} + EndGlobalSection +EndGlobal diff --git a/GuiRunner/App.config b/GuiRunner/App.config new file mode 100644 index 0000000..8324aa6 --- /dev/null +++ b/GuiRunner/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/GuiRunner/App.xaml b/GuiRunner/App.xaml new file mode 100644 index 0000000..9e6b3af --- /dev/null +++ b/GuiRunner/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/GuiRunner/App.xaml.cs b/GuiRunner/App.xaml.cs new file mode 100644 index 0000000..54a8179 --- /dev/null +++ b/GuiRunner/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace GuiRunner +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/GuiRunner/GuiRunner.csproj b/GuiRunner/GuiRunner.csproj new file mode 100644 index 0000000..d0e5a7b --- /dev/null +++ b/GuiRunner/GuiRunner.csproj @@ -0,0 +1,142 @@ + + + + + Debug + AnyCPU + {F2B11CF5-FD73-420E-B796-9342743F0BD5} + WinExe + Properties + GuiRunner + GuiRunner + v4.6 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.dll + True + + + ..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Extras.dll + True + + + ..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Platform.dll + True + + + ..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll + True + + + + + ..\packages\MvvmLightLibs.5.3.0.0\lib\net45\System.Windows.Interactivity.dll + True + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + {45BCACD4-4A5D-4E90-ADB5-A573F0A53661} + CyclicReferenceFinder.Model + + + {a3404987-04eb-4996-81b1-bcb9d0cd73bb} + CyclicReferenceFinder.Parser + + + {7698d958-e481-4f6e-b348-b78107bd8005} + CyclicReferenceFinder.ReferencesAnalyzer + + + + + \ No newline at end of file diff --git a/GuiRunner/MainWindow.xaml b/GuiRunner/MainWindow.xaml new file mode 100644 index 0000000..27f137e --- /dev/null +++ b/GuiRunner/MainWindow.xaml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GuiRunner/MainWindow.xaml.cs b/GuiRunner/MainWindow.xaml.cs new file mode 100644 index 0000000..ea3faef --- /dev/null +++ b/GuiRunner/MainWindow.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace GuiRunner +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + } + } +} diff --git a/GuiRunner/MainWindowViewModel.cs b/GuiRunner/MainWindowViewModel.cs new file mode 100644 index 0000000..851d3f6 --- /dev/null +++ b/GuiRunner/MainWindowViewModel.cs @@ -0,0 +1,144 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using CyclicReferenceFinder.Model; +using CyclicReferenceFinder.Parser; +using CyclicReferenceFinder.ReferencesAnalyzer; +using GalaSoft.MvvmLight; +using GalaSoft.MvvmLight.Command; +using Microsoft.Win32; + +namespace GuiRunner +{ + public class MainWindowViewModel:ViewModelBase + { + private string _solutionFile; + private bool _isBusy; + private ObservableCollection _projects; + private bool _isSolutionLoaded; + private Project _sourceProject; + private Project _referencedProject; + private bool? _cyclicReferenceFound; + private ObservableCollection _chains; + + + public String SolutionFile + { + get { return _solutionFile; } + set + { + _solutionFile = value; + RaisePropertyChanged(); + } + } + + public Project SourceProject + { + get { return _sourceProject; } + set + { + _sourceProject = value; + RaisePropertyChanged(); + FindCyclicReferenceCommand.RaiseCanExecuteChanged(); + } + } + + public Project ReferencedProject + { + get { return _referencedProject; } + set + { + _referencedProject = value; + RaisePropertyChanged(); + FindCyclicReferenceCommand.RaiseCanExecuteChanged(); + } + } + + public ObservableCollection Chains + { + get { return _chains; } + set { _chains = value; RaisePropertyChanged();} + } + + public bool? CyclicReferenceFound + { + get { return _cyclicReferenceFound; } + set + { + _cyclicReferenceFound = value; + RaisePropertyChanged(); + } + } + + public bool IsBusy + { + get { return _isBusy; } + set + { + _isBusy = value; + RaisePropertyChanged(); + FindCyclicReferenceCommand.RaiseCanExecuteChanged(); + SelectSolutionCommand.RaiseCanExecuteChanged(); + + } + } + + public bool IsSolutionLoaded + { + get { return _isSolutionLoaded; } + set { _isSolutionLoaded = value;RaisePropertyChanged(); + FindCyclicReferenceCommand.RaiseCanExecuteChanged(); + } + } + + public RelayCommand SelectSolutionCommand { get; } + public RelayCommand FindCyclicReferenceCommand { get; } + + public ObservableCollection Projects + { + get { return _projects; } + set + { + _projects = value; + RaisePropertyChanged(); + } + } + + public MainWindowViewModel() + { + CyclicReferenceFound = true; + SelectSolutionCommand = new RelayCommand(HandleSelectSolutionCommand, () => !IsBusy); + FindCyclicReferenceCommand = new RelayCommand(HandleCyclicReferenceCommand, ()=>!IsBusy && IsSolutionLoaded &&SourceProject!=null && ReferencedProject!=null); + } + + private async void HandleCyclicReferenceCommand() + { + IsBusy = true; + Chains = new ObservableCollection(await CyclicFinder.Instance.FindCylicChains(SourceProject, ReferencedProject)); + CyclicReferenceFound = Chains.Any(); + IsBusy = false; + } + + private void HandleSelectSolutionCommand() + { + OpenFileDialog openFileDialog = new OpenFileDialog() + { + CheckFileExists = true, + Filter = "Visual studio solution file(*.sln)|*.sln", + FileName = SolutionFile + }; + + if (openFileDialog.ShowDialog(Application.Current.MainWindow)==true) + { + Projects= new ObservableCollection(Parser.Instance.Parse(openFileDialog.FileName).OrderBy(p=>p.Name)); + SolutionFile = openFileDialog.FileName; + } + IsSolutionLoaded = true; + } + } +} diff --git a/GuiRunner/Properties/AssemblyInfo.cs b/GuiRunner/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..1bfd53b --- /dev/null +++ b/GuiRunner/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("GuiRunner")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("MSS - CH")] +[assembly: AssemblyProduct("GuiRunner")] +[assembly: AssemblyCopyright("Copyright © MSS - CH 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GuiRunner/Properties/Resources.Designer.cs b/GuiRunner/Properties/Resources.Designer.cs new file mode 100644 index 0000000..15ab516 --- /dev/null +++ b/GuiRunner/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace GuiRunner.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("GuiRunner.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/GuiRunner/Properties/Resources.resx b/GuiRunner/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/GuiRunner/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/GuiRunner/Properties/Settings.Designer.cs b/GuiRunner/Properties/Settings.Designer.cs new file mode 100644 index 0000000..f4dabe1 --- /dev/null +++ b/GuiRunner/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace GuiRunner.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/GuiRunner/Properties/Settings.settings b/GuiRunner/Properties/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/GuiRunner/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/GuiRunner/packages.config b/GuiRunner/packages.config new file mode 100644 index 0000000..c071434 --- /dev/null +++ b/GuiRunner/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/README.md b/README.md index b1d78ad..22a6e99 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,7 @@ # CyclicReferenceFinder This is a small tool designed to help user to find the "project reference chain" that prevent the user to add a new project in VisualStudio. + +I've made a simple GUI to easily select your own Visual Studio Solution file(*.sln), it will then allow you to select the project in which you are trying to add a reference, and the project which you're trying to reference. + +This tool have been made because I was unable to find the reason I could not add a project reference(due to cyclic dependency). +I don't expect to be very robust for now, but if you have issue, don't hesitate to raise an issue.