Пример #1
0
        public CSharpSolution(string fileName)
        {
            _orphanProject = new OrphanProject(this);
            Projects = new Dictionary<string, IProject>();
            Directory = Path.GetDirectoryName(fileName);
            var projectLinePattern = new Regex("Project\\(\"(?<TypeGuid>.*)\"\\)\\s+=\\s+\"(?<Title>.*)\",\\s*\"(?<Location>.*)\",\\s*\"(?<Guid>.*)\"");

            foreach (string line in File.ReadLines(fileName))
            {
                Match match = projectLinePattern.Match(line);
                if (match.Success)
                {
                    string typeGuid = match.Groups["TypeGuid"].Value;
                    string title = match.Groups["Title"].Value;
                    string location = Path.Combine(Directory, match.Groups["Location"].Value).FixPath();
                    string guid = match.Groups["Guid"].Value;
                    switch (typeGuid.ToUpperInvariant())
                    {
                        case "{2150E333-8FDC-42A3-9474-1A3956D46DE8}": // Solution Folder
                            // ignore folders
                            break;
                        case "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}": // C# project
                            Console.WriteLine("Loading project - " + title);
                            Projects.Add(title, new CSharpProject(this, title, location));
                            break;
                        default:
                            Console.WriteLine("Project {0} has unsupported type {1}", location, typeGuid);
                            break;
                    }
                }
            }
        }
Пример #2
0
        public void LoadSolution()
        {
            Loaded         = false;
            _orphanProject = new OrphanProject(_fileSystem, _logger);
            Projects       = new List <IProject>();
            Projects.Add(_orphanProject);

            var directory          = Path.GetDirectoryName(FileName);
            var projectLinePattern =
                new Regex(
                    "Project\\(\"(?<TypeGuid>.*)\"\\)\\s+=\\s+\"(?<Title>.*)\",\\s*\"(?<Location>.*)\",\\s*\"(?<Guid>.*)\"");

            foreach (string line in File.ReadLines(FileName))
            {
                Match match = projectLinePattern.Match(line);
                if (match.Success)
                {
                    string typeGuid = match.Groups["TypeGuid"].Value;
                    string title    = match.Groups["Title"].Value;
                    string location = Path.Combine(directory, match.Groups["Location"].Value);
                    string guid     = match.Groups["Guid"].Value;

                    switch (typeGuid.ToUpperInvariant())
                    {
                    case "{2150E333-8FDC-42A3-9474-1A3956D46DE8}":     // Solution Folder
                        // ignore folders
                        break;

                    case "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}":     // C# project
                        LoadProject(title, location, guid);
                        break;

                    case "{9A19103F-16F7-4668-BE54-9A1E7A4F7556}":     // C# project
                        LoadProject(title, location, guid);
                        break;

                    default:
                        // Unity3D makes type GUID from the MD5 of title.
                        if (MD5(title) == typeGuid.Substring(1, typeGuid.Length - 2).ToLower().Replace("-", ""))
                        {
                            LoadProject(title, location, guid);
                        }
                        else
                        {
                            _logger.Debug("Project {0} has unsupported type {1}", location, typeGuid);
                        }
                        break;
                    }
                }
            }
            Loaded = true;
        }
Пример #3
0
        public void LoadSolution(string fileName)
        {
            Loaded = false;
            FileName = fileName;
            _orphanProject = new OrphanProject();
            Projects = new List<IProject>();
            Projects.Add(_orphanProject);

            var directory = Path.GetDirectoryName(fileName);
            var projectLinePattern =
                new Regex(
                    "Project\\(\"(?<TypeGuid>.*)\"\\)\\s+=\\s+\"(?<Title>.*)\",\\s*\"(?<Location>.*)\",\\s*\"(?<Guid>.*)\"");

            foreach (string line in File.ReadLines(fileName))
            {
                Match match = projectLinePattern.Match(line);
                if (match.Success)
                {
                    string typeGuid = match.Groups["TypeGuid"].Value;
                    string title = match.Groups["Title"].Value;
                    string location = Path.Combine(directory, match.Groups["Location"].Value).LowerCaseDriveLetter();
                    string guid = match.Groups["Guid"].Value;

                    switch (typeGuid.ToUpperInvariant())
                    {
                        case "{2150E333-8FDC-42A3-9474-1A3956D46DE8}": // Solution Folder
                                // ignore folders
                            break;
                        case "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}": // C# project
                            LoadProject(title, location, guid);
                            break;
                        default:
                                // Unity3D makes type GUID from the MD5 of title.
                            if (MD5(title) == typeGuid.Substring(1, typeGuid.Length - 2).ToLower().Replace("-", ""))
                            {
                                LoadProject(title, location, guid);
                            }
                            else
                            {
                                _logger.Debug("Project {0} has unsupported type {1}", location, typeGuid);
                            }
                            break;
                    }
                }
            }
            Loaded = true;
        }
Пример #4
0
        private void LoadSolution(string fileName)
        {
            FileName       = fileName;
            _orphanProject = new OrphanProject();
            Projects       = new List <IProject>();
            Directory      = Path.GetDirectoryName(fileName);
            var projectLinePattern =
                new Regex(
                    "Project\\(\"(?<TypeGuid>.*)\"\\)\\s+=\\s+\"(?<Title>.*)\",\\s*\"(?<Location>.*)\",\\s*\"(?<Guid>.*)\"");

            foreach (string line in File.ReadLines(fileName))
            {
                Match match = projectLinePattern.Match(line);
                if (match.Success)
                {
                    string typeGuid = match.Groups["TypeGuid"].Value;
                    string title    = match.Groups["Title"].Value;
                    string location = Path.Combine(Directory, match.Groups["Location"].Value).FixPath();
                    string guid     = match.Groups["Guid"].Value;
                    switch (typeGuid.ToUpperInvariant())
                    {
                    case "{2150E333-8FDC-42A3-9474-1A3956D46DE8}":     // Solution Folder
                        // ignore folders
                        break;

                    case "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}":     // C# project
                        LoadProject(title, location, guid);
                        break;

                    default:
                        // Unity3D makes type GUID from the MD5 of title.
                        if (MD5(title) == typeGuid.Substring(1, typeGuid.Length - 2).ToLower().Replace("-", ""))
                        {
                            LoadProject(title, location, guid);
                        }
                        else
                        {
                            Console.WriteLine("Project {0} has unsupported type {1}", location, typeGuid);
                        }
                        break;
                    }
                }
            }
        }
Пример #5
0
        public void ShouldThrowProjectNotFoundExceptionForOrphanProject()
        {
            var solution = new FakeSolution(@"/test/fake.sln");
            var project = new OrphanProject();
            project.Files.Add(new CSharpFile(project, "/test/folder/Test.cs", "Some content..."));
            solution.Projects.Add(project);

            var request = new AddToProjectRequest
            {
                FileName = @"/test/folder/Test.cs"
            };

            var handler = new AddToProjectHandler(solution);
            handler.AddToProject(request);
        }