GenerateSrcMLFromFile() public method

Generate a SrcML document from a single source file. The language will be inferred from the extension.
public GenerateSrcMLFromFile ( string sourceFileName, string xmlFileName ) : void
sourceFileName string The path of the source file to convert.
xmlFileName string The file name to write the resulting XML to.
return void
Ejemplo n.º 1
0
        public void TestCSharpUsingStatement() {
            var generator = new SrcMLGenerator(TestConstants.SrcmlPath);
            generator.GenerateSrcMLFromFile("external\\TestCSharpUsingStatement.cs", "external_xml\\TestCSharpUsingStatement.cs.xml");
            var fileUnit = SrcMLElement.Load("external_xml\\TestCSharpUsingStatement.cs.xml");

            var usingBlock = fileUnit.Elements(SRC.Using).FirstOrDefault();
            Assert.IsNotNull(usingBlock);

            Assert.AreEqual(1, usingBlock.Elements(SRC.Declaration).Count());
            Assert.AreEqual(1, usingBlock.Elements(SRC.Block).Count());
        }
Ejemplo n.º 2
0
 public void TestCppStaticTypeModifier() {
     var generator = new SrcMLGenerator(TestConstants.SrcmlPath);
     generator.GenerateSrcMLFromFile("external\\TestCppTypeModifiers.cpp", "external_xml\\TestCppStaticModifier.cpp.xml");
     var fileUnit = SrcMLElement.Load("external_xml\\TestCppStaticModifier.cpp.xml");
     var typeWithStatic = fileUnit.Descendants(SRC.Type).LastOrDefault();
     Assert.IsNotNull(typeWithStatic);
     var staticModifier = typeWithStatic.Elements(SRC.Specifier).FirstOrDefault();
     Assert.IsNotNull(staticModifier);
     Assert.AreEqual("static", staticModifier.Value);
 }
Ejemplo n.º 3
0
        public void TestCSharpExpressionWithRemove() {
            var generator = new SrcMLGenerator(TestConstants.SrcmlPath);
            generator.GenerateSrcMLFromFile("external\\TestCSharpExpressionWithRemove.cs", "external_xml\\TestCSharpExpressionWithRemove.cs.xml");
            var fileUnit = SrcMLElement.Load("external_xml\\TestCSharpExpressionWithRemove.cs.xml");

            var method = fileUnit.Descendants(SRC.Function).FirstOrDefault();
            Assert.IsNotNull(method);
            var methodBlock = method.Element(SRC.Block);
            Assert.IsNotNull(methodBlock);
            Assert.AreEqual(1, methodBlock.Elements(SRC.ExpressionStatement).Count());
        }
Ejemplo n.º 4
0
 public void TestCSharpExpressionWithDefaultKeyword() {
     var generator = new SrcMLGenerator(TestConstants.SrcmlPath);
     generator.GenerateSrcMLFromFile("external\\TestCSharpExpressionWithDefaultKeyword.cs", "external_xml\\TestCSharpExpressionWithDefaultKeyword.cs.xml");
     var fileUnit = SrcMLElement.Load("external_xml\\TestCSharpExpressionWithDefaultKeyword.cs.xml");
     var classB = fileUnit.Element(SRC.Class);
     Assert.IsNotNull(classB);
     Assert.AreEqual(2, classB.Descendants(SRC.Function).Count());
 }
Ejemplo n.º 5
0
        public void TestCSharpUsingStatement() {
            var generator = new SrcMLGenerator(Path.Combine(SrcMLHelper.GetSrcMLRootDirectory(), SrcMLHelper.srcMLExecutableLocation));
            generator.GenerateSrcMLFromFile("external\\TestCSharpUsingStatement.cs", "external_xml\\TestCSharpUsingStatement.cs.xml");
            var fileUnit = SrcMLElement.Load("external_xml\\TestCSharpUsingStatement.cs.xml");

            var usingBlock = fileUnit.Elements(SRC.Using_Stmt).FirstOrDefault();
            Assert.IsNotNull(usingBlock);

            Assert.AreEqual(1, usingBlock.Elements(SRC.Init).Count());
            Assert.AreEqual(1, usingBlock.Elements(SRC.Block).Count());
        }
Ejemplo n.º 6
0
        public void TestCSharpExpressionWithRemove() {
            var generator = new SrcMLGenerator(Path.Combine(SrcMLHelper.GetSrcMLRootDirectory(), SrcMLHelper.srcMLExecutableLocation));
            generator.GenerateSrcMLFromFile("external\\TestCSharpExpressionWithRemove.cs", "external_xml\\TestCSharpExpressionWithRemove.cs.xml");
            var fileUnit = SrcMLElement.Load("external_xml\\TestCSharpExpressionWithRemove.cs.xml");

            var method = fileUnit.Descendants(SRC.Function).FirstOrDefault();
            Assert.IsNotNull(method);
            var methodBlock = method.Element(SRC.Block);
            Assert.IsNotNull(methodBlock);
            Assert.AreEqual(1, methodBlock.Elements(SRC.ExpressionStatement).Count());
        }
Ejemplo n.º 7
0
 public void TestCppStaticTypeModifier() {
     var generator = new SrcMLGenerator(Path.Combine(SrcMLHelper.GetSrcMLRootDirectory(), SrcMLHelper.srcMLExecutableLocation));
     generator.GenerateSrcMLFromFile("external\\TestCppTypeModifiers.cpp", "external_xml\\TestCppStaticModifier.cpp.xml");
     var fileUnit = SrcMLElement.Load("external_xml\\TestCppStaticModifier.cpp.xml");
     var typeWithStatic = fileUnit.Descendants(SRC.Declaration).LastOrDefault();
     Assert.IsNotNull(typeWithStatic);
     var staticModifier = typeWithStatic.Elements(SRC.Specifier).FirstOrDefault();
     Assert.IsNotNull(staticModifier);
     Assert.AreEqual("static", staticModifier.Value);
 }
Ejemplo n.º 8
0
 public void TestCSharpExpressionWithDefaultKeyword() {
     var generator = new SrcMLGenerator(Path.Combine(SrcMLHelper.GetSrcMLRootDirectory(), SrcMLHelper.srcMLExecutableLocation));
     generator.GenerateSrcMLFromFile("external\\TestCSharpExpressionWithDefaultKeyword.cs", "external_xml\\TestCSharpExpressionWithDefaultKeyword.cs.xml");
     var fileUnit = SrcMLElement.Load("external_xml\\TestCSharpExpressionWithDefaultKeyword.cs.xml");
     var classB = fileUnit.Element(SRC.Class);
     Assert.IsNotNull(classB);
     Assert.AreEqual(2, classB.Descendants(SRC.Function).Count());
 }