bool TryParseVersionAndPackage(LoopState loopState, out VersionRange snippetVersion, out string error) { snippetVersion = null; if (loopState.Version == null) { snippetVersion = fileVersion; error = null; return(true); } VersionRange version; if (VersionRangeParser.TryParseVersion(loopState.Version, out version)) { if (fileVersion.IsPreRelease()) { error = $"Could not use '{loopState.Version}' since directory is flagged as Prerelease. FileVersion: {fileVersion.ToFriendlyString()}."; return(false); } snippetVersion = version; error = null; return(true); } error = $"Expected '{loopState.Version}' to be parsable as a version."; return(false); }