Ejemplo n.º 1
0
        /// <summary>
        /// Command line interface to parse all the TTree's in a
        /// TFile and make the XML file that specifies their layout
        /// for later object generation.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            ///
            /// Parse the inputs
            /// 

            List<FileInfo> rootFiles = new List<FileInfo>();
            List<FileInfo> libraries = new List<FileInfo>();
            string specialFile = "";
            FileInfo outputFile = null;
            DirectoryInfo outputDir = null;
            bool doExistanceCheck = true;

            foreach (var arg in args)
            {
                if (arg == "-o")
                {
                    specialFile = "o";
                    doExistanceCheck = false;
                    continue;
                }

                if (arg == "-d")
                {
                    specialFile = "outD";
                    doExistanceCheck = false;
                    continue;
                }

                if (specialFile == "outD")
                {
                    DirectoryInfo inf = new DirectoryInfo(arg);
                    if (!inf.Exists)
                        inf.Create();
                    outputDir = inf;
                    specialFile = "";
                    continue;
                }

                FileInfo f = new FileInfo(arg);
                if (doExistanceCheck && !f.Exists)
                {
                    SimpleLogging.Log("Could not file file {0}", f.FullName);
                    return;
                }
                doExistanceCheck = true;

                if (specialFile.Length > 0)
                {
                    if (specialFile == "o")
                        outputFile = f;
                    specialFile = "";
                }
                else if (f.Extension == ".root" || f.Name.Contains(".root."))
                {
                    rootFiles.Add(f);
                }
                else
                {
                    libraries.Add(f);
                }
            }

            if (rootFiles.Count == 0)
            {
                SimpleLogging.Log("no input root files to scan!");
                return;
            }

            // Output directory for all our files is where the root file is located if we don't have anything better!
            if (outputDir == null)
            {
                outputDir = rootFiles[0].Directory;
            }

            if (outputFile == null)
                outputFile = new FileInfo(string.Format("{0}\\{1}", outputDir.FullName, Path.ChangeExtension(rootFiles[0].Name, "ntupom")));

            ///
            /// Make sure to write everything to a log file for the next step!
            /// 

            using (var logFile = File.CreateText(Path.ChangeExtension(outputFile.FullName, ".log")))
            {
                SimpleLogging.AddStream(logFile);

                ///
                /// Next, load up all the libraries
                /// 

                var gSystem = ROOTNET.NTSystem.gSystem;
                foreach (var lib in libraries)
                {
                    gSystem.Load(lib.FullName);
                }

                ///
                /// Next, we need to find all the classes that are in those libraries,
                /// and then figure out where the location of the classes is.
                /// 

                var loadedNames = (from s in libraries
                                   select Path.GetFileNameWithoutExtension(s.Name)).ToArray();

                var usedClasses = from cls in ROOTNET.NTROOT.gROOT.ListOfClasses.Cast<ROOTNET.Interface.NTClass>()
                                  let shared = cls.SharedLibs
                                  where shared != null
                                  let name = Path.GetFileNameWithoutExtension(shared.Split().First())
                                  where loadedNames.Contains(name)
                                  select cls;

                var sourcefiles = from cls in usedClasses
                                  select cls.GetImplFileName();

                ///
                /// And now process the root files!
                /// 

                var converter = new TTreeParser.ParseTFile();
                converter.ProxyGenerationLocation = outputDir;

                var rootClassList = from f in rootFiles
                                    from c in converter.ParseFile(f)
                                    select c;
                var allClasses = rootClassList.ToArray();
                if (allClasses.Length == 0)
                {
                    SimpleLogging.Log("No classes were found in the input files!");
                    return;
                }

                ///
                /// Write out the output xml file now
                /// 

                NtupleTreeInfo results = new NtupleTreeInfo() { Classes = allClasses, ClassImplimintationFiles = sourcefiles.ToArray() };
                XmlSerializer xmlout = new XmlSerializer(typeof(NtupleTreeInfo));
                using (var output = outputFile.CreateText())
                {
                    xmlout.Serialize(output, results);
                    output.Close();
                }

                ///
                /// Make sure the log file gets it done
                /// 

                logFile.Close();
            }
        }
Ejemplo n.º 2
0
        public void TestCStyleArrayBadIndexName()
        {
            // Simple set of types for an index array
            var vArray = new ItemCStyleArray("int[]", new ItemSimpleType("arr", "int"));
            vArray.Add(0, "i", false);
            var vIndex = new ItemSimpleType("n", "int");
            FileInfo proxyFile = new FileInfo("TestCStyleArray.cpp");
            using (var writer = proxyFile.CreateText())
            {
                writer.WriteLine();
                writer.Close();
            }
            ROOTClassShell mainClass = new ROOTClassShell("TestSimpleRename") { NtupleProxyPath = proxyFile.FullName };
            mainClass.Add(vIndex);
            mainClass.Add(vArray);
            var ntup = new NtupleTreeInfo() { Classes = new ROOTClassShell[] { mainClass }, ClassImplimintationFiles = new string[0] };

            var userinfo = new TTreeUserInfo()
            {
                Groups = new ArrayGroup[] { new ArrayGroup() {
                Name = "ungrouped",
                Variables = new VariableInfo[] {
                    new VariableInfo() { NETName = "n", TTreeName = "n" },
                    new VariableInfo() { NETName = "arr", TTreeName = "arr"}
                } } }
            };

            var cg = new ClassGenerator();
            var outputFile = new FileInfo("TestCStyleArray.cs");
            cg.GenerateClasss(ntup, outputFile, "junk", new Dictionary<string, TTreeUserInfo>() { { "TestSimpleRename", userinfo } });
        }
Ejemplo n.º 3
0
        public void TestDuplicateClassNames()
        {
            var vIndex = new ItemSimpleType("n", "int");
            FileInfo proxyFile = new FileInfo("TestCStyleArray.cpp");
            using (var writer = proxyFile.CreateText())
            {
                writer.WriteLine();
                writer.Close();
            }
            ROOTClassShell mainClass = new ROOTClassShell("TestSimpleRename") { NtupleProxyPath = proxyFile.FullName };
            mainClass.Add(vIndex);

            ROOTClassShell mainClass1 = new ROOTClassShell("TestSimpleRename") { NtupleProxyPath = proxyFile.FullName };
            mainClass1.Add(vIndex);
            var ntup = new NtupleTreeInfo() { Classes = new ROOTClassShell[] { mainClass, mainClass1 }, ClassImplimintationFiles = new string[0] };

            var userinfo = new TTreeUserInfo()
            {
                Groups = new ArrayGroup[] { new ArrayGroup() {
                Name = "ungrouped",
                Variables = new VariableInfo[] {
                    new VariableInfo() { NETName = "n", TTreeName = "n" },
                } } }
            };

            var cg = new ClassGenerator();
            var outputFile = new FileInfo("TestDuplicateClassNames.cs");
            cg.GenerateClasss(ntup, outputFile, "junk", new Dictionary<string, TTreeUserInfo>() { { "TestDuplicateClassNames", userinfo } });
        }
Ejemplo n.º 4
0
        public void TestRenamedIndex()
        {
            /// Create simple user info - but don't do anything with it!
            ItemSimpleType simpleIndex = new ItemSimpleType("index", "int[]");
            ItemSimpleType simpleVal = new ItemSimpleType("var1", "float[]");
            FileInfo proxyFile = new FileInfo("TestRenamedIndex.cpp");
            using (var writer = proxyFile.CreateText())
            {
                writer.WriteLine();
                writer.Close();
            }
            ROOTClassShell mainClass = new ROOTClassShell("TestRenamedIndex") { NtupleProxyPath = proxyFile.FullName };
            mainClass.Add(simpleIndex);
            mainClass.Add(simpleVal);
            var ntup = new NtupleTreeInfo() { Classes = new ROOTClassShell[] { mainClass }, ClassImplimintationFiles = new string[0] };

            var userinfo = new TTreeUserInfo()
            {
                Groups = new ArrayGroup[] {
                    new ArrayGroup()
                    {
                        Name = "jets", Variables = new VariableInfo[]
                        {
                            new VariableInfo() { NETName = "muons", TTreeName = "index", IndexToGroup="muons" }
                        }
                    },
                    new ArrayGroup()
                    {
                        Name = "muons", Variables = new VariableInfo[]
                        {
                            new VariableInfo() { NETName = "var1", TTreeName = "var1"}
                        }
                    }
                }
            };

            var cg = new ClassGenerator();
            var outputFile = new FileInfo("TestRenamedIndex.cs");
            cg.GenerateClasss(ntup, outputFile, "junk", new Dictionary<string, TTreeUserInfo>() { { "TestRenamedIndex", userinfo } });

            DumpOutputFile(outputFile);

            /// Look through this to see if we can make sure there are no renames!
            Assert.IsTrue(FindInFile(outputFile, "TTreeVariableGrouping"), "Missing TTreeVariableGrouping");
            Assert.IsTrue(FindInFile(outputFile, "jets"), "missing a reference to jets");
            Assert.IsTrue(FindInFile(outputFile, "muons"), "missing a reference to jets");
            Assert.IsTrue(FindInFile(outputFile, "IndexToOtherObjectArray(typeof("), "Missing IndexToOtherObject");
            Assert.IsTrue(FindInFile(outputFile, "TestRenamedIndexmuons muons"), "Muon reference is imporper");
            Assert.IsTrue(FindInFile(outputFile, "float var1"), "var1 missing");
            Assert.IsFalse(FindInFile(outputFile, "ungrouped"), "group found");
        }
Ejemplo n.º 5
0
        public void TestConstCStyleArray()
        {
            // Simple set of types for an index array
            var vArray = new ItemCStyleArray("int[]", new ItemSimpleType("arr", "int"));
            vArray.Add(0, "10", true);
            var vIndex = new ItemSimpleType("n", "int");
            FileInfo proxyFile = new FileInfo("TestConstCStyleArray.cpp");
            using (var writer = proxyFile.CreateText())
            {
                writer.WriteLine();
                writer.Close();
            }

            ROOTClassShell mainClass = new ROOTClassShell("TestSimpleRename") { NtupleProxyPath = proxyFile.FullName };
            mainClass.Add(vIndex);
            mainClass.Add(vArray);
            var ntup = new NtupleTreeInfo() { Classes = new ROOTClassShell[] { mainClass }, ClassImplimintationFiles = new string[0] };

            var userinfo = new TTreeUserInfo()
            {
                Groups = new ArrayGroup[] { new ArrayGroup() {
                Name = "ungrouped",
                Variables = new VariableInfo[] {
                    new VariableInfo() { NETName = "n", TTreeName = "n" },
                    new VariableInfo() { NETName = "arr", TTreeName = "arr"}
                } } }
            };

            var cg = new ClassGenerator();
            var outputFile = new FileInfo("TestConstCStyleArray.cs");
            cg.GenerateClasss(ntup, outputFile, "junk", new Dictionary<string, TTreeUserInfo>() { { "TestSimpleRename", userinfo } });

            CopyToOutput(outputFile);

            /// Look through this to see if we can make sure there are no renames!
            Assert.IsTrue(FindInFile(outputFile, "int[] arr"), "Array Decl missing");
            Assert.IsTrue(FindInFile(outputFile, "int n"), "Index decl missing");
            Assert.IsTrue(FindInFile(outputFile, "[ArraySizeIndex(\"10\", IsConstantExpression = true, Index = 0)]"), "Missing array size index attribute");
        }
Ejemplo n.º 6
0
        public void GenerateClassFromClasses(
            ClassGenerator target,
            int outputChoice,
            int numExtraFiles,
            int numExtraFilesToCreate,
            int extraFileIndexNull,
            int proxyPathChoice,
            string nameSName,
            int NumObjectCollection)
        {
            if (numExtraFiles < 0
                || numExtraFilesToCreate < 0
                || extraFileIndexNull < 0
                || outputChoice < 0
                || proxyPathChoice < 0
                || NumObjectCollection < 0)
                return;

            ///
            /// Kill off the directory we might have left behind from a previous run, and create a new one.
            /// 

            DirectoryInfo testDir = new DirectoryInfo(".\\GenerateClassFromClasses");
            if (testDir.Exists)
            {
                testDir.Delete(true);
            }
            testDir.Create();

            ///
            /// Setup the input stuff so Pex can play
            /// 

            FileInfo outputCSFile;
            if (outputChoice == 1)
            {
                outputCSFile = new FileInfo(testDir.FullName + "\\output.cs");
            }
            else
            {
                outputCSFile = null;
            }

            ROOTClassShell[] objCollect = null;
            if (NumObjectCollection > 0)
            {
                List<ROOTClassShell> objs = new List<ROOTClassShell>();

                for (int i = 0; i < NumObjectCollection; i++)
                {
                    ROOTClassShell rcs = new ROOTClassShell();
                    rcs.Name = "dude_" + i.ToString();

                    for (int j = 0; j < i; j++)
                    {
                        IClassItem item = null;
                        switch (NumObjectCollection % 4)
                        {
                            case 0:
                                item = null;
                                break;

                            case 1:
                                var itm = new ItemSimpleType() { ItemType = "int" };
                                item = itm;
                                break;

                            case 2:
                                var itmv = new ItemVector() { ItemType = "int[]" };
                                item = itmv;
                                break;

                            case 3:
                                var itmr = new ItemROOTClass() { ItemType = "TLorentzVector" };
                                item = itmr;
                                break;
                        }
                        if (item != null)
                            item.Name = "item_" + j.ToString();
                        rcs.Items.Add(item);
                    }
                    objs.Add(rcs);
                }

                if (NumObjectCollection > 0)
                {
                    if (proxyPathChoice == 1)
                    {
                        var proxyFile = new FileInfo(testDir.FullName + "\\GenerateClassFromClasses_" + proxyPathChoice.ToString() + ".h");
                        using (var w = proxyFile.CreateText())
                        {
                            w.WriteLine("hi");
                            w.Close();
                        }
                        objs[0].NtupleProxyPath = proxyFile.FullName;
                    }

                    if (proxyPathChoice == 2)
                    {
                        var proxyFile = new FileInfo(testDir.FullName + "\\GenerateClassFromClasses_" + proxyPathChoice.ToString() + ".h");
                        objs[0].NtupleProxyPath = proxyFile.FullName;
                    }

                    if (proxyPathChoice == 3)
                    {
                        var proxyFile = new FileInfo(testDir.FullName + "\\GenerateClassFromClasses_" + proxyPathChoice.ToString() + ".h");
                        using (var w = proxyFile.CreateText())
                        {
                            w.WriteLine("hi");
                            w.Close();
                        }
                        foreach (var item in objs)
                        {
                            item.NtupleProxyPath = proxyFile.FullName;
                        }
                    }
                }
                objCollect = objs.ToArray();
            }

            ///
            /// Create the final object, and any extra files needed!
            /// 

            NtupleTreeInfo info = new NtupleTreeInfo() { Classes = objCollect };

            info.ClassImplimintationFiles = (from c in Enumerable.Range(0, numExtraFiles)
                                             let f = new FileInfo(testDir.FullName + "\\GenerateClassFromClasses_extra_" + c.ToString() + ".cpp")
                                             select f.FullName
                                                 ).ToArray();

            int maxFilesToCreate = numExtraFilesToCreate > numExtraFiles ? numExtraFiles : numExtraFilesToCreate;
            for (int i = 0; i < maxFilesToCreate; i++)
            {
                using (var w = File.CreateText(info.ClassImplimintationFiles[i]))
                {
                    w.WriteLine();
                    w.Close();
                }
            }

            if (extraFileIndexNull < numExtraFiles)
            {
                info.ClassImplimintationFiles[extraFileIndexNull] = null;
            }

            ///
            /// Ok, do the investigation
            /// 

            target.GenerateClasss(info, outputCSFile, nameSName);

            Assert.IsFalse(info.Classes.Any(c => c.NtupleProxyPath == null), "No null proxy paths allowed");
            Assert.IsFalse(info.Classes.Any(c => !File.Exists(c.NtupleProxyPath)), "proxy files must exist");

            Assert.IsFalse(info.ClassImplimintationFiles.Any(c => c == null), "no null implementation files allowed");
            Assert.IsFalse(info.ClassImplimintationFiles.Any(c => !File.Exists(c)), "all implimntation files must exist");

            /// Check that all the ntuple proxy guys and the temp file guys appear in the file

            foreach (var item in info.Classes.Where(c => c.IsTopLevelClass))
            {
                Assert.IsTrue(FindInFile(outputCSFile, item.NtupleProxyPath), "Could not find the proxy path '" + item.NtupleProxyPath + "'");
            }
            foreach (var item in info.ClassImplimintationFiles)
            {
                Assert.IsTrue(FindInFile(outputCSFile, item), "coul dnot find impl file '" + item + "'");
            }
        }
Ejemplo n.º 7
0
        public void TestNonIntIndex()
        {
            /// Create simple user info - but don't do anything with it!
            ItemSimpleType simpleIndex = new ItemSimpleType("index", "float[]");
            ItemSimpleType simpleVal = new ItemSimpleType("var1", "float[]");
            FileInfo proxyFile = new FileInfo("TestNonIntIndex.cpp");
            using (var writer = proxyFile.CreateText())
            {
                writer.WriteLine();
                writer.Close();
            }
            ROOTClassShell mainClass = new ROOTClassShell("TestNonIntIndex") { NtupleProxyPath = proxyFile.FullName };
            mainClass.Add(simpleIndex);
            mainClass.Add(simpleVal);
            var ntup = new NtupleTreeInfo() { Classes = new ROOTClassShell[] { mainClass }, ClassImplimintationFiles = new string[0] };

            var userinfo = new TTreeUserInfo()
            {
                Groups = new ArrayGroup[] {
                    new ArrayGroup()
                    {
                        Name = "jets", Variables = new VariableInfo[]
                        {
                            new VariableInfo() { NETName = "index", TTreeName = "index", IndexToGroup="muons" }
                        }
                    },
                    new ArrayGroup()
                    {
                        Name = "muons", Variables = new VariableInfo[]
                        {
                            new VariableInfo() { NETName = "var1", TTreeName = "var1"}
                        }
                    }
                }
            };

            var cg = new ClassGenerator();
            var outputFile = new FileInfo("TestNonIntIndex.cs");
            cg.GenerateClasss(ntup, outputFile, "junk", new Dictionary<string, TTreeUserInfo>() { { "TestNonIntIndex", userinfo } });
        }
Ejemplo n.º 8
0
        public void TestSimpleGroupWithCustomClassName()
        {
            /// Create simple user info - but don't do anything with it!
            ItemSimpleType simple = new ItemSimpleType("var1", "int[]");
            FileInfo proxyFile = new FileInfo("TestSimpleGroupAndRename.cpp");
            using (var writer = proxyFile.CreateText())
            {
                writer.WriteLine();
                writer.Close();
            }
            ROOTClassShell mainClass = new ROOTClassShell("TestSimpleGroupAndRename") { NtupleProxyPath = proxyFile.FullName };
            mainClass.Add(simple);
            var ntup = new NtupleTreeInfo() { Classes = new ROOTClassShell[] { mainClass }, ClassImplimintationFiles = new string[0] };

            var userinfo = new TTreeUserInfo() { Groups = new ArrayGroup[] { new ArrayGroup() { Name = "jets", ClassName = "Jet", Variables = new VariableInfo[] { new VariableInfo() { NETName = "myvar", TTreeName = "var1" } } } } };

            var cg = new ClassGenerator();
            var outputFile = new FileInfo("TestSimpleGroupAndRename.cs");
            cg.GenerateClasss(ntup, outputFile, "junk", new Dictionary<string, TTreeUserInfo>() { { "TestSimpleGroupAndRename", userinfo } });

            DumpOutputFile(outputFile);

            /// Look through this to see if we can make sure there are no renames!
            Assert.IsTrue(FindInFile(outputFile, "RenameVariable(\"var1\")"), "Rename missing!");
            Assert.IsTrue(FindInFile(outputFile, "TTreeVariableGrouping"), "Missing TTreeVariableGrouping");
            Assert.IsTrue(FindInFile(outputFile, "jets"), "missing a reference to jets");
            Assert.IsTrue(FindInFile(outputFile, "int myvar"), "myvar missing");
            Assert.IsTrue(FindInFile(outputFile, "int[] var1"), "val1 missing");
            Assert.IsFalse(FindInFile(outputFile, "ungrouped"), "group found");
            Assert.IsFalse(FindInFile(outputFile, "TestSimpleGroupAndRenamejets"), "Found the non-class name default class name");
            Assert.IsTrue(FindInFile(outputFile, "Jet"), "Did not find the Jet custom class name");
        }
Ejemplo n.º 9
0
        public void TestCharactersInClassName()
        {
            ItemSimpleType simple = new ItemSimpleType("fork", "int");
            FileInfo proxyFile = new FileInfo("TestColonsInVarName.cpp");
            using (var writer = proxyFile.CreateText())
            {
                writer.WriteLine();
                writer.Close();
            }

            ROOTClassShell mainClass = new ROOTClassShell("##Shapes") { NtupleProxyPath = proxyFile.FullName };
            mainClass.Add(simple);
            var ntup = new NtupleTreeInfo() { Classes = new ROOTClassShell[] { mainClass }, ClassImplimintationFiles = new string[0] };

            var userinfo = new TTreeUserInfo() { Groups = new ArrayGroup[] { new ArrayGroup() { Name = "jets", Variables = new VariableInfo[] { new VariableInfo() { NETName = "fork", TTreeName = "fork" } } } } };

            var cg = new ClassGenerator();
            var outputFile = new FileInfo("TestCharactersInClassName.cs");
            cg.GenerateClasss(ntup, outputFile, "junk", new Dictionary<string, TTreeUserInfo>() { { "TestSimpleGroupAndRename", userinfo } });

            DumpOutputFile(outputFile);

            Assert.AreEqual(3, CountInFile(outputFile, "##Shapes"), "Missing reference ot the shapes object");
        }
Ejemplo n.º 10
0
        public void TestColonsInVarName()
        {
            ItemSimpleType simple = new ItemSimpleType("dude::fork", "int[]");
            FileInfo proxyFile = new FileInfo("TestColonsInVarName.cpp");
            using (var writer = proxyFile.CreateText())
            {
                writer.WriteLine();
                writer.Close();
            }

            ROOTClassShell mainClass = new ROOTClassShell("TestSimpleGroupAndRename") { NtupleProxyPath = proxyFile.FullName };
            mainClass.Add(simple);
            var ntup = new NtupleTreeInfo() { Classes = new ROOTClassShell[] { mainClass }, ClassImplimintationFiles = new string[0] };

            var userinfo = new TTreeUserInfo() { Groups = new ArrayGroup[] { new ArrayGroup() { Name = "jets", Variables = new VariableInfo[] { new VariableInfo() { NETName = "dude::fork", TTreeName = "dude::fork" } } } } };

            var cg = new ClassGenerator();
            var outputFile = new FileInfo("TestSimpleGroupAndRename.cs");
            cg.GenerateClasss(ntup, outputFile, "junk", new Dictionary<string, TTreeUserInfo>() { { "TestSimpleGroupAndRename", userinfo } });

            DumpOutputFile(outputFile);

            /// Look through this to see if we can make sure there are no renames!
            Assert.IsFalse(FindInFile(outputFile, "dude::fork"), "Saw the double colon!!");
            Assert.IsTrue(FindInFile(outputFile, "dude__fork"), "Missing the variable!!");
        }
Ejemplo n.º 11
0
        public void GroupWithArrayLengthSpecification()
        {
            ItemSimpleType simple1 = new ItemSimpleType("avar", "int[]");
            ItemSimpleType simple2 = new ItemSimpleType("bvar", "int[]");
            FileInfo proxyFile = new FileInfo("TestColonsInVarNameWRename.cpp");
            using (var writer = proxyFile.CreateText())
            {
                writer.WriteLine();
                writer.Close();
            }

            ROOTClassShell mainClass = new ROOTClassShell("GroupWithArrayLengthSpecification") { NtupleProxyPath = proxyFile.FullName };
            mainClass.Add(simple1);
            mainClass.Add(simple2);
            var ntup = new NtupleTreeInfo() { Classes = new ROOTClassShell[] { mainClass }, ClassImplimintationFiles = new string[0] };

            var userinfo = new TTreeUserInfo() { Groups = new ArrayGroup[] {
                new ArrayGroup() {
                    Name = "jets",
                    NETNameOfVariableToUseAsArrayLength ="b",
                    Variables = new VariableInfo[] {
                        new VariableInfo() { NETName = "a", TTreeName = "avar" },
                        new VariableInfo() { NETName = "b", TTreeName = "bvar" },
                    }
                } } };

            var cg = new ClassGenerator();
            var outputFile = new FileInfo("GroupWithArrayLengthSpecification.cs");
            cg.GenerateClasss(ntup, outputFile, "junk", new Dictionary<string, TTreeUserInfo>() { { "GroupWithArrayLengthSpecification", userinfo } });

            DumpOutputFile(outputFile);

            /// Look through this to see if we can make sure there are no renames!
            Assert.IsTrue(FindInFile(outputFile, "UseAsArrayLength"), "Missing the UseAsArrayLength attribute!!");
        }
Ejemplo n.º 12
0
        public void TestNoGroups()
        {
            /// Create simple user info - but don't do anything with it!
            ItemSimpleType simple = new ItemSimpleType("var1", "int[]");
            Assert.IsFalse(simple.NotAPointer, "not a pointer");
            FileInfo proxyFile = new FileInfo("TestNoGroupsProxy.cpp");
            using (var writer = proxyFile.CreateText())
            {
                writer.WriteLine();
                writer.Close();
            }
            ROOTClassShell mainClass = new ROOTClassShell("TestSimpleRename") { NtupleProxyPath = proxyFile.FullName };
            mainClass.Add(simple);
            var ntup = new NtupleTreeInfo() { Classes = new ROOTClassShell[] { mainClass }, ClassImplimintationFiles = new string[0] };

            var userinfo = new TTreeUserInfo() { Groups = new ArrayGroup[] { new ArrayGroup() { Name = "ungrouped", Variables = new VariableInfo[] { new VariableInfo() { NETName = "var1", TTreeName = "var1" } } } } };

            var cg = new ClassGenerator();
            var outputFile = new FileInfo("TestNoGroups.cs");
            cg.GenerateClasss(ntup, outputFile, "junk", new Dictionary<string, TTreeUserInfo>() { { "TestSimpleRename", userinfo } });

            /// Look through this to see if we can make sure there are no renames!
            Assert.IsFalse(FindInFile(outputFile, "RenameVariable"), "We saw a rename!");
            Assert.IsFalse(FindInFile(outputFile, "ungrouped"), "group found");
        }