当前位置: 首页>>代码示例>>C#>>正文


C# LibSrcMLRunner.GenerateSrcMLFromFile方法代码示例

本文整理汇总了C#中LibSrcMLRunner.GenerateSrcMLFromFile方法的典型用法代码示例。如果您正苦于以下问题:C# LibSrcMLRunner.GenerateSrcMLFromFile方法的具体用法?C# LibSrcMLRunner.GenerateSrcMLFromFile怎么用?C# LibSrcMLRunner.GenerateSrcMLFromFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LibSrcMLRunner的用法示例。


在下文中一共展示了LibSrcMLRunner.GenerateSrcMLFromFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestDataFileNameMap

        public void TestDataFileNameMap(bool compressionEnabled) {
            //I'm not exactly sure what this test is testing for, but the way files are named by the library
            //is not playing well with this test. Seems like it wants a specific file extension. Some decision
            //will have to be made about how to handle this problem. Does the library need to generate names differently?
            //Or maybe this test should be different?
            var generator = new DataGenerator();
            var mapping = new DataFileNameMapping(TEST_DIRECTORY, compressionEnabled);
            var sourcePath = @"..\..\TestInputs\function_def.cpp";
            var srcmlPath = @"..\..\TestInputs\function_def.xml";

            var mappedPath = mapping.GetTargetPath(sourcePath);

            var actualExtension = Path.GetExtension(mappedPath);
            var expectedExtension = (compressionEnabled ? XmlSerialization.DEFAULT_COMPRESSED_EXTENSION : XmlSerialization.DEFAULT_EXTENSION);
            StringAssert.AreEqualIgnoringCase(expectedExtension, actualExtension);

            //generator.Generate(srcmlPath, mappedPath);
            LibSrcMLRunner runner = new LibSrcMLRunner();
            runner.GenerateSrcMLFromFile(srcmlPath, mappedPath, Language.CPlusPlus, new Collection<uint> { LibSrcMLRunner.SrcMLOptions.SRCML_OPTION_POSITION }, new Dictionary<string, Language> { });


            Assert.That(File.Exists(mappedPath), String.Format("Could not generate {0}", mappedPath));

            var data = XmlSerialization.Load(mappedPath, compressionEnabled);
            Assert.IsNotNull(data, String.Format("Could not load data from {0}. It should {1}be compressed", mappedPath, compressionEnabled ? String.Empty : "not "));
        }
开发者ID:cnewman,项目名称:SrcML.NET,代码行数:26,代码来源:DataFileNameMappingTests.cs

示例2: TestRoundTrip

        public void TestRoundTrip(string sourceFileName, bool compressOutput) {
            var sourceFilePath = Path.Combine(TestInputPath, sourceFileName);
            var destFilePath = Path.Combine(TestInputPath, DefaultInputName);

            LibSrcMLRunner runner = new LibSrcMLRunner();
            runner.GenerateSrcMLFromFile(sourceFilePath, destFilePath + ".cpp", Language.CPlusPlus, new Collection<UInt32>() { LibSrcMLRunner.SrcMLOptions.SRCML_OPTION_POSITION }, new Dictionary<string, Language>() { });
            Assert.That(File.Exists(destFilePath + ".cpp0.xml"));

            var fileUnit = SrcMLElement.Load(destFilePath + ".cpp0.xml");
            var dataGenerator = new DataGenerator();
            var nsd = dataGenerator.Parse(fileUnit.Element(SRC.Unit)) as NamespaceDefinition;

            XmlSerialization.WriteElement(nsd, DefaultOutputName, compressOutput);
            var nsdFromFile = XmlSerialization.Load(DefaultOutputName, compressOutput) as NamespaceDefinition;
            DataAssert.StatementsAreEqual(nsd, nsdFromFile);
        }
开发者ID:cnewman,项目名称:SrcML.NET,代码行数:16,代码来源:SerializationTests.cs


注:本文中的LibSrcMLRunner.GenerateSrcMLFromFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。