/// <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); }
public void SetUp() { var controller = new CSharpController(); codeRoot = new CodeRoot(controller); var ns = new Namespace(controller, "Namespace1") { Index = 0 }; codeRoot.AddChild(ns); ns.AddChild(new Class(controller, "Class1") { Index = 1 }); }
public void SetUp() { var controller = new CSharpController(); codeRoot = new CodeRoot(controller); var ns = new Namespace(controller, "Namespace1") { Index = 0 }; codeRoot.AddChild(ns); ns.AddChild(new Class(controller, "Class1") { Index = 1 }); }