Example #1
0
        private Proj GetProject(string fileName)
        {
            file = SampleFiles.SampleFileHelper.GetCsProjFile(fileName);
            var reader = new ProjReader();

            return(reader.Read(file));
        }
        protected override void ProcessStream(out String assemblyName
                                              , out String projectGuid
                                              , out List <FileInfo> dependencies)
        {
            String rootNamespace = null;
            String projectName   = null;

            assemblyName = null;
            projectGuid  = null;
            dependencies = new List <FileInfo>(0);

            while (ProjReader.EndOfStream == false)
            {
                var line = ProjReader.ReadLine().Trim();

                if (line.StartsWith("<ProjectName>"))
                {
                    projectName = GetProjectName(line);
                }
                else if (line.StartsWith("<RootNamespace>"))
                {
                    rootNamespace = GetRootNamespace(line);
                }
                else if (line.StartsWith("<TargetName>"))
                {
                    assemblyName = GetTargetName(line);
                }
                else if (line.StartsWith("<ProjectGuid>"))
                {
                    projectGuid = GetProjectGuid(line);
                }
            }

            if (assemblyName != null)
            {
                var pn = projectName ?? String.Empty;

                assemblyName = Regex.Replace(assemblyName, @"\$\(ProjectName\)", pn, RegexOptions.IgnoreCase);

                assemblyName = Regex.Replace(assemblyName, @"\$\(RootNamespace\)", pn, RegexOptions.IgnoreCase);
            }

            if ((assemblyName != null) && (assemblyName.Contains("$")))
            {
                var logger = Logger.GetLogger(LogType.NoAssemblyName);

                logger.Log("AssemblyName Resolving Error:");
                logger.Log(Proj.DirectoryName, 1);
                logger.Log(Proj.Name, 1);
                logger.Log(assemblyName, 1);
                logger.Log();
            }

            if (assemblyName == null)
            {
                assemblyName = projectName;
            }
        }
Example #3
0
 public void BeforeEach()
 {
     options    = new SlnGenerationOptions(WorkingDirectory);
     finder     = MockRepository.GenerateStrictMock <ProjectFileFinder>();
     reader     = MockRepository.GenerateStrictMock <ProjReader>();
     repository = new CsProjRepository
     {
         Finder = finder,
         Reader = reader
     };
 }
Example #4
0
        protected override void ProcessStream(out String assemblyName
                                              , out String projectGuid
                                              , out List <FileInfo> dependencies)
        {
            assemblyName = null;
            projectGuid  = null;
            dependencies = new List <FileInfo>(20);

            while (ProjReader.EndOfStream == false)
            {
                var line = ProjReader.ReadLine().Trim();

                if (line.StartsWith("<AssemblyName>"))
                {
                    assemblyName = GetAssemblyName(line);
                }
                else if (line.StartsWith("<ProjectGuid>"))
                {
                    projectGuid = GetProjectGuid(line);
                }
                else if (line.StartsWith("<ProjectReference"))
                {
                    var dependency = TryGetDependency(line);

                    if (dependency != null)
                    {
                        dependencies.Add(dependency);
                    }
                }
            }

            if ((assemblyName != null) && (assemblyName.Contains("$")))
            {
                var logger = Logger.GetLogger(LogType.NoAssemblyName);

                logger.Log("AssemblyName Resolving Error:");
                logger.Log(Proj.DirectoryName, 1);
                logger.Log(Proj.Name, 1);
                logger.Log(assemblyName, 1);
                logger.Log();
            }
        }
Example #5
0
        private String TryAddHintPath(String line
                                      , String dependency)
        {
            while (ProjReader.EndOfStream == false)
            {
                var nextLine = ProjReader.ReadLine().Trim();

                if (nextLine == "</ProjectReference>")
                {
                    break;
                }

                if (line.StartsWith("<HintPath>"))
                {
                    var hintPath = RemoveTag(line, "HintPath");

                    dependency = Path.Combine(hintPath, dependency);

                    break;
                }
            }

            return(dependency);
        }