Ejemplo n.º 1
0
        /// <summary>
        /// Drafts the two typical lines found, per project, in a .sln file.
        /// </summary>
        /// <param name="projFile">
        /// If the projFile has its <see cref="ProjFile.GetMainProjectTypeGuid()"/> property assigned then
        /// that value is used; elsewise, a match is looked up in <see cref="VisualStudioProjTypeGuids"/>
        /// </param>
        /// <param name="slnDir"></param>
        /// <returns></returns>
        public static string GetSlnProjectEntry(ProjFile projFile, string slnDir)
        {
            var projExt = Path.GetExtension(projFile.FileName);

            if (string.IsNullOrWhiteSpace(projExt))
            {
                return(null);
            }

            var projGuid = projFile.ProjectGuid;

            if (string.IsNullOrWhiteSpace(projGuid))
            {
                return(null);
            }

            if (string.IsNullOrWhiteSpace(projFile.GetMainProjectTypeGuid()) && !VisualStudioProjTypeGuids.ContainsKey(projExt))
            {
                throw new NotImplementedException("There is no VS Project Type Guid defined for " +
                                                  $"a '{projExt}' file type.  Assign the ProjFile's " +
                                                  "VsProjectTypeGuids directly.");
            }

            var projTypeGuid = projFile.GetMainProjectTypeGuid() ?? VisualStudioProjTypeGuids[projExt];

            var projName = Path.GetFileNameWithoutExtension(projFile.FileName);

            var projFileFullName = Path.Combine(projFile.DirectoryName, projFile.FileName);
            var projRelFullName  = projFileFullName;

            NfPath.TryGetRelPath(slnDir, ref projRelFullName);

            var projBldr = new StringBuilder();

            projBldr.AppendLine(
                $"Project(\"{projTypeGuid}\") = \"{projName}\", \"{projRelFullName}\", \"{projGuid}\"");
            projBldr.AppendLine("EndProject");
            return(projBldr.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Replaces the implementation of each <see cref="CgMember"/>, including signature, with whitespace.
        /// The implementation is resolved on the <see cref="CgMember.PdbModuleSymbols"/>
        /// </summary>
        /// <param name="rmCgMems"></param>
        /// <param name="removeEmptyLines">Optional, set to true to not have the results as blank char-for-char</param>
        public static string[] RemoveMembersFromSrcCodeFiles(List <CgMember> rmCgMems, bool removeEmptyLines = false)
        {
            if (rmCgMems == null || rmCgMems.Count <= 0)
            {
                return(new string[0]);
            }

            var byFile =
                rmCgMems.Where(
                    x =>
                    !string.IsNullOrWhiteSpace(x?.PdbModuleSymbols?.file) && File.Exists(x.PdbModuleSymbols.file))
                .ToList();

            if (byFile.Count <= 0)
            {
                return(new string[0]);
            }
            var modifiedFiles = new List <string>();

            foreach (var fl in byFile.Select(x => x.PdbModuleSymbols.file).Distinct())
            {
                var srcLines = File.ReadAllLines(fl);
                var cgMems   =
                    byFile.Where(x => string.Equals(x.PdbModuleSymbols.file, fl, StringComparison.OrdinalIgnoreCase))
                    .ToList();
                RemoveMembersFromSrcCodeFiles(srcLines, cgMems, fl);
                modifiedFiles.Add(fl);
                if (removeEmptyLines)
                {
                    System.Threading.Thread.Sleep(50);
                    NfPath.ToDoubleSpaced(fl);
                }
            }

            return(modifiedFiles.ToArray());
        }
Ejemplo n.º 3
0
 public void TestContainsExcludeCodeDirectory()
 {
     Assert.IsTrue(NfPath.ContainsExcludeCodeDirectory(@"C:\Projects\Wanker\Services\WCF\WSXXX\bin\QA3"));
 }
Ejemplo n.º 4
0
 public void TestIsCodeFileExtension()
 {
     Assert.IsTrue(NfPath.IsCodeFileExtension(".cs"));
     Assert.IsTrue(NfPath.IsCodeFileExtension("MyCode.cs"));
     Assert.IsTrue(NfPath.IsCodeFileExtension(@"C:\Projects\MyCodeFile.cs"));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Writes the current in memory contents to file.
 /// </summary>
 public virtual void Save(Encoding encoding = null)
 {
     NfPath.SaveXml(_xmlDocument, _fileFullName, encoding);
 }