Exemple #1
0
        public void ReadFromStream(TextReader sr)
        {
            this.Clear();
            this.m_RootElements = PBXProjectData.ParseContent(sr.ReadToEnd());
            if (!this.m_RootElements.Contains("objects"))
            {
                throw new Exception("Invalid PBX project file: no objects element");
            }
            PBXElementDict pbxElementDict1 = this.m_RootElements["objects"].AsDict();

            this.m_RootElements.Remove("objects");
            this.m_RootElements.SetString("objects", "OBJMARKER");
            if (this.m_RootElements.Contains("objectVersion"))
            {
                this.m_ObjectVersion = this.m_RootElements["objectVersion"].AsString();
                this.m_RootElements.Remove("objectVersion");
            }
            List <string> allGuids        = new List <string>();
            string        prevSectionName = (string)null;

            foreach (KeyValuePair <string, PBXElement> keyValuePair in (IEnumerable <KeyValuePair <string, PBXElement> >)pbxElementDict1.values)
            {
                allGuids.Add(keyValuePair.Key);
                PBXElement pbxElement = keyValuePair.Value;
                if (!(pbxElement is PBXElementDict) || !pbxElement.AsDict().Contains("isa"))
                {
                    this.m_UnknownObjects.values.Add(keyValuePair.Key, pbxElement);
                }
                else
                {
                    PBXElementDict pbxElementDict2 = pbxElement.AsDict();
                    string         index1          = pbxElementDict2["isa"].AsString();
                    if (this.m_Section.ContainsKey(index1))
                    {
                        this.m_Section[index1].AddObject(keyValuePair.Key, pbxElementDict2);
                    }
                    else
                    {
                        KnownSectionBase <PBXObjectData> knownSectionBase;
                        if (this.m_UnknownSections.ContainsKey(index1))
                        {
                            knownSectionBase = this.m_UnknownSections[index1];
                        }
                        else
                        {
                            knownSectionBase = new KnownSectionBase <PBXObjectData>(index1);
                            this.m_UnknownSections.Add(index1, knownSectionBase);
                        }
                        knownSectionBase.AddObject(keyValuePair.Key, pbxElementDict2);
                        if (!this.m_SectionOrder.Contains(index1))
                        {
                            int index2 = 0;
                            if (prevSectionName != null)
                            {
                                index2 = this.m_SectionOrder.FindIndex((Predicate <string>)(x => x == prevSectionName)) + 1;
                            }
                            this.m_SectionOrder.Insert(index2, index1);
                        }
                    }
                    prevSectionName = index1;
                }
            }
            this.RepairStructure(allGuids);
            this.RefreshAuxMaps();
        }
Exemple #2
0
        private bool RepairStructureImpl(Dictionary <string, bool> allGuids)
        {
            bool flag1 = false | PBXProjectData.RemoveObjectsFromSection <PBXBuildFileData>(this.buildFiles, allGuids, (Func <PBXBuildFileData, bool>)(o =>
            {
                if (o.fileRef != null)
                {
                    return(!allGuids.ContainsKey(o.fileRef));
                }
                return(true);
            })) | PBXProjectData.RemoveObjectsFromSection <PBXGroupData>(this.groups, allGuids, (Func <PBXGroupData, bool>)(o => o.children == null));

            foreach (PBXGroupData pbxGroupData in this.groups.GetObjects())
            {
                PBXProjectData.RemoveMissingGuidsFromGuidList(pbxGroupData.children, allGuids);
            }
            bool flag2 = flag1 | PBXProjectData.RemoveObjectsFromSection <PBXSourcesBuildPhaseData>(this.sources, allGuids, (Func <PBXSourcesBuildPhaseData, bool>)(o => o.files == null));

            foreach (FileGUIDListBase fileGuidListBase in this.sources.GetObjects())
            {
                PBXProjectData.RemoveMissingGuidsFromGuidList(fileGuidListBase.files, allGuids);
            }
            bool flag3 = flag2 | PBXProjectData.RemoveObjectsFromSection <PBXHeadersBuildPhaseData>(this.headers, allGuids, (Func <PBXHeadersBuildPhaseData, bool>)(o => o.files == null));

            foreach (FileGUIDListBase fileGuidListBase in this.headers.GetObjects())
            {
                PBXProjectData.RemoveMissingGuidsFromGuidList(fileGuidListBase.files, allGuids);
            }
            bool flag4 = flag3 | PBXProjectData.RemoveObjectsFromSection <PBXFrameworksBuildPhaseData>(this.frameworks, allGuids, (Func <PBXFrameworksBuildPhaseData, bool>)(o => o.files == null));

            foreach (FileGUIDListBase fileGuidListBase in this.frameworks.GetObjects())
            {
                PBXProjectData.RemoveMissingGuidsFromGuidList(fileGuidListBase.files, allGuids);
            }
            bool flag5 = flag4 | PBXProjectData.RemoveObjectsFromSection <PBXResourcesBuildPhaseData>(this.resources, allGuids, (Func <PBXResourcesBuildPhaseData, bool>)(o => o.files == null));

            foreach (FileGUIDListBase fileGuidListBase in this.resources.GetObjects())
            {
                PBXProjectData.RemoveMissingGuidsFromGuidList(fileGuidListBase.files, allGuids);
            }
            bool flag6 = flag5 | PBXProjectData.RemoveObjectsFromSection <PBXCopyFilesBuildPhaseData>(this.copyFiles, allGuids, (Func <PBXCopyFilesBuildPhaseData, bool>)(o => o.files == null));

            foreach (FileGUIDListBase fileGuidListBase in this.copyFiles.GetObjects())
            {
                PBXProjectData.RemoveMissingGuidsFromGuidList(fileGuidListBase.files, allGuids);
            }
            bool flag7 = flag6 | PBXProjectData.RemoveObjectsFromSection <PBXShellScriptBuildPhaseData>(this.shellScripts, allGuids, (Func <PBXShellScriptBuildPhaseData, bool>)(o => o.files == null));

            foreach (FileGUIDListBase fileGuidListBase in this.shellScripts.GetObjects())
            {
                PBXProjectData.RemoveMissingGuidsFromGuidList(fileGuidListBase.files, allGuids);
            }
            bool flag8 = flag7 | PBXProjectData.RemoveObjectsFromSection <PBXNativeTargetData>(this.nativeTargets, allGuids, (Func <PBXNativeTargetData, bool>)(o => o.phases == null));

            foreach (PBXNativeTargetData nativeTargetData in this.nativeTargets.GetObjects())
            {
                PBXProjectData.RemoveMissingGuidsFromGuidList(nativeTargetData.phases, allGuids);
            }
            bool flag9 = flag8 | PBXProjectData.RemoveObjectsFromSection <PBXVariantGroupData>(this.variantGroups, allGuids, (Func <PBXVariantGroupData, bool>)(o => o.children == null));

            foreach (PBXGroupData pbxGroupData in this.variantGroups.GetObjects())
            {
                PBXProjectData.RemoveMissingGuidsFromGuidList(pbxGroupData.children, allGuids);
            }
            bool flag10 = flag9 | PBXProjectData.RemoveObjectsFromSection <XCConfigurationListData>(this.buildConfigLists, allGuids, (Func <XCConfigurationListData, bool>)(o => o.buildConfigs == null));

            foreach (XCConfigurationListData configurationListData in this.buildConfigLists.GetObjects())
            {
                PBXProjectData.RemoveMissingGuidsFromGuidList(configurationListData.buildConfigs, allGuids);
            }
            return(flag10);
        }
Exemple #3
0
        public void ReadFromStream(TextReader sr)
        {
            this.Clear();
            this.m_RootElements = PBXProjectData.ParseContent(sr.ReadToEnd());
            if (!this.m_RootElements.Contains("objects"))
            {
                throw new Exception("Invalid PBX project file: no objects element");
            }
            PBXElementDict pbxElementDict1 = this.m_RootElements["objects"].AsDict();

            this.m_RootElements.Remove("objects");
            this.m_RootElements.SetString("objects", "OBJMARKER");
            if (this.m_RootElements.Contains("objectVersion"))
            {
                this.m_ObjectVersion = this.m_RootElements["objectVersion"].AsString();
                this.m_RootElements.Remove("objectVersion");
            }
            List <string> allGuids = new List <string>();
            // ISSUE: reference to a compiler-generated field
            string prevSectionName = null;

            foreach (KeyValuePair <string, PBXElement> keyValuePair in (IEnumerable <KeyValuePair <string, PBXElement> >)pbxElementDict1.values)
            {
                allGuids.Add(keyValuePair.Key);
                PBXElement pbxElement = keyValuePair.Value;
                if (!(pbxElement is PBXElementDict) || !pbxElement.AsDict().Contains("isa"))
                {
                    this.m_UnknownObjects.values.Add(keyValuePair.Key, pbxElement);
                }
                else
                {
                    PBXElementDict pbxElementDict2 = pbxElement.AsDict();
                    string         index1          = pbxElementDict2["isa"].AsString();
                    if (this.m_Section.ContainsKey(index1))
                    {
                        this.m_Section[index1].AddObject(keyValuePair.Key, pbxElementDict2);
                    }
                    else
                    {
                        KnownSectionBase <PBXObjectData> knownSectionBase;
                        if (this.m_UnknownSections.ContainsKey(index1))
                        {
                            knownSectionBase = this.m_UnknownSections[index1];
                        }
                        else
                        {
                            knownSectionBase = new KnownSectionBase <PBXObjectData>(index1);
                            this.m_UnknownSections.Add(index1, knownSectionBase);
                        }
                        knownSectionBase.AddObject(keyValuePair.Key, pbxElementDict2);
                        if (!this.m_SectionOrder.Contains(index1))
                        {
                            int pos = 0;
                            if (prevSectionName != null)
                            {
                                // this never fails, because we already added any previous unknown sections
                                // to m_SectionOrder
                                pos  = m_SectionOrder.FindIndex(x => x == prevSectionName);
                                pos += 1;
                            }
                            m_SectionOrder.Insert(pos, index1);
                        }
                    }
                    // ISSUE: reference to a compiler-generated field
                    prevSectionName = index1;
                }
            }
            this.RepairStructure(allGuids);
            this.RefreshAuxMaps();
        }