public List <Snippet> FromText(string contents) { var extractor = FileSnippetExtractor.Build(VersionRange.All, "package", false); using (var stringReader = new StringReader(contents)) { return(extractor.AppendFromReader(stringReader, "path.cs").ToList()); } }
void ReadingFiles() { #region ReadingFiles var files = Directory.EnumerateFiles(@"C:\path", "*.cs", SearchOption.AllDirectories); var snippetExtractor = FileSnippetExtractor.Build( fileVersion: VersionRange.Parse("[1.1,2.0)"), package: "ThePackageName", isCurrent: true); var snippets = snippetExtractor.Read(files); #endregion }
public void CanExtractVersionFromFile() { var input = @" <!-- startcode CodeKey --> <configSections/> <!-- endcode -->"; using (var stringReader = new StringReader(input)) { var versionRange = new VersionRange(new NuGetVersion(1, 1, 0)); var extractor = FileSnippetExtractor.Build(versionRange, "package", false); var snippets = extractor.AppendFromReader(stringReader, "path.cs").ToList(); ObjectApprover.VerifyWithJson(snippets.Single()); } }