Beispiel #1
0
        protected void SetProjectItemsConfigs(SlnResult data)
        {
            if (data.ProjectConfigurationPlatforms == null)
            {
                return;
            }

            var ret = new List <ProjectItemCfg>();

            foreach (var slnConf in data.ProjectConfigurationPlatforms)
            {
                foreach (var prjConf in slnConf.Value)
                {
                    ProjectItem pItem;

                    if (data.ProjectItems == null)
                    {
                        pItem = default;
                    }
                    else
                    {
                        pItem = data.ProjectItems.FirstOrDefault(p => p.pGuid.Guid() == prjConf.PGuid.Guid());
                    }

                    ret.Add(new ProjectItemCfg(pItem, slnConf.Key, prjConf));
                }
            }
            data.ProjectItemsConfigs = ret;
        }
Beispiel #2
0
        /// <summary>
        /// To parse data from used stream.
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="type">Allowed type of operations.</param>
        /// <returns></returns>
        public ISlnResult Parse(StreamReader reader, SlnItems type)
        {
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader), MsgResource.ValueNoEmptyOrNull);
            }

            string sln = (reader.BaseStream is FileStream) ? ((FileStream)reader.BaseStream).Name : MEM_FILE;

            var data = new SlnResult()
            {
                SolutionDir = sln.GetDirectoryFromFile(),
                ResultType  = type,
            };

            Process(new Svc(reader, data));

            if (data.SolutionConfigs != null)
            {
                data.DefaultConfig = new ConfigItem(
                    ExtractDefaultConfiguration(data.SolutionConfigs),
                    ExtractDefaultPlatform(data.SolutionConfigs)
                    );
            }

            data.Properties = GlobalProperties(
                sln,
                data.DefaultConfig?.Configuration,
                data.DefaultConfig?.Platform
                );

            Aliases(data);

            if ((type & SlnItems.Env) == SlnItems.Env)
            {
                data.Env = new IsolatedEnv(data, RawXmlProjects);
                if ((type & SlnItems.EnvWithMinimalProjects) == SlnItems.EnvWithMinimalProjects)
                {
                    data.Env.LoadMinimalProjects();
                }
                if ((type & SlnItems.EnvWithProjects) == SlnItems.EnvWithProjects)
                {
                    data.Env.LoadProjects();
                }
            }

            if ((type & SlnItems.ProjectDependenciesXml) == SlnItems.ProjectDependenciesXml)
            {
                if (data.Env?.Projects != null)
                {
                    // The following class provides additional features for project references in ISlnPDManager manner,
                    // But we'll just activate references for existing ProjectDependencies (shallow copy)
                    // just to eliminate miscellaneous units between VS and msbuild world: https://github.com/3F/MvsSln/issues/25
                    new ProjectReferences(data.ProjectDependencies, data.Env.Projects);
                }
            }

            return(data);
        }
Beispiel #3
0
        protected void SetProjectConfigurationPlatforms(SlnResult data)
        {
            if (data.SolutionConfigs == null || data.ProjectConfigs == null)
            {
                return;
            }

            var ret = new Dictionary <IConfPlatform, IConfPlatformPrj[]>();

            foreach (var sln in data.SolutionConfigs)
            {
                ret[sln] = data.ProjectConfigs.Where(p => (ConfigItem)p.Sln == (ConfigItem)sln).ToArray();
            }

            data.ProjectConfigurationPlatforms = new RoProperties <IConfPlatform, IConfPlatformPrj[]>(ret);
        }
Beispiel #4
0
        /// <summary>
        /// To parse data from used stream.
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="type">Allowed type of operations.</param>
        /// <returns></returns>
        public ISlnResult Parse(StreamReader reader, SlnItems type)
        {
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader), MsgResource.ValueNoEmptyOrNull);
            }

            string sln = (reader.BaseStream is FileStream) ? ((FileStream)reader.BaseStream).Name : MEM_FILE;

            var data = new SlnResult()
            {
                SolutionDir = sln.GetDirectoryFromFile(),
                ResultType  = type,
            };

            Process(new Svc(reader, data));

            if (data.SolutionConfigs != null)
            {
                data.DefaultConfig = new ConfigItem(
                    ExtractDefaultConfiguration(data.SolutionConfigs),
                    ExtractDefaultPlatform(data.SolutionConfigs)
                    );
            }

            data.Properties = GlobalProperties(
                sln,
                data.DefaultConfig?.Configuration,
                data.DefaultConfig?.Platform
                );

            Aliases(data);

            if ((type & SlnItems.Env) == SlnItems.Env)
            {
                data.Env = new IsolatedEnv(data, RawXmlProjects);
                if ((type & SlnItems.EnvWithMinimalProjects) == SlnItems.EnvWithMinimalProjects)
                {
                    data.Env.LoadMinimalProjects();
                }
                if ((type & SlnItems.EnvWithProjects) == SlnItems.EnvWithProjects)
                {
                    data.Env.LoadProjects();
                }
            }
            return(data);
        }
Beispiel #5
0
 /// <summary>
 /// TODO: another way to manage aliases for data.
 /// </summary>
 /// <param name="data"></param>
 protected void Aliases(SlnResult data)
 {
     SetProjectConfigurationPlatforms(data);
     SetProjectItemsConfigs(data);
 }