public void TestVisitSystemElementsCount()
        {
            MCSElementVisitor sv = new MCSElementVisitor();
            Mono.CSharp.ClassB someClass = new Mono.CSharp.ClassB();

            MCSClassElement se = new MCSClassElement("name", someClass);
            se.Visit(sv);

            Assert.AreEqual(6, sv.SystemElementsCount);
        }
Esempio n. 2
0
        public void TestMethod1()
        {
            Stream outputStream = File.OpenWrite("C:\\xml_output.xml");
            XMLFormatBuilder xmlBuilder = new XMLFormatBuilder(outputStream);
            FormatTextVisitor ftv = new FormatTextVisitor(xmlBuilder, null);
            xmlBuilder.WriteStartDocument();
            string _pathToTests = System.Reflection.Assembly.GetExecutingAssembly().Location;
            _pathToTests = System.IO.Path.GetDirectoryName(_pathToTests);

            string _dmcsAssemblyFullPath = System.IO.Path.Combine(_pathToTests, "dmcs.exe");

            MCSCompiler compiler = new MCSCompiler(_dmcsAssemblyFullPath, new EmptyReportPrinter());
            compiler.Compile(_pathToTests + @"\Testdata\FileWithValidSouceCode.cs");

            MCSClassElement se = new MCSClassElement("root", compiler.TreeRoot);
            se.Visit(ftv);
            xmlBuilder.WriteEndDocument();
            xmlBuilder.Close();
            outputStream.Close();
        }
        public override void Process(SourceCodeProject project)
        {
            MCSCompiler compiler = new MCSCompiler(Utils.GetDmcsAssemblyPath(), _reporter);
            if (!compiler.SuccessfulCreated)
            {
                return;
            }

            _formatter.WriteStartDocument();
            _formatter.WriteStartCustomElement("Project", "Name", project.Name);

            int filesProcessed = 0;

            DoProgress(0);

            foreach (SourceFile file in project)
            {
                if (!compiler.Compile(file.FileFullPath))
                {
                    continue;
                }

                FormatTextVisitor visitor = new FormatTextVisitor(_formatter, _processors);

                _formatter.WriteStartCustomElement("SourceFile", "Name", file.PathInProject);

                MCSClassElement root = new MCSClassElement("Root", compiler.TreeRoot);
                root.Visit(visitor);

                _formatter.WriteEndElement();

                filesProcessed++;

                DoProgress(filesProcessed * 100 / project.FilesCount);
            }

            _formatter.WriteEndElement();
            _formatter.WriteEndDocument();
        }