public void GetInstallations_NotEmpty() { Skip.If(RuntimeInfo.GetRuntime().IsMono()); var allInstallations = FrameworkInfo.GetInstallations(); Assert.NotEmpty(allInstallations); }
public bool SdkExists(string framework) { // obtain framework and ensure it's valid FrameworkInfo fi = GetFramework(framework); return(fi.SdkDirectory != null); }
public string GetRuntimeEngine(string framework) { // obtain framework and ensure it's valid FrameworkInfo fi = GetFramework(framework); return(fi.RuntimeEngine); }
public void Invalid_SDK() { const string xml = @"<?xml version=""1.0"" ?> <project> <property name=""nant.settings.currentframework"" value=""testnet-1.0"" /> <property name=""gacutil.tool"" value=""${framework::get-tool-path('gacutil.exe')}"" /> <fail unless=""${file::exists(gacutil.tool)}"" /> <echo>${gacutil.tool}</echo> </project>"; XmlDocument configDoc = new XmlDocument(); using (Stream cs = Assembly.GetExecutingAssembly().GetManifestResourceStream("NAnt.Core.Tests.Framework.config")) { configDoc.Load(cs); } Project project = CreateFilebasedProject(xml, Level.Info, configDoc.DocumentElement); FrameworkInfo tf = project.Frameworks ["testnet-1.0"]; if (!tf.IsValid) { Assert.Ignore(tf.Description + "is not available."); } Assert.IsNull(tf.SdkDirectory, "#1"); ExecuteProject(project); }
public void GetLatest_NotNull() { Skip.If(RuntimeInfo.GetRuntime().IsMono()); var latest = FrameworkInfo.GetLatest(Environment.Version.Major); Assert.NotNull(latest); }
private IEnumerable <FrameworkInfo> DetectFrameworkInfos(DetectorContext context) { var detectedFrameworkResult = new List <FrameworkInfo>(); var packageJson = GetPackageJsonObject(context.SourceRepo, _logger); if (packageJson?.devDependencies != null) { var devDependencyObject = packageJson?.devDependencies; foreach (var keyWordToName in NodeConstants.DevDependencyFrameworkKeyWordToName) { var keyword = keyWordToName.Key; try { var frameworkInfo = new FrameworkInfo { Framework = keyWordToName.Value, FrameworkVersion = devDependencyObject[keyword].Value as string }; detectedFrameworkResult.Add(frameworkInfo); } catch (RuntimeBinderException) { } } } if (packageJson?.dependencies != null) { var dependencyObject = packageJson?.dependencies; foreach (var keyWordToName in NodeConstants.DependencyFrameworkKeyWordToName) { var keyword = keyWordToName.Key; try { var frameworkInfo = new FrameworkInfo { Framework = keyWordToName.Value, FrameworkVersion = dependencyObject[keyword].Value as string }; detectedFrameworkResult.Add(frameworkInfo); } catch (RuntimeBinderException) { } } } if (context.SourceRepo.FileExists(NodeConstants.FlutterYamlFileName)) { var frameworkInfo = new FrameworkInfo { Framework = NodeConstants.FlutterFrameworkeName, FrameworkVersion = string.Empty }; detectedFrameworkResult.Add(frameworkInfo); } return(detectedFrameworkResult); }
public string GetAssemblyDirectory(string framework) { // obtain framework and ensure it's valid FrameworkInfo fi = GetFramework(framework); // return full path to the assembly directory of the specified framework return(fi.FrameworkAssemblyDirectory.FullName); }
public string GetDescription(string framework) { // obtain framework and ensure it's valid FrameworkInfo fi = GetFramework(framework); // return the description of the specified framework return(fi.Description); }
public string GetFamily(string framework) { // obtain framework and ensure it's valid FrameworkInfo fi = GetFramework(framework); // return the family of the specified framework return(fi.Family); }
public Version GetClrVersion(string framework) { // obtain framework and ensure it's valid FrameworkInfo fi = GetFramework(framework); // return the family of the specified framework return(fi.ClrVersion); }
public Assembly() { Name = String.Empty; Framework = new FrameworkInfo(); Version = String.Empty; Culture = String.Empty; PublicKeyToken = String.Empty; References = new List<Assembly>(); }
public Assembly(string name, string version) { Name = name; Framework = new FrameworkInfo(); Version = version; Culture = String.Empty; PublicKeyToken = String.Empty; References = new List<Assembly>(); }
public string GetSdkDirectory(string framework) { // obtain framework and ensure it's valid FrameworkInfo fi = GetFramework(framework); // get the SDK directory of the specified framework DirectoryInfo sdkDirectory = fi.SdkDirectory; // return directory or empty string if SDK is not installed return((sdkDirectory != null) ? sdkDirectory.FullName : string.Empty); }
/// <summary> /// Default ctor /// </summary> internal Checker(string path, FrameworkInfo framework, Action <MessageTypes, string, IMetadataScope, string> log, Action <int, int> setProgress) { this.path = path; this.framework = framework; this.log = log; this.setProgress = setProgress; var localFolder = Path.GetDirectoryName(path); resolver = new AssemblyResolver(localFolder, framework.Folder); }
/// <summary> /// Default ctor /// </summary> public MainForm() { InitializeComponent(); miSelectAssembly.Image = Icons24.Check; miFrameworkFolder.Image = Icons24.Folder; miCopy.Image = Icons24.Copy; var folder = UserPreferences.Preferences.AssemblyCheckFrameworkFolder; framework = (string.IsNullOrEmpty(folder) || !Directory.Exists(folder)) ? Frameworks.Instance.GetNewestVersion() : new FrameworkInfo(folder); UpdateMenu(); miCopy.Enabled = false; }
private string CreateConsoleRunner() { FileInfo thisAssemblyFile = new FileInfo(new Uri(GetType().Assembly.CodeBase).LocalPath); FrameworkInfo targetFramework = Project.TargetFramework; string externalNUnitDir = ("" + Project.Properties["nant.nunit2outproc.nunitpath"]).Trim(); // assemble directories which can be probed for missing unresolved assembly references string baseDir = AppDomain.CurrentDomain.BaseDirectory; string libDir = Path.Combine(baseDir, "lib"); string frameworkFamilyLibDir = Path.Combine(libDir, targetFramework.Family); string frameworkVersionLibDir = Path.Combine(frameworkFamilyLibDir, targetFramework.ClrVersion.ToString(2)); ArrayList probePathList = new ArrayList(); if (externalNUnitDir.Length > 0) { // only probe nunit directory probePathList.Add(externalNUnitDir); } else { // probe nant lib directories probePathList.Add(frameworkVersionLibDir); probePathList.Add(frameworkFamilyLibDir); probePathList.Add(libDir); probePathList.Add(baseDir); } string[] probePaths = (string[])probePathList.ToArray(typeof(string)); // find location of nunit.core assembly for current targetFramework DirectoryInfo nunitDirectory = ResolveAssemblyLocation("nunit.core", probePaths).Directory; //publish nunit-console-runner.dll if not available yet FileInfo nunitConsoleRunnerFile = new FileInfo(Path.Combine(nunitDirectory.FullName, "nunit-console-runner.dll")); PublishAssemblyResourceFile("nunit-console-runner.dll", nunitConsoleRunnerFile); // create and compile console-runner.exe using current targetframework if necessary string exeFileName = "nunit-console-" + targetFramework.Name + ".exe"; FileInfo exeFile = new FileInfo(Path.Combine(nunitDirectory.FullName, exeFileName)); if (!exeFile.Exists) { FileInfo exeConfigFile = new FileInfo(Path.Combine(nunitDirectory.FullName, exeFileName + ".config")); PublishAssemblyResourceFile("nunit-console.exe.config", exeConfigFile); string mainExeCode = GetResourceString("nunit-console.cstemplate"); CompileExe(mainExeCode, exeFile, probePaths); } return(exeFile.FullName); // @"D:\NUnit-2.2.8-src\src\build\net\1.0\debug\nunit-console.exe"; }
/// <summary> /// Checks if the SDK for the framework specified in the <see cref="Resource" /> /// property is available on the current system. /// </summary> /// <returns> /// <see langword="true" /> when the SDK for the specified framework is /// available; otherwise, <see langword="false" />. /// </returns> private bool CheckFrameworkSDK() { FrameworkInfo framework = Project.Frameworks[Resource]; if (framework != null) { return(framework.SdkDirectory != null); } else { return(false); } }
public void GetInstallations_AllReleasesAreMappedToVersion() { var allInstallations = FrameworkInfo.GetInstallations(); foreach (var installation in allInstallations) { if (installation.Release != null) { Assert.NotNull(installation.Version, $"Release {installation.Release} has no version mapped"); } } }
public void GetInstallations_AllReleasesAreMappedToVersion() { Skip.If(RuntimeInfo.GetRuntime().IsMono()); var allInstallations = FrameworkInfo.GetInstallations(); foreach (var installation in allInstallations) { if (installation.Release != null) { // Release has no version mapped Assert.NotNull(installation.Version); } } }
public static FrameworkInfo GetMinDotNetFramework(List <Models.Assembly> assemblies) { var minFramework = new FrameworkInfo(); foreach (var assembly in assemblies) { if (assembly.Framework.SortOrder > minFramework.SortOrder) { minFramework = assembly.Framework; } } return(minFramework); }
/// <summary> /// Change the current framework folder. /// </summary> private void miChangeFrameworkFolder_Click(object sender, EventArgs e) { using (var dialog = new FolderBrowserDialog()) { dialog.SelectedPath = Frameworks.Root; if (dialog.ShowDialog(this) != DialogResult.OK) { return; } framework = new FrameworkInfo(dialog.SelectedPath); UpdateMenu(); UserPreferences.Preferences.AssemblyCheckFrameworkFolder = dialog.SelectedPath; UserPreferences.SaveNow(); } }
private static TargetDotNetFrameworkVersion GetTargetDotNetFrameworkVersion(FrameworkInfo framework) { switch (framework.ClrVersion.ToString(2)) { case "1.1": return(TargetDotNetFrameworkVersion.Version11); case "2.0": return(TargetDotNetFrameworkVersion.Version20); default: throw new BuildException("Current target framework is not supported.", Location.UnknownLocation); } }
public void Initialize(long managedDriverId, FrameworkInfo frameworkInfo, string masterAddress, bool implicitAcknowledgements, Credential credential) { var schedulerInterface = SchedulerCallbacks.GetSchedulerInterface(); var frameworkInfoBytes = ProtoBufHelper.Serialize(frameworkInfo); byte[] credentialBytes = null; if (credential != null) credentialBytes = ProtoBufHelper.Serialize(credential); unsafe { using (var pinnedFrameworkInfo = MarshalHelper.CreatePinnedObject(frameworkInfoBytes)) using (var pinnedCredential = MarshalHelper.CreatePinnedObject(credentialBytes)) _nativeDriverPtr = NativeImports.SchedulerDriver.Initialize(managedDriverId, &schedulerInterface, pinnedFrameworkInfo.Ptr, masterAddress, implicitAcknowledgements, pinnedCredential.Ptr); } }
private Dictionary <string, FrameworkInfo> ParsePackageGroups(string[] specList) { var frameworks = new Dictionary <string, FrameworkInfo>(StringComparer.OrdinalIgnoreCase); var loggerParts = _testLogger.Split("/"); var loggerName = loggerParts[0]; var loggerVersion = loggerParts[1]; foreach (var spec in specList) { var parts = spec.Split(":"); string?packageName = null; string packageVersion = null !; if (parts.Length > 1) { var packageParts = parts[0].Split("/"); packageName = packageParts[0]; packageVersion = packageParts[1]; } var tfms = parts.Last().Split(","); foreach (var tfm in tfms) { if (string.IsNullOrEmpty(tfm)) { throw new CustomException($"Invalid tfm '{tfm}'"); } if (!frameworks.TryGetValue(tfm, out var tfmInfo)) { tfmInfo = new FrameworkInfo(tfm); frameworks[tfm] = tfmInfo; tfmInfo.AddPackage(loggerName, loggerVersion); } if (packageName == null) { continue; } tfmInfo.AddPackage(packageName, packageVersion); } } return(frameworks); }
public void TargetFramework() { Project p = CreateEmptyProject(); FrameworkInfo tf = p.TargetFramework; Assert.IsNotNull(tf, "#1"); Assert.IsNotNull(tf.ClrVersion, "#2"); Assert.IsNotNull(tf.Description, "#3"); Assert.IsNotNull(tf.Family, "#4"); Assert.IsNotNull(tf.FrameworkAssemblyDirectory, "#5"); Assert.IsNotNull(tf.FrameworkDirectory, "#6"); Assert.IsTrue(tf.IsValid, "#7"); Assert.IsNotNull(tf.Name, "#8"); Assert.IsNotNull(tf.Project, "#9"); Assert.AreNotSame(p, tf.Project, "#10"); Assert.IsNotNull(tf.TaskAssemblies, "#11"); Assert.IsNotNull(tf.Version, "#12"); }
public string ScanProbingPaths(string baseDirectory, string fileName) { string libPath = null; FrameworkInfo fi = Project.TargetFramework; if (fi.Runtime != null) { string[] probingPaths = fi.Runtime.ProbingPaths.GetDirectories(baseDirectory); libPath = FileUtils.ResolveFile(probingPaths, fileName, true); } if (libPath == null) { throw new FileNotFoundException(string.Format(CultureInfo.InvariantCulture, "\"{0}\" could not be found in any of the configured " + "probing paths.", fileName)); } return(libPath); }
public void Initialize(long managedDriverId, FrameworkInfo frameworkInfo, string masterAddress, bool implicitAcknowledgements, Credential credential) { var schedulerInterface = SchedulerCallbacks.GetSchedulerInterface(); var frameworkInfoBytes = ProtoBufHelper.Serialize(frameworkInfo); byte[] credentialBytes = null; if (credential != null) { credentialBytes = ProtoBufHelper.Serialize(credential); } unsafe { using (var pinnedFrameworkInfo = MarshalHelper.CreatePinnedObject(frameworkInfoBytes)) using (var pinnedCredential = MarshalHelper.CreatePinnedObject(credentialBytes)) _nativeDriverPtr = NativeImports.SchedulerDriver.Initialize(managedDriverId, &schedulerInterface, pinnedFrameworkInfo.Ptr, masterAddress, implicitAcknowledgements, pinnedCredential.Ptr); } }
public MesosSchedulerDriver(IScheduler scheduler, FrameworkInfo frameworkInfo, string masterAddress, bool implicitAcknowledgements, Credential credential) { if (scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } if (frameworkInfo == null) { throw new ArgumentNullException(nameof(frameworkInfo)); } if (masterAddress == null) { throw new ArgumentNullException(nameof(masterAddress)); } Scheduler = scheduler; Id = DriverRegistry.Register(this); _bridge = new SchedulerDriverBridge(); _bridge.Initialize(Id, frameworkInfo, masterAddress, implicitAcknowledgements, credential); }
public void Process_ContextWithGetInstallationsData() { Skip.If(Runtime.Current.IsMono(), "Mono not supported."); //Arrange var @event = new SentryEvent(); var sut = _fixture.GetSut(); var installationList = FrameworkInfo.GetInstallations(); //Act _ = sut.Process(@event); //Assert var dictionary = @event.Contexts[NetFxInstallationsEventProcessor.NetFxInstallationsKey] as Dictionary <string, string>; foreach (var item in installationList) { Assert.Contains($"\"{item.GetVersionNumber()}\"", dictionary[$"{NetFxInstallationsEventProcessor.NetFxInstallationsKey} {item.Profile}"]); } }
/// <summary> /// Checks whether the specified framework is valid. /// </summary> /// <param name="framework">The framework to check.</param> /// <exception cref="ArgumentException"><paramref name="framework" /> is not a valid framework identifier.</exception> private FrameworkInfo GetFramework(string framework) { if (framework == Project.TargetFramework.Name) { return(Project.TargetFramework); } FrameworkInfo fi = Project.Frameworks [framework]; if (fi == null) { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, ResourceUtils.GetString("NA1096"), framework)); } else { // ensure framework is valid fi.Validate(); return(fi); } }
public void CurrentFramework_Invalid() { FrameworkInfo invalid = null; Project p = CreateEmptyProject(); foreach (FrameworkInfo framework in p.Frameworks) { if (!framework.IsValid) { invalid = framework; break; } } if (invalid == null) { Assert.Ignore("Test requires at least one invalid framework."); } string _xml = @" <project name='PropTests'> <property name='nant.settings.currentframework' value='{0}' /> </project>"; try { RunBuild(string.Format(_xml, invalid.Name)); Assert.Fail("#1"); } catch (TestBuildException ex) { Assert.IsNotNull(ex.InnerException, "#2"); // either initialization of the framework failed, or validation // failed BuildException inner = ex.InnerException as BuildException; Assert.IsNotNull(inner, "#3"); Assert.IsNotNull(inner.InnerException, "#4"); Assert.IsNotNull(inner.RawMessage, "#5"); } }
public void BuildReferenceAssemblyIndex() { var frameworkTypeDirs = Directory.GetDirectories(FrameworkProfile.Paths.ReferenceAssembliesDirectory).ToList(); var frameworks = new Dictionary<string, FrameworkInfo>(); var assemblyIndex = new List<Tuple<AssemblyNameReference, FrameworkProfileInfo>>(); var defaultProfileAssemblyIndex = new List<Tuple<AssemblyNameReference, FrameworkProfileInfo>>(); var legacyVersions = frameworkTypeDirs.Exclude(dir => { dir = Path.GetFileName(dir); return dir == FrameworkProfile.Versions.v30 || dir == FrameworkProfile.Versions.v35; }).ToArray(); foreach (var frameworkTypeDir in frameworkTypeDirs) { var frameworkType = Path.GetFileName(frameworkTypeDir); var frameworkVersionDirs = Directory.GetDirectories(frameworkTypeDir).ToList(); if (frameworkType == FrameworkProfile.Frameworks.NetFramework) { frameworkVersionDirs.AddRange(legacyVersions); } var frameworkInfo = new FrameworkInfo() { FrameworkType = frameworkType }; foreach (var versionDir in frameworkVersionDirs) { var versionString = Path.GetFileName(versionDir); Version version = null; if (versionString.StartsWith("v") && Version.TryParse(versionString.TrimStart('v'), out version)) { if (frameworkInfo.Versions == null) { frameworkInfo.Versions = new Dictionary<Version, FrameworkVersionInfo>(); } FrameworkVersionInfo versionInfo; if (!frameworkInfo.Versions.TryGetValue(version, out versionInfo)) { versionInfo = new FrameworkVersionInfo() { FrameworkInfo = frameworkInfo, Version = version, Profiles = new Dictionary<string, FrameworkProfileInfo>() }; frameworkInfo.Versions.Add(version, versionInfo); } var assemblyListFile = Path.Combine(versionDir, FrameworkProfile.Paths.FrameworkListFile); if (File.Exists(assemblyListFile)) { //default profile var profileInfo = FrameworkProfileInfo.Parse(XDocument.Load(assemblyListFile)); profileInfo.Profile = string.Empty; profileInfo.Directory = versionDir; profileInfo.FrameworkVersionInfo = versionInfo; if (versionInfo.DefaultProfile == null) { versionInfo.DefaultProfile = profileInfo; } else { Trace.WriteLine(string.Format("Warning: Found duplicate default profiles: {0} in {1} and {2} in {3}.", versionInfo.DefaultProfile.Profile, versionInfo.DefaultProfile.Directory, profileInfo.Profile, profileInfo.Directory)); } versionInfo.Profiles.Add(profileInfo.Profile, profileInfo); foreach (var assemblyNameRef in profileInfo.Assemblies) { assemblyIndex.Add(Tuple.Create(assemblyNameRef, profileInfo)); defaultProfileAssemblyIndex.Add(Tuple.Create(assemblyNameRef, profileInfo)); } } var profilesDirectory = Path.Combine(versionDir, FrameworkProfile.Paths.ProfilesSubdirectory); if (Directory.Exists(profilesDirectory)) { string[] frameworkProfileDirs = Directory.GetDirectories(profilesDirectory).ToArray(); foreach (var frameworkProfileDir in frameworkProfileDirs) { var frameworkProfileString = Path.GetFileName(frameworkProfileDir); var profileAssemblyListFile = Path.Combine(frameworkProfileDir, FrameworkProfile.Paths.FrameworkListFile); if (File.Exists(profileAssemblyListFile)) { var profileInfo = FrameworkProfileInfo.Parse(XDocument.Load(profileAssemblyListFile)); profileInfo.Profile = frameworkProfileString; profileInfo.Directory = frameworkProfileDir; profileInfo.FrameworkVersionInfo = versionInfo; if (!versionInfo.Profiles.ContainsKey(profileInfo.Profile)) { versionInfo.Profiles.Add(profileInfo.Profile, profileInfo); } else { Trace.WriteLine(string.Format("Warning: Found profiles with duplicate identifier {0}: in {1} and {2}.", profileInfo.Profile, versionInfo.Profiles[profileInfo.Profile].Directory, profileInfo.Directory)); } foreach (var assemblyNameRef in profileInfo.Assemblies) { assemblyIndex.Add(Tuple.Create(assemblyNameRef, profileInfo)); } } } } if (!(versionInfo.DefaultProfile != null || (versionInfo.Profiles != null && versionInfo.Profiles.Any()))) { frameworkInfo.Versions.Remove(version); } } else { Trace.WriteLine(string.Format("Strange: Cannot parse the version of the framework in {0}. Skipping.", versionDir)); } } if (frameworkInfo.Versions != null && frameworkInfo.Versions.Any()) { frameworks.Add(frameworkInfo.FrameworkType, frameworkInfo); } } //var mscorlibs = defaultProfileAssemblyIndex.Where(kv => kv.Item1.Name == "mscorlib").ToList(); _frameworks = frameworks; _assemblyIndex = assemblyIndex; _defaultProfileAssemblyIndex = defaultProfileAssemblyIndex; }
/// <summary> /// Initializes all build attributes and child elements. /// </summary> /// <remarks> /// <see cref="FilterChain" /> needs to maintain the order in which the /// filters are specified in the build file. /// </remarks> protected override void InitializeXml(XmlNode elementNode, PropertyDictionary properties, FrameworkInfo framework) { XmlNode = elementNode; FilterChainConfigurator configurator = new FilterChainConfigurator( this, elementNode, properties, framework); configurator.Initialize(); }
public FilterChainConfigurator(Element element, XmlNode elementNode, PropertyDictionary properties, FrameworkInfo targetFramework) : base(element, elementNode, properties, targetFramework) { }