コード例 #1
0
        public void SuccessfulCompileFile()
        {
            MCSCompiler compiler = new MCSCompiler(_dmcsAssemblyFullPath, new EmptyReportPrinter());

            bool compileResult = compiler.Compile(System.IO.Path.Combine(_pathToTestData, "FileWithValidSouceCode.cs"));

            Assert.IsTrue(compileResult);
        }
コード例 #2
0
        public void CreateCompilerFromInvalidAssembly()
        {
            bool isTestSuccessful = false;

            try
            {
                MCSCompiler compiler =
                    new MCSCompiler(_pathToTests + @"\ParseTree.exe", new EmptyReportPrinter());
            }
            catch
            {
                isTestSuccessful = true;
            }
            Assert.IsTrue(isTestSuccessful);
        }
コード例 #3
0
ファイル: SomeTest.cs プロジェクト: ifanatic/CSharpParseTree
        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();
        }
コード例 #4
0
        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();
        }
コード例 #5
0
        public void CreateCompilerFromValidAssembly()
        {
            MCSCompiler compiler = new MCSCompiler(_dmcsAssemblyFullPath, new EmptyReportPrinter());

            Assert.IsTrue(compiler.SuccessfulCreated);
        }