private string VerifyAndResolveVersion(string version) { if (string.IsNullOrEmpty(version)) { return(_scriptGeneratorOptions.DefaultVersion); } else { var maxSatisfyingVersion = SemanticVersionResolver.GetMaxSatisfyingVersion( version, _versionProvider.SupportedDotNetCoreVersions); if (string.IsNullOrEmpty(maxSatisfyingVersion)) { var exc = new UnsupportedVersionException( DotNetCoreConstants.LanguageName, version, _versionProvider.SupportedDotNetCoreVersions); _logger.LogError(exc, "Exception caught"); throw exc; } return(maxSatisfyingVersion); } }
public override void Validate(ID3Versions version) { base.Validate(version); Exception innerException = null; if (version != ID3Versions.V2_4 && version != ID3Versions.V2_3) { innerException = new UnsupportedVersionException(version); } else { try { description.Validate(version); } catch (IOValidationException ex) { innerException = ex; } } if (innerException != null) { throw new FrameValidationException("Validation failed.", this, innerException); } }
private string VerifyAndResolveVersion(string version) { // Get the versions either from disk or on the web var versionInfo = _versionProvider.GetVersionInfo(); // Get the default version. This could be having just the major or major.minor version. // So try getting the latest version of the default version. if (string.IsNullOrEmpty(version)) { version = versionInfo.DefaultVersion; } var maxSatisfyingVersion = SemanticVersionResolver.GetMaxSatisfyingVersion( version, versionInfo.SupportedVersions); if (string.IsNullOrEmpty(maxSatisfyingVersion)) { var exc = new UnsupportedVersionException( PythonConstants.PythonName, version, versionInfo.SupportedVersions); _logger.LogError( exc, $"Exception caught, the version '{version}' is not supported for the Python platform."); throw exc; } return(maxSatisfyingVersion); }
private string DetectNodeVersion(dynamic packageJson) { var nodeVersionRange = packageJson?.engines?.node?.Value as string; // Get the default version. This could be having just the major or major.minor version. // So try getting the maximum satisfying version of the default version. var versionInfo = _versionProvider.GetVersionInfo(); if (string.IsNullOrEmpty(nodeVersionRange)) { nodeVersionRange = versionInfo.DefaultVersion; } var maxSatisfyingVersion = SemanticVersionResolver.GetMaxSatisfyingVersion( nodeVersionRange, versionInfo.SupportedVersions); if (string.IsNullOrEmpty(maxSatisfyingVersion)) { var exception = new UnsupportedVersionException( NodeConstants.NodeJsName, nodeVersionRange, versionInfo.SupportedVersions); _logger.LogError( exception, $"Exception caught, the version '{nodeVersionRange}' is not supported for the Node platform."); throw exception; } return(maxSatisfyingVersion); }
public override void Validate(ID3Versions version) { base.Validate(version); Exception innerException = null; if ((version & ID3Versions.V2) != ID3Versions.V2) { innerException = new UnsupportedVersionException(version); } else if (description.TextEncodingType != base.EncodedText.TextEncodingType) { innerException = new InvalidTextEncodingTypeException( "URL not set with required TextEncodingType.", description.TextEncodingType); } else { try { description.Validate(version); } catch (IOValidationException ex) { innerException = ex; } } if (innerException != null) { throw new FrameValidationException("Validation failed.", this, innerException); } }
public override void Validate(ID3Versions version) { Exception innerException = null; if ((version & ID3Versions.V2) != ID3Versions.V2) { innerException = new UnsupportedVersionException(version); } else if (url.TextEncodingType != URLLinkFrame.UrlEncodingType) { innerException = new InvalidTextEncodingTypeException( "URL not set with required TextEncodingType.", url.TextEncodingType); } else { try { url.Validate(version); } catch (IOValidationException ex) { innerException = ex; } } if (innerException != null) { throw new FrameValidationException("Validation failed.", this, innerException); } }
public override void Validate(ID3Versions version) { Exception innerException = null; if ((version & ID3Versions.V2) != ID3Versions.V2) { innerException = new UnsupportedVersionException(version); } else { try { text.Validate(version); } catch (IOValidationException ex) { innerException = ex; } } if (innerException != null) { throw new FrameValidationException("Validation failed.", this, innerException); } }
private string DetectNodeVersion(dynamic packageJson) { var nodeVersionRange = packageJson?.engines?.node?.Value as string; if (nodeVersionRange == null) { nodeVersionRange = _nodeScriptGeneratorOptions.NodeJsDefaultVersion; } string nodeVersion = null; if (!string.IsNullOrWhiteSpace(nodeVersionRange)) { nodeVersion = SemanticVersionResolver.GetMaxSatisfyingVersion( nodeVersionRange, _nodeVersionProvider.SupportedNodeVersions); if (string.IsNullOrWhiteSpace(nodeVersion)) { var exc = new UnsupportedVersionException( $"Target Node.js version '{nodeVersionRange}' is unsupported. " + $"Supported versions are: {string.Join(", ", _nodeVersionProvider.SupportedNodeVersions)}"); _logger.LogError(exc, "Exception caught"); throw exc; } } return(nodeVersion); }
private string DetectNodeVersion(dynamic packageJson) { var nodeVersionRange = packageJson?.engines?.node?.Value as string; if (nodeVersionRange == null) { nodeVersionRange = _nodeScriptGeneratorOptions.NodeJsDefaultVersion; } string nodeVersion = null; if (!string.IsNullOrWhiteSpace(nodeVersionRange)) { nodeVersion = SemanticVersionResolver.GetMaxSatisfyingVersion( nodeVersionRange, _versionProvider.SupportedNodeVersions); if (string.IsNullOrWhiteSpace(nodeVersion)) { var exc = new UnsupportedVersionException( NodeConstants.NodeJsName, nodeVersionRange, _versionProvider.SupportedNodeVersions); _logger.LogError(exc, $"Exception caught, the version '{nodeVersionRange}' is not supported for the node platform."); throw exc; } } return(nodeVersion); }
private string GetMaxSatisfyingGoVersionAndVerify(string version) { var versionInfo = this.goVersionProvider.GetVersionInfo(); if (!versionInfo.SupportedVersions.Contains(version)) { var exc = new UnsupportedVersionException( GolangConstants.PlatformName, version, versionInfo.SupportedVersions); this.logger.LogError( exc, $"Exception caught, the version '{version}' is not supported for the Go platform."); throw exc; } return(version); }
private string GetMaxSatisfyingVersionAndVerify(string runtimeVersion) { var versionMap = _versionProvider.GetSupportedVersions(); // Since our semantic versioning library does not work with .NET Core preview version format, here // we do some trivial way of finding the latest version which matches a given runtime version // Runtime versions are usually like: 1.0, 2.1, 3.1, 5.0 etc. // (these are constructed from netcoreapp21, netcoreapp31 etc.) // Preview version of sdks also have preview versions of runtime versions and hence they // have '-' in their names. var nonPreviewRuntimeVersions = versionMap.Keys.Where(version => version.IndexOf("-") < 0); var maxSatisfyingVersion = SemanticVersionResolver.GetMaxSatisfyingVersion( runtimeVersion, nonPreviewRuntimeVersions); // Check if a preview version is available if (string.IsNullOrEmpty(maxSatisfyingVersion)) { // NOTE: // Preview versions: 5.0.0-preview.3.20214.6, 5.0.0-preview.2.20160.6, 5.0.0-preview.1.20120.5 var previewRuntimeVersions = versionMap.Keys .Where(version => version.IndexOf("-") >= 0) .Where(version => version.StartsWith(runtimeVersion)) .OrderByDescending(version => version); if (previewRuntimeVersions.Any()) { maxSatisfyingVersion = previewRuntimeVersions.First(); } } if (string.IsNullOrEmpty(maxSatisfyingVersion)) { var exception = new UnsupportedVersionException( DotNetCoreConstants.PlatformName, runtimeVersion, versionMap.Keys); _logger.LogError( exception, $"Exception caught, the version '{runtimeVersion}' is not supported for the .NET Core platform."); throw exception; } return(maxSatisfyingVersion); }
private string VerifyAndResolveVersion(string version) { if (string.IsNullOrEmpty(version)) { return(_opts.PhpDefaultVersion); } var maxSatisfyingVersion = SemanticVersionResolver.GetMaxSatisfyingVersion(version, _versionProvider.SupportedPhpVersions); if (string.IsNullOrEmpty(maxSatisfyingVersion)) { var exc = new UnsupportedVersionException($"Target PHP version '{version}' is unsupported. " + $"Supported versions are: {string.Join(", ", _versionProvider.SupportedPhpVersions)}"); _logger.LogError(exc, "Exception caught"); throw exc; } return(maxSatisfyingVersion); }
/// <summary> /// Gets a matching version for the platform given a version in SemVer format. /// If the given version is not supported, an exception is thrown. /// </summary> /// <returns>The maximum version that satisfies the requested version spec.</returns> private string GetMatchingTargetVersion(IProgrammingPlatform platform, string targetVersionSpec) { string targetVersion; var maxSatisfyingVersion = SemanticVersionResolver.GetMaxSatisfyingVersion( targetVersionSpec, platform.SupportedVersions); if (string.IsNullOrEmpty(maxSatisfyingVersion)) { var exc = new UnsupportedVersionException(platform.Name, targetVersionSpec, platform.SupportedVersions); _logger.LogError(exc, $"Exception caught, the given version '{targetVersionSpec}' is not supported for platform '{platform.Name}'."); throw exc; } else { targetVersion = maxSatisfyingVersion; } return(targetVersion); }
private string GetMaxSatisfyingVersionAndVerify(string version) { var versionInfo = _versionProvider.GetVersionInfo(); var maxSatisfyingVersion = SemanticVersionResolver.GetMaxSatisfyingVersion( version, versionInfo.SupportedVersions); if (string.IsNullOrEmpty(maxSatisfyingVersion)) { var exc = new UnsupportedVersionException( PhpConstants.PlatformName, version, versionInfo.SupportedVersions); _logger.LogError( exc, $"Exception caught, the version '{version}' is not supported for the PHP platform."); throw exc; } return(maxSatisfyingVersion); }
private string GetMaxSatisfyingVersionAndVerify(string runtimeVersion) { var versionMap = _versionProvider.GetSupportedVersions(); var maxSatisfyingVersion = SemanticVersionResolver.GetMaxSatisfyingVersion( runtimeVersion, versionMap.Keys); if (string.IsNullOrEmpty(maxSatisfyingVersion)) { var exception = new UnsupportedVersionException( DotNetCoreConstants.LanguageName, runtimeVersion, versionMap.Keys); _logger.LogError( exception, $"Exception caught, the version '{runtimeVersion}' is not supported for the .NET Core platform."); throw exception; } return(maxSatisfyingVersion); }
private string GetMaxSatisfyingMavenVersionAndVerify(string version) { var versionInfo = _mavenVersionProvider.GetVersionInfo(); var maxSatisfyingVersion = SemanticVersionResolver.GetMaxSatisfyingVersion( version, versionInfo.SupportedVersions); if (string.IsNullOrEmpty(maxSatisfyingVersion)) { var exception = new UnsupportedVersionException( "maven", version, versionInfo.SupportedVersions); _logger.LogError( exception, $"Exception caught, the version '{version}' is not supported for Maven."); throw exception; } return(maxSatisfyingVersion); }
public string GetMaxSatisfyingPhpComposerVersionAndVerify(string version) { var versionInfo = this.phpComposerVersionProvider.GetVersionInfo(); var maxSatisfyingVersion = SemanticVersionResolver.GetMaxSatisfyingVersion( version, versionInfo.SupportedVersions); if (string.IsNullOrEmpty(maxSatisfyingVersion)) { var exception = new UnsupportedVersionException( PhpConstants.PhpComposerName, version, versionInfo.SupportedVersions); this.logger.LogError( exception, $"Exception caught, the version '{version}' is not supported for the Node platform."); throw exception; } return(maxSatisfyingVersion); }
private string GetMaxSatisfyingVersionAndVerify(string version) { var supportedVersions = SupportedVersions; // Since our semantic versioning library does not work with Python preview version format, here // we do some trivial way of finding the latest version which matches a given runtime version. // Preview version of sdks have alphabet letter in the version name. Such as '3.8.0b3', '3.9.0b1',etc. var nonPreviewRuntimeVersions = supportedVersions.Where(v => !v.Any(c => char.IsLetter(c))); var maxSatisfyingVersion = SemanticVersionResolver.GetMaxSatisfyingVersion( version, nonPreviewRuntimeVersions); // Check if a preview version is available if (string.IsNullOrEmpty(maxSatisfyingVersion)) { // Preview versions: '3.8.0b3', '3.9.0b1', etc var previewRuntimeVersions = supportedVersions .Where(v => v.Any(c => char.IsLetter(c))) .Where(v => v.StartsWith(version)) .OrderByDescending(v => v); if (previewRuntimeVersions.Any()) { maxSatisfyingVersion = previewRuntimeVersions.First(); } } if (string.IsNullOrEmpty(maxSatisfyingVersion)) { var exc = new UnsupportedVersionException( PythonConstants.PlatformName, version, supportedVersions); _logger.LogError( exc, $"Exception caught, the version '{version}' is not supported for the Python platform."); throw exc; } return(maxSatisfyingVersion); }
/// <summary> /// Gets a matching version for the platform given a version in SemVer format. /// If the given version is not supported, an exception is thrown. /// </summary> /// <returns>The maximum version that satisfies the requested version spec.</returns> private string GetMatchingTargetVersion(IProgrammingPlatform platform, string targetVersionSpec) { string targetVersion; var maxSatisfyingVersion = SemanticVersionResolver.GetMaxSatisfyingVersion( targetVersionSpec, platform.SupportedLanguageVersions); if (string.IsNullOrEmpty(maxSatisfyingVersion)) { var exc = new UnsupportedVersionException( $"The '{platform.Name}' version '{targetVersionSpec}' is not supported. " + $"Supported versions are: {string.Join(", ", platform.SupportedLanguageVersions)}"); _logger.LogError(exc, "Exception caught"); throw exc; } else { targetVersion = maxSatisfyingVersion; } return(targetVersion); }
public override void Validate(ID3Versions version) { Exception innerException = null; if ((version & ID3Versions.V2) != ID3Versions.V2) { innerException = new UnsupportedVersionException(version); } else if (mimeType.TextEncodingType != GEOBFrame.MimeTypeEncodingType) { innerException = new InvalidTextEncodingTypeException( "MIME type not set with required TextEncodingType.", mimeType.TextEncodingType); } else if (description.TextEncodingType != filename.TextEncodingType) { innerException = new InvalidTextEncodingTypeException( "Description and Text not set with same TextEncodingType.", description.TextEncodingType); } else { try { mimeType.Validate(version); filename.Validate(version); description.Validate(version); } catch (IOValidationException ex) { innerException = ex; } } if (innerException != null) { throw new FrameValidationException("Validation failed.", this, innerException); } }
private string VerifyAndResolveVersion(string version) { if (string.IsNullOrEmpty(version)) { return(_opts.PhpDefaultVersion); } var maxSatisfyingVersion = SemanticVersionResolver.GetMaxSatisfyingVersion( version, _versionProvider.SupportedPhpVersions); if (string.IsNullOrEmpty(maxSatisfyingVersion)) { var exc = new UnsupportedVersionException( PhpConstants.PhpName, version, _versionProvider.SupportedPhpVersions); _logger.LogError(exc, "Exception caught"); throw exc; } return(maxSatisfyingVersion); }
private string VerifyAndResolveVersion(string version) { if (string.IsNullOrEmpty(version)) { return(_pythonScriptGeneratorOptions.PythonDefaultVersion); } var maxSatisfyingVersion = SemanticVersionResolver.GetMaxSatisfyingVersion( version, _versionProvider.SupportedPythonVersions); if (string.IsNullOrEmpty(maxSatisfyingVersion)) { var exc = new UnsupportedVersionException( PythonConstants.PythonName, version, _versionProvider.SupportedPythonVersions); _logger.LogError(exc, $"Exception caught, the version '{version}' is not supported for the Python platform."); throw exc; } return(maxSatisfyingVersion); }
private string VerifyAndResolveVersion(string version) { if (string.IsNullOrEmpty(version)) { return(_scriptGeneratorOptions.DefaultVersion); } else { var maxSatisfyingVersion = SemanticVersionResolver.GetMaxSatisfyingVersion( version, _versionProvider.SupportedDotNetCoreVersions); if (string.IsNullOrEmpty(maxSatisfyingVersion)) { var exc = new UnsupportedVersionException( $"Target .NET Core version '{version}' is unsupported. Supported versions are:" + $" {string.Join(", ", _versionProvider.SupportedDotNetCoreVersions)}"); _logger.LogError(exc, "Exception caught"); throw exc; } return(maxSatisfyingVersion); } }
private string GetMaxSatisfyingVersionAndVerify(string version) { var supportedVersions = SupportedVersions; var nonPreviewRuntimeVersions = supportedVersions.Where(v => !v.Any(c => char.IsLetter(c))); var maxSatisfyingVersion = SemanticVersionResolver.GetMaxSatisfyingVersion( version, nonPreviewRuntimeVersions); // Check if a preview version is available if (string.IsNullOrEmpty(maxSatisfyingVersion)) { // Preview versions: '7.4.0RC4', '7.4.0beta2', etc var previewRuntimeVersions = supportedVersions .Where(v => v.Any(c => char.IsLetter(c))) .Where(v => v.StartsWith(version)) .OrderByDescending(v => v); if (previewRuntimeVersions.Any()) { maxSatisfyingVersion = previewRuntimeVersions.First(); } } if (string.IsNullOrEmpty(maxSatisfyingVersion)) { var exc = new UnsupportedVersionException( PhpConstants.PlatformName, version, supportedVersions); _logger.LogError( exc, $"Exception caught, the version '{version}' is not supported for the PHP platform."); throw exc; } return(maxSatisfyingVersion); }