public static bool Is(this Sdk sdk, SdkId id) { if (id.IsNull) { throw new ArgumentNullException(nameof(id)); } return(sdk != null && sdk.Id == id); }
public static bool IsNot(this Sdk sdk, SdkId id) { if (id.IsNull) { throw new ArgumentNullException(nameof(id)); } return(sdk == null || sdk.Id != id); }
public static Sdk FromEntryAssembly( SdkId id, string name = null, string profile = null, string version = null) => new Sdk( id, new FrameworkName(Assembly .GetEntryAssembly() .GetCustomAttribute <TargetFrameworkAttribute> () .FrameworkName), Array.Empty <string> (), name, profile, version);
public Sdk( SdkId id, FrameworkName targetFramework, IEnumerable <string> assemblySearchPaths, string name = null, string profile = null, string version = null) { Id = ((string)id) ?? throw new ArgumentNullException(nameof(id)); TargetFramework = targetFramework ?? throw new ArgumentNullException(nameof(targetFramework)); AssemblySearchPaths = assemblySearchPaths?.ToArray() ?? throw new ArgumentNullException(nameof(assemblySearchPaths)); Name = name; Profile = profile; Version = version; if (Name != null || Version != null) { return; } if (Environment.OSVersion.Platform == PlatformID.Unix) { Name = "System Mono"; const string monoVersionPath = "/Library/Frameworks/Mono.framework/Versions/Current/VERSION"; if (File.Exists(monoVersionPath)) { Version = File.ReadAllText(monoVersionPath)?.Trim(); } } else { var versionInfo = FileVersionInfo.GetVersionInfo(typeof(object).Assembly.Location); Name = ".NET Framework"; Version = versionInfo.ProductVersion; } }