本文整理汇总了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 "));
}
示例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);
}