Пример #1
0
        /// <summary>
        /// New position in stream.
        /// </summary>
        /// <param name="svc"></param>
        /// <param name="line">Received line.</param>
        /// <returns>true if it was processed by current handler, otherwise it means ignoring.</returns>
        public override bool Positioned(ISvc svc, RawText line)
        {
            var pItem = new ProjectItem(line.trimmed, svc.Sln.SolutionDir);

            if (pItem.pGuid == null ||
                !String.Equals(Guids.SLN_FOLDER, pItem.pType, StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }

            LSender.Send(this, $"Found solution-folder: '{pItem.name}'", Message.Level.Info);

            var folderItems = new List <RawText>();

            while ((line = svc.ReadLine(this)) != null && (line != "EndProject"))
            {
                if (!line.trimmed.StartsWith("ProjectSection(SolutionItems) = preProject", StringComparison.Ordinal))
                {
                    continue;
                }

                for (line = svc.ReadLine(this); line != null; line = svc.ReadLine(this))
                {
                    if (line.trimmed.StartsWith("EndProjectSection", StringComparison.Ordinal))
                    {
                        break;
                    }

                    var item = line.trimmed.Before('=');
                    if (item == null)
                    {
                        LSender.Send(
                            this,
                            $"Ignored incorrect item for '{pItem.name}':{pItem.pGuid} - '{line}'",
                            Message.Level.Warn
                            );
                        continue;
                    }

                    item = item.TrimEnd();
                    LSender.Send(this, $"Found item: '{item}'", Message.Level.Info);

                    folderItems.Add(new RawText(item, svc.CurrentEncoding));
                }
            }

            if (svc.Sln.SolutionFolderList == null)
            {
                svc.Sln.SolutionFolderList = new List <SolutionFolder>();
            }

            svc.Sln.SolutionFolderList.Add(new SolutionFolder(pItem, folderItems));
            return(true);
        }
Пример #2
0
        /// <summary>
        /// New position in stream.
        /// </summary>
        /// <param name="svc"></param>
        /// <param name="line">Received line.</param>
        /// <returns>true if it was processed by current handler, otherwise it means ignoring.</returns>
        public override bool Positioned(ISvc svc, RawText line)
        {
            if (svc.Sln.ExtItems == null)
            {
                svc.Sln.ExtItems = new Dictionary <string, string>();
            }

            string _line;

            while ((_line = svc.ReadLine(this)) != null && _line.Trim() != "EndGlobalSection")
            {
                int pos = _line.IndexOf('=');
                if (pos < 0) // we will use non-strict processing
                {
                    svc.Sln.ExtItems[_line.Trim()] = null;
                    LSender.Send(this, $"Found extensible null record:{_line}", Message.Level.Info);
                    continue;
                }

                string key = _line.Substring(0, pos).Trim();
                string val = _line.Substring(pos + 1).Trim();

                svc.Sln.ExtItems[key] = val;
                LSender.Send(this, $"Found extensible key-value: `{key}` = `{val}`", Message.Level.Info);
            }

            return(true);
        }
        /// <summary>
        /// New position in stream.
        /// </summary>
        /// <param name="svc"></param>
        /// <param name="line">Received line.</param>
        /// <returns>true if it was processed by current handler, otherwise it means ignoring.</returns>
        public override bool Positioned(ISvc svc, RawText line)
        {
            if (svc.Sln.SolutionConfigList == null)
            {
                svc.Sln.SolutionConfigList = new List <IConfPlatform>();
            }

            string _line;

            while ((_line = svc.ReadLine(this)) != null && _line.Trim() != "EndGlobalSection")
            {
                string left = _line.Before('=')?.Trim(); // Debug|Win32 = Debug|Win32
                if (left == null ||
                    String.Compare(left, "DESCRIPTION", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    LSender.Send(this, $"Solution Configuration has been ignored for line '{_line}'", Message.Level.Debug);
                    continue;
                }

                string[] cfg = left.Split('|');
                if (cfg.Length < 2)
                {
                    continue;
                }

                LSender.Send(this, $"Solution Configuration ->['{cfg[0]}' ; '{cfg[1]}']", Message.Level.Info);
                svc.Sln.SolutionConfigList.Add(new ConfigSln(cfg[0], cfg[1]));
            }

            return(true);
        }
Пример #4
0
        /// <summary>
        /// New position in stream.
        /// </summary>
        /// <param name="svc"></param>
        /// <param name="line">Received line.</param>
        /// <returns>true if it was processed by current handler, otherwise it means ignoring.</returns>
        public override bool Positioned(ISvc svc, RawText line)
        {
            string _line;

            while ((_line = svc.ReadLine(this)) != null && _line.Trim() != "EndGlobalSection")
            {
                int pos = _line.IndexOf('='); // Guids: src = dest
                if (pos < 0)
                {
                    LSender.Send(this, $"Incorrect NestedProjects records: '{_line}'", Message.Level.Warn);
                    return(false);
                }

                string src  = _line.Substring(0, pos).Trim();
                string dest = _line.Substring(pos + 1).Trim();

                LSender.Send(this, $"NestedProjects '{src}' -> '{dest}'", Message.Level.Info);

                var parent = svc.Sln.SolutionFolderList.Where(f => f.header.pGuid == dest).First();

                svc.Sln.SolutionFolderList.Where(f => f.header.pGuid == src)
                .ForEach(f => f.header.parent.Value = parent);

                svc.Sln.ProjectItemList.Where(p => p.pGuid == src)
                .ForEach(p => p.parent.Value = parent);
            }

            return(true);
        }
Пример #5
0
        protected void Process(ISvc svc)
        {
            _coh = new CoHandlers(SlnHandlers);

            DoPreProcessing(svc);
            {
                string line;
                while ((line = svc.ReadLine()) != null)
                {
                    DoPositioned(svc, new RawText(line, svc.CurrentEncoding));
                }
            }
            DoPostProcessing(svc);
        }
Пример #6
0
        /// <summary>
        /// New position in stream.
        /// </summary>
        /// <param name="svc"></param>
        /// <param name="line">Received line.</param>
        /// <returns>true if it was processed by current handler, otherwise it means ignoring.</returns>
        public override bool Positioned(ISvc svc, RawText line)
        {
            if (svc.Sln.ProjectConfigList == null)
            {
                svc.Sln.ProjectConfigList = new List <IConfPlatformPrj>();
            }

            var records = new Dictionary <Cortege, ConfigPrj>(new EqCortegeComparer());

            string _line;

            while ((_line = svc.ReadLine(this)) != null && _line.Trim() != "EndGlobalSection")
            {
                var v = Parse(ref _line, out LineAttr ltype);

                if (ltype == LineAttr.InvalidOrUnknown)
                {
                    LSender.Send(this, $"Incorrect Project Configuration: {v}; raw: '{_line}'", Message.Level.Warn);
                    continue;
                }

                //NOTE: Build0 and Deploy0 records are valid too. Even if an ActiveCfg is corrupted and does not exist at all.
                if (!records.ContainsKey(v))
                {
                    LSender.Send(this, $"Found Project Configuration: {v}", Message.Level.Info);

                    records[v] = new ConfigPrj(v.cprj, v.pGuid, false, new ConfigSln(v.csln));
                    svc.Sln.ProjectConfigList.Add(records[v]);
                }

                if (ltype == LineAttr.Build0)
                {
                    LSender.Send(this, $"Project Configuration, update Build.0  {v}", Message.Level.Debug);
                    records[v].IncludeInBuild = true;
                    continue;
                }

                if (ltype == LineAttr.Deploy0)
                {
                    LSender.Send(this, $"Project Configuration, update Deploy.0  {v}", Message.Level.Debug);
                    records[v].IncludeInDeploy = true;
                    continue;
                }
            }

            return(true);
        }
Пример #7
0
        /// <summary>
        /// New position in stream.
        /// </summary>
        /// <param name="svc"></param>
        /// <param name="line">Received line.</param>
        /// <returns>true if it was processed by current handler, otherwise it means ignoring.</returns>
        public override bool Positioned(ISvc svc, RawText line)
        {
            if (svc.Sln.ProjectConfigList == null)
            {
                svc.Sln.ProjectConfigList = new List <IConfPlatformPrj>();
            }

            /*
             * [Projects Guid]                        [Solution pair]                [Project pair]
             * {A7BF1F9C-F18D-423E-9354-859DC3CFAFD4}.CI_Release|Any CPU.ActiveCfg = Release|Any CPU   - configuration name
             * {A7BF1F9C-F18D-423E-9354-859DC3CFAFD4}.CI_Release|Any CPU.Build.0 = Release|Any CPU     - flag of build  (this line exists only when this flag is true)
             */
            string _line;

            var cortege = new Dictionary <Cortege, ConfigPrj>(new EqCortegeComparer());

            while ((_line = svc.ReadLine(this)) != null && _line.Trim() != "EndGlobalSection")
            {
                int x, y;

                x = _line.IndexOf('.');
                var pGuid = _line.Substring(0, x).Trim();

                y = _line.IndexOf('.', ++x);
                string csln = _line.Substring(x, y - x).Trim();

                x = _line.IndexOf('=', ++y);
                string type = _line.Substring(y, x - y).Trim();

                string cprj = _line.Substring(x + 1).Trim();

                bool isActiveCfg = type.Equals("ActiveCfg", StringComparison.OrdinalIgnoreCase);
                bool isBuild0    = type.Equals("Build.0", StringComparison.OrdinalIgnoreCase);
                bool isDeploy0   = type.Equals("Deploy.0", StringComparison.OrdinalIgnoreCase);

                if (!isActiveCfg && !isBuild0 && !isDeploy0)
                {
                    LSender.Send(this, $"Project Configuration has been ignored for line '{_line}'", Message.Level.Debug);
                    continue;
                }

                var ident = new Cortege()
                {
                    pGuid = pGuid,
                    csln  = csln,
                    cprj  = cprj,
                };

                if (!cortege.ContainsKey(ident))
                {
                    LSender.Send(this, $"New Project Configuration `{pGuid}`, `{csln}` = `{cprj}` /{type}", Message.Level.Info);
                    cortege[ident] = new ConfigPrj(cprj, pGuid, isBuild0, new ConfigSln(csln));
                    svc.Sln.ProjectConfigList.Add(cortege[ident]);
                    continue;
                }

                if (isBuild0)
                {
                    LSender.Send(this, $"Project Configuration, update Build.0  `{pGuid}`", Message.Level.Debug);
                    cortege[ident].IncludeInBuild = true;
                    continue;
                }

                if (isDeploy0)
                {
                    LSender.Send(this, $"Project Configuration, update Deploy.0  `{pGuid}`", Message.Level.Debug);
                    cortege[ident].IncludeInDeploy = true;
                    continue;
                }
            }

            return(true);
        }