Example #1
0
        /// <summary>
        /// Generates the Merged CodeRoot object.
        /// </summary>
        /// <exception cref="InvalidOperationException">If no code roots have been added, or there is a conflict.</exception>
        /// <returns></returns>
        public ICodeRoot GetMergedCodeRoot()
        {
            ICodeRoot originalCodeRoot = coderoots.GetFirstNonNullObject();

            if (originalCodeRoot == null)
            {
                throw new InvalidOperationException("Cannot merge code roots when none have been added");
            }
            ICodeRoot newCodeRoot = originalCodeRoot.NewInstance();

            originalCodeRoot.ShallowCloneInto(newCodeRoot);

            foreach (CodeRootMapNode child in children)
            {
                MissingObject missingObjects = child.DetermineMissingConstructs();
                if ((missingObjects & MissingObject.User) != 0 &&
                    (missingObjects & MissingObject.NewGen) != 0)
                {
                    // Only PrevGen here. Ignore it.
                    continue;
                }

                newCodeRoot.AddChild(child.GetMergedBaseConstruct());
            }

            return(newCodeRoot);
        }