// NOTE: this is a new constructor provided, which passes in the framework version // of the given profile in addition to the name. // The existing behavior was to pass "v0.0" as the framework version, so // that's what the fixed parameter is in the backwards-compatible constructor above. /// <summary> /// Creates a portable profile for the given framework version, profile name and /// supported frameworks. /// </summary> /// <param name="frameworkDirectory">.NET framework version that the profile belongs to, like "v4.0".</param> /// <param name="name">Name of the portable profile, like "win+net45".</param> /// <param name="supportedFrameworks">Supported frameworks.</param> public NetPortableProfile(string frameworkDirectory, string name, IEnumerable <FrameworkName> supportedFrameworks, IEnumerable <FrameworkName> optionalFrameworks) { if (String.IsNullOrEmpty(frameworkDirectory)) { throw new ArgumentNullException(nameof(frameworkDirectory)); } if (String.IsNullOrEmpty(name)) { throw new ArgumentNullException(nameof(name)); } if (supportedFrameworks == null) { throw new ArgumentNullException(nameof(supportedFrameworks)); } var frameworks = supportedFrameworks.ToList(); if (frameworks.Any(f => f == null)) { throw new ArgumentException(NuGetResources.SupportedFrameworkIsNull, nameof(supportedFrameworks)); } if (frameworks.Count == 0) { throw new ArgumentOutOfRangeException(nameof(supportedFrameworks)); } Name = name; SupportedFrameworks = new ReadOnlyHashSet <FrameworkName>(frameworks); OptionalFrameworks = new ReadOnlyHashSet <FrameworkName>(optionalFrameworks ?? Enumerable.Empty <FrameworkName>()); FrameworkDirectory = frameworkDirectory; FrameworkVersion = new DirectoryInfo(frameworkDirectory).Name.TrimStart('v'); FrameworkName = new FrameworkName(".NETPortable", Version.Parse(FrameworkVersion), Name); }
// NOTE: this is a new constructor provided, which passes in the framework version // of the given profile in addition to the name. // The existing behavior was to pass "v0.0" as the framework version, so // that's what the fixed parameter is in the backwards-compatible constructor above. /// <summary> /// Creates a portable profile for the given framework version, profile name and /// supported frameworks. /// </summary> /// <param name="version">.NET framework version that the profile belongs to, like "v4.0".</param> /// <param name="name">Name of the portable profile, like "win+net45".</param> /// <param name="supportedFrameworks">Supported frameworks.</param> public NetPortableProfile(string version, string name, IEnumerable <FrameworkName> supportedFrameworks) { if (String.IsNullOrEmpty(version)) { throw new ArgumentNullException("version"); } if (String.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } if (supportedFrameworks == null) { throw new ArgumentNullException("supportedFrameworks"); } var frameworks = supportedFrameworks.ToList(); if (frameworks.Any(f => f == null)) { throw new ArgumentException(NuGetResources.SupportedFrameworkIsNull, "supportedFrameworks"); } if (frameworks.Count == 0) { throw new ArgumentOutOfRangeException("supportedFrameworks"); } Name = name; SupportedFrameworks = new ReadOnlyHashSet <FrameworkName>(frameworks); FrameworkVersion = version; }
// NOTE: this is a new constructor provided, which passes in the framework version // of the given profile in addition to the name. // The existing behavior was to pass "v0.0" as the framework version, so // that's what the fixed parameter is in the backwards-compatible constructor above. /// <summary> /// Creates a portable profile for the given framework version, profile name and /// supported frameworks. /// </summary> /// <param name="version">.NET framework version that the profile belongs to, like "v4.0".</param> /// <param name="name">Name of the portable profile, like "win+net45".</param> /// <param name="supportedFrameworks">Supported frameworks.</param> /// <param name="optionalFrameworks">Optional frameworks.</param> public NetPortableProfile(string version, string name, IEnumerable <FrameworkName> supportedFrameworks, IEnumerable <FrameworkName> optionalFrameworks) { if (String.IsNullOrEmpty(version)) { throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "version"); } if (String.IsNullOrEmpty(name)) { throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "name"); } if (supportedFrameworks == null) { throw new ArgumentNullException("supportedFrameworks"); } var frameworks = supportedFrameworks.ToList(); if (frameworks.Any(f => f == null)) { throw new ArgumentException(NuGetResources.SupportedFrameworkIsNull, "supportedFrameworks"); } if (frameworks.Count == 0) { throw new ArgumentOutOfRangeException("supportedFrameworks"); } Name = name; SupportedFrameworks = new ReadOnlyHashSet <FrameworkName>(frameworks); OptionalFrameworks = (optionalFrameworks == null || optionalFrameworks.IsEmpty()) ? new ReadOnlyHashSet <FrameworkName>(Enumerable.Empty <FrameworkName>()) : new ReadOnlyHashSet <FrameworkName>(optionalFrameworks); FrameworkVersion = version; }