Exemplo n.º 1
0
        public void IsOSPlatformOrLater_ReturnsTrue_ForCurrentOS(OSPlatform osPlatform)
        {
            // IsOSPlatformOrLater("xyz1.2.3.4") running as "xyz1.2.3.4" should return true

            bool    isCurrentPlatfom = RuntimeInformation.IsOSPlatform(osPlatform);
            Version current          = Environment.OSVersion.Version;

            Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformOrLater($"{osPlatform}{current}"));
            Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformOrLater($"{osPlatform.ToString().ToLower()}{current}"));
            Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformOrLater($"{osPlatform.ToString().ToUpper()}{current}"));

            Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformOrLater(osPlatform, current.Major));

            if (current.Minor >= 0)
            {
                Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformOrLater(osPlatform, current.Major, current.Minor));

                if (current.Build >= 0)
                {
                    Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformOrLater(osPlatform, current.Major, current.Minor, current.Build));

                    if (current.Revision >= 0)
                    {
                        Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformOrLater(osPlatform, current.Major, current.Minor, current.Build, current.Revision));
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void IsOSPlatformOrLater_ReturnsFalse_ForNewerVersionOfCurrentOS(OSPlatform osPlatform)
        {
            // IsOSPlatformOrLater("xyz11.0") running as "xyz10.0" should return false

            Version currentVersion = Environment.OSVersion.Version;

            Version newer = new Version(currentVersion.Major + 1, 0);

            Assert.False(RuntimeInformation.IsOSPlatformOrLater($"{osPlatform}{newer}"));
            Assert.False(RuntimeInformation.IsOSPlatformOrLater($"{osPlatform.ToString().ToLower()}{newer}"));
            Assert.False(RuntimeInformation.IsOSPlatformOrLater($"{osPlatform.ToString().ToUpper()}{newer}"));
            Assert.False(RuntimeInformation.IsOSPlatformOrLater(osPlatform, newer.Major));

            newer = new Version(currentVersion.Major, currentVersion.Minor + 1);
            Assert.False(RuntimeInformation.IsOSPlatformOrLater($"{osPlatform}{newer}"));
            Assert.False(RuntimeInformation.IsOSPlatformOrLater(osPlatform, newer.Major, newer.Minor));

            newer = new Version(currentVersion.Major, currentVersion.Minor, currentVersion.Build + 1);
            Assert.False(RuntimeInformation.IsOSPlatformOrLater($"{osPlatform}{newer}"));
            Assert.False(RuntimeInformation.IsOSPlatformOrLater(osPlatform, newer.Major, newer.Minor, newer.Build));

            newer = new Version(currentVersion.Major, currentVersion.Minor, currentVersion.Build, currentVersion.Revision + 1);
            Assert.False(RuntimeInformation.IsOSPlatformOrLater($"{osPlatform}{newer}"));
            Assert.False(RuntimeInformation.IsOSPlatformOrLater(osPlatform, newer.Major, newer.Minor, newer.Build, newer.Revision));
        }
Exemplo n.º 3
0
        public void IsOSPlatformEarlierThan_ReturnsFalse_ForCurrentOS(OSPlatform osPlatform)
        {
            // IsOSPlatformEarlierThan("xyz1.2.3.4") running as "xyz1.2.3.4" should return false

            Version current = Environment.OSVersion.Version;

            Assert.False(RuntimeInformation.IsOSPlatformEarlierThan($"{osPlatform}{current}"));
            Assert.False(RuntimeInformation.IsOSPlatformEarlierThan($"{osPlatform.ToString().ToLower()}{current}"));
            Assert.False(RuntimeInformation.IsOSPlatformEarlierThan($"{osPlatform.ToString().ToUpper()}{current}"));

            Assert.False(RuntimeInformation.IsOSPlatformEarlierThan(osPlatform, current.Major));

            if (current.Minor >= 0)
            {
                Assert.False(RuntimeInformation.IsOSPlatformEarlierThan(osPlatform, current.Major, current.Minor));

                if (current.Build >= 0)
                {
                    Assert.False(RuntimeInformation.IsOSPlatformEarlierThan(osPlatform, current.Major, current.Minor, current.Build));

                    if (current.Revision >= 0)
                    {
                        Assert.False(RuntimeInformation.IsOSPlatformEarlierThan(osPlatform, current.Major, current.Minor, current.Build, current.Revision));
                    }
                }
            }
        }
Exemplo n.º 4
0
        public void IsOSPlatformEarlierThan_ReturnsFalse_ForOlderVersionOfCurrentOS(OSPlatform osPlatform)
        {
            // IsOSPlatformEarlierThan("xyz10.0") running as "xyz11.0" should return false

            Version current = Environment.OSVersion.Version;

            Version older = new Version(current.Major - 1, 0);

            Assert.False(RuntimeInformation.IsOSPlatformEarlierThan($"{osPlatform}{older}"));
            Assert.False(RuntimeInformation.IsOSPlatformEarlierThan($"{osPlatform.ToString().ToLower()}{older}"));
            Assert.False(RuntimeInformation.IsOSPlatformEarlierThan($"{osPlatform.ToString().ToUpper()}{older}"));
            Assert.False(RuntimeInformation.IsOSPlatformEarlierThan(osPlatform, older.Major));

            if (current.Minor > 0)
            {
                older = new Version(current.Major, current.Minor - 1);
                Assert.False(RuntimeInformation.IsOSPlatformEarlierThan($"{osPlatform}{older}"));
                Assert.False(RuntimeInformation.IsOSPlatformEarlierThan(osPlatform, older.Major, older.Minor));
            }

            if (current.Build > 0)
            {
                older = new Version(current.Major, current.Minor, current.Build - 1);
                Assert.False(RuntimeInformation.IsOSPlatformEarlierThan($"{osPlatform}{older}"));
                Assert.False(RuntimeInformation.IsOSPlatformEarlierThan(osPlatform, older.Major, older.Minor, older.Build));
            }

            if (current.Revision > 0)
            {
                older = new Version(current.Major, current.Minor, current.Build, current.Revision - 1);
                Assert.False(RuntimeInformation.IsOSPlatformEarlierThan($"{osPlatform}{older}"));
                Assert.False(RuntimeInformation.IsOSPlatformEarlierThan(osPlatform, older.Major, older.Minor, older.Build, older.Revision));
            }
        }
Exemplo n.º 5
0
        public void IsOSPlatformOrLater_ReturnsTrue_ForOlderVersionOfCurrentOS(OSPlatform osPlatform)
        {
            // IsOSPlatformOrLater("xyz10.0") running as "xyz11.0" should return true

            bool    isCurrentPlatfom = RuntimeInformation.IsOSPlatform(osPlatform);
            Version current          = Environment.OSVersion.Version;

            Version older = new Version(current.Major - 1, 0);

            Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformOrLater($"{osPlatform}{older}"));
            Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformOrLater($"{osPlatform.ToString().ToLower()}{older}"));
            Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformOrLater($"{osPlatform.ToString().ToUpper()}{older}"));
            Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformOrLater(osPlatform, older.Major));

            if (current.Minor > 0)
            {
                older = new Version(current.Major, current.Minor - 1);
                Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformOrLater($"{osPlatform}{older}"));
                Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformOrLater(osPlatform, older.Major, older.Minor));
            }

            if (current.Build > 0)
            {
                older = new Version(current.Major, current.Minor, current.Build - 1);
                Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformOrLater($"{osPlatform}{older}"));
                Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformOrLater(osPlatform, older.Major, older.Minor, older.Build));
            }

            if (current.Revision > 0)
            {
                older = new Version(current.Major, current.Minor, current.Build, current.Revision - 1);
                Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformOrLater($"{osPlatform}{older}"));
                Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformOrLater(osPlatform, older.Major, older.Minor, older.Build, older.Revision));
            }
        }
Exemplo n.º 6
0
 private void ValidateOSPlatform(OSPlatform os)
 {
     if (!SupportedOperatingSystems.Any(s => s.Equals(os.ToString(), StringComparison.OrdinalIgnoreCase)))
     {
         throw new PlatformNotSupportedException($"OS {os.ToString()} is not supported for language {Language}");
     }
 }
Exemplo n.º 7
0
        public void CheckOSPlatform()
        {
            OSPlatform winObj = OSPlatform.Create("WINDOWS");
            OSPlatform winProp = OSPlatform.Windows;
            OSPlatform randomObj = OSPlatform.Create("random");
            OSPlatform defaultObj = default(OSPlatform);
            OSPlatform conObj = new OSPlatform();
            Assert.Throws<ArgumentNullException>(() => { OSPlatform nullObj = OSPlatform.Create(null); });
            Assert.Throws<ArgumentException>(() => { OSPlatform emptyObj = OSPlatform.Create(""); });

            Assert.True(winObj == winProp);
            Assert.True(winObj != randomObj);
            Assert.True(defaultObj == conObj);

            Assert.False(winObj == defaultObj);
            Assert.False(winObj == randomObj);
            Assert.False(winObj != winProp);

            Assert.True(winObj.Equals(winProp));
            Assert.True(conObj.Equals(defaultObj));

            Assert.False(defaultObj.Equals(winProp));
            Assert.False(winObj.Equals(null));
            Assert.False(winObj.Equals("something"));

            Assert.Equal("WINDOWS", winObj.ToString());
            Assert.Equal("WINDOWS", winProp.ToString());
            Assert.Equal("", defaultObj.ToString());
            Assert.Equal("", conObj.ToString());
            Assert.Equal("random", randomObj.ToString());

            Assert.Equal(winObj.GetHashCode(), winProp.GetHashCode());
            Assert.Equal(0, defaultObj.GetHashCode());
            Assert.Equal(defaultObj.GetHashCode(), conObj.GetHashCode());
        }
Exemplo n.º 8
0
        public string GetOsPlatformDescription()
        {
            StringBuilder retval = new StringBuilder(1024);
            OSPlatform    os     = GetOSPlatform();

            retval.AppendLine($"OSPlatform: {os.ToString()}");
            retval.AppendLine($"RTI.FrameworkDescription: {RuntimeInformation.FrameworkDescription}");
            retval.AppendLine($"RTI.OSArchitecture: {RuntimeInformation.OSArchitecture}");
            retval.AppendLine($"RTI.OSDescription: {RuntimeInformation.OSDescription}");

            return(retval.ToString());
        }
Exemplo n.º 9
0
        public static async Task <Device> Create(string deviceID, string orgID)
        {
            OSPlatform platform = OSUtils.GetPlatform();

            var systemDrive = DriveInfo.GetDrives().FirstOrDefault(x =>
                                                                   x.IsReady &&
                                                                   x.RootDirectory.FullName.Contains(Path.GetPathRoot(Environment.SystemDirectory ?? Environment.CurrentDirectory)));

            var device = new Device()
            {
                ID             = deviceID,
                DeviceName     = Environment.MachineName,
                Platform       = platform.ToString(),
                ProcessorCount = Environment.ProcessorCount,
                OSArchitecture = RuntimeInformation.OSArchitecture,
                OSDescription  = RuntimeInformation.OSDescription,
                Is64Bit        = Environment.Is64BitOperatingSystem,
                IsOnline       = true,
                Drives         = DriveInfo.GetDrives().Where(x => x.IsReady).Select(x => new Drive()
                {
                    DriveFormat   = x.DriveFormat,
                    DriveType     = x.DriveType,
                    Name          = x.Name,
                    RootDirectory = x.RootDirectory.FullName,
                    FreeSpace     = x.TotalSize > 0 ? x.TotalFreeSpace / x.TotalSize : 0,
                    TotalSize     = x.TotalSize > 0 ? Math.Round((double)(x.TotalSize / 1024 / 1024 / 1024), 2) : 0,
                    VolumeLabel   = x.VolumeLabel
                }).ToList(),
                OrganizationID = orgID,
                CurrentUser    = DeviceInformation.GetCurrentUser()
            };

            if (systemDrive != null && systemDrive.TotalSize > 0 && systemDrive.TotalFreeSpace > 0)
            {
                device.TotalStorage = Math.Round((double)(systemDrive.TotalSize / 1024 / 1024 / 1024), 2);
                device.UsedStorage  = Math.Round((double)((systemDrive.TotalSize - systemDrive.TotalFreeSpace) / 1024 / 1024 / 1024), 2);
            }


            var(usedMemory, totalMemory) = GetMemoryInGB();
            device.UsedMemory            = usedMemory;
            device.TotalMemory           = totalMemory;

            device.CpuUtilization = await GetCpuUtilization();

            if (File.Exists("Remotely_Agent.dll"))
            {
                device.AgentVersion = FileVersionInfo.GetVersionInfo("Remotely_Agent.dll")?.FileVersion?.ToString()?.Trim();
            }

            return(device);
        }
Exemplo n.º 10
0
        string BuildRuntimeIdentifier()
        {
            string rid;

            if (OSPlatform == OSPlatform.Windows)
            {
                rid = "win";
            }
            else if (OSPlatform == OSPlatform.OSX)
            {
                rid = "osx";
            }
            else if (OSPlatform == OSPlatform.Linux)
            {
                rid = "linux";
            }
            else
            {
                rid = OSPlatform.ToString().ToLowerInvariant();
            }

            if (Architecture == null)
            {
                return(rid);
            }

            switch (Architecture.Value)
            {
            case X86:
                rid += "-x86";
                break;

            case X64:
                rid += "-x64";
                break;

            case Arm:
                rid += "-arm";
                break;

            case Arm64:
                rid += "-arm64";
                break;

            default:
                rid += "-" + Architecture.Value.ToString().ToLowerInvariant();
                break;
            }

            return(rid);
        }
Exemplo n.º 11
0
 public static ProcessBrowser CreateForPlatform(OSPlatform platform)
 {
     if (platform == OSPlatform.Windows)
     {
         return(new ProcessBrowser((url) =>
         {
             return new ProcessStartInfo
             {
                 FileName = url,
                 CreateNoWindow = true,
                 UseShellExecute = true,
             };
         }));
     }
     else if (platform == OSPlatform.Linux)
     {
         return(new ProcessBrowser((url) =>
         {
             // If no associated application/json MimeType is found xdg-open opens retrun error
             // but it tries to open it anyway using the console editor (nano, vim, other..)
             var escapedArgs = $"xdg-open {url}".Replace("\"", "\\\"");
             return new ProcessStartInfo
             {
                 FileName = "/bin/sh",
                 Arguments = $"-c \"{escapedArgs}\"",
                 RedirectStandardOutput = true,
                 UseShellExecute = false,
                 CreateNoWindow = true,
                 WindowStyle = ProcessWindowStyle.Hidden
             };
         }));
     }
     else if (platform == OSPlatform.OSX)
     {
         return(new ProcessBrowser((url) => new ProcessStartInfo
         {
             FileName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? url : "open",
             Arguments = $"-e {url}",
             CreateNoWindow = true,
             UseShellExecute = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
         }));
     }
     else
     {
         throw new NotSupportedException(platform.ToString());
     }
 }
Exemplo n.º 12
0
        public static BaseDeviceInformation GetInformation(OSPlatform osPlatform)
        {
            var fileName = $"jcBENCH.lib.{osPlatform.ToString().ToLower()}.dll";

            if (!File.Exists(fileName))
            {
                throw new Exception($"Could not find {osPlatform} Assembly ({fileName}");
            }

            var assembly = Assembly.LoadFile(Path.Combine(AppContext.BaseDirectory, fileName));

            if (assembly == null)
            {
                throw new Exception("Failure loading Dynamic Platform Assembly");
            }

            return(assembly.DefinedTypes.Where(a => a.BaseType == typeof(BaseDeviceInformation) && !a.IsAbstract)
                   .Select(b => (BaseDeviceInformation)Activator.CreateInstance(b)).FirstOrDefault(c => RuntimeInformation.IsOSPlatform(osPlatform)));
        }
Exemplo n.º 13
0
        public void CheckOSPlatform()
        {
            OSPlatform winObj     = OSPlatform.Create("WINDOWS");
            OSPlatform winProp    = OSPlatform.Windows;
            OSPlatform randomObj  = OSPlatform.Create("random");
            OSPlatform defaultObj = default(OSPlatform);
            OSPlatform conObj     = new OSPlatform();

            Assert.Throws <ArgumentNullException>(() => { OSPlatform nullObj = OSPlatform.Create(null); });
            Assert.Throws <ArgumentException>(() => { OSPlatform emptyObj = OSPlatform.Create(""); });

            Assert.True(winObj == winProp);
            Assert.True(winObj != randomObj);
            Assert.True(defaultObj == conObj);

            Assert.False(winObj == defaultObj);
            Assert.False(winObj == randomObj);
            Assert.False(winObj != winProp);

            Assert.True(winObj.Equals(winProp));
            Assert.True(winObj.Equals((object)winProp));
            Assert.True(conObj.Equals(defaultObj));

            Assert.False(defaultObj.Equals(winProp));
            Assert.False(defaultObj.Equals((object)winProp));
            Assert.False(winObj.Equals(null));
            Assert.False(winObj.Equals("something"));

            Assert.Equal("WINDOWS", winObj.ToString());
            Assert.Equal("WINDOWS", winProp.ToString());
            Assert.Equal("", defaultObj.ToString());
            Assert.Equal("", conObj.ToString());
            Assert.Equal("random", randomObj.ToString());

            Assert.Equal(winObj.GetHashCode(), winProp.GetHashCode());
            Assert.Equal(0, defaultObj.GetHashCode());
            Assert.Equal(defaultObj.GetHashCode(), conObj.GetHashCode());
        }
Exemplo n.º 14
0
        internal string GetHydratedWorkerPath(RpcWorkerDescription description)
        {
            if (string.IsNullOrEmpty(description.DefaultWorkerPath))
            {
                return(null);
            }

            OSPlatform os = _systemRuntimeInformation.GetOSPlatform();

            Architecture architecture = _systemRuntimeInformation.GetOSArchitecture();
            string       version      = _environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeVersionSettingName);

            if (string.IsNullOrEmpty(version))
            {
                version = description.DefaultRuntimeVersion;
            }

            description.ValidateWorkerPath(description.DefaultWorkerPath, os, architecture, version);

            return(description.DefaultWorkerPath.Replace(RpcWorkerConstants.OSPlaceholder, os.ToString())
                   .Replace(RpcWorkerConstants.ArchitecturePlaceholder, architecture.ToString())
                   .Replace(RpcWorkerConstants.RuntimeVersionPlaceholder, version));
        }
Exemplo n.º 15
0
 public OSNotSupportedException(OSPlatform platform, StatType statType)
 {
     Console.WriteLine($"We currently do not support logging for {statType.ToString()} on {platform.ToString()}");
 }
Exemplo n.º 16
0
        public static Device Create(ConnectionInfo connectionInfo)
        {
            OSPlatform platform = OSUtils.GetPlatform();
            DriveInfo  systemDrive;

            if (!string.IsNullOrWhiteSpace(Environment.SystemDirectory))
            {
                systemDrive = DriveInfo.GetDrives()
                              .Where(x => x.IsReady)
                              .FirstOrDefault(x =>
                                              x.RootDirectory.FullName.Contains(Path.GetPathRoot(Environment.SystemDirectory ?? Environment.CurrentDirectory))
                                              );
            }
            else
            {
                systemDrive = DriveInfo.GetDrives().FirstOrDefault(x =>
                                                                   x.IsReady &&
                                                                   x.RootDirectory.FullName == Path.GetPathRoot(Environment.CurrentDirectory));
            }

            var device = new Device()
            {
                ID             = connectionInfo.DeviceID,
                DeviceName     = Environment.MachineName,
                Platform       = platform.ToString(),
                ProcessorCount = Environment.ProcessorCount,
                OSArchitecture = RuntimeInformation.OSArchitecture,
                OSDescription  = RuntimeInformation.OSDescription,
                Is64Bit        = Environment.Is64BitOperatingSystem,
                IsOnline       = true,
                Drives         = DriveInfo.GetDrives().Where(x => x.IsReady).Select(x => new Drive()
                {
                    DriveFormat   = x.DriveFormat,
                    DriveType     = x.DriveType,
                    Name          = x.Name,
                    RootDirectory = x.RootDirectory.FullName,
                    FreeSpace     = x.TotalSize > 0 ? x.TotalFreeSpace / x.TotalSize : 0,
                    TotalSize     = x.TotalSize > 0 ? Math.Round((double)(x.TotalSize / 1024 / 1024 / 1024), 2) : 0,
                    VolumeLabel   = x.VolumeLabel
                }).ToList(),
                OrganizationID = connectionInfo.OrganizationID,
                CurrentUser    = GetCurrentUser()
            };

            if (systemDrive != null && systemDrive.TotalSize > 0 && systemDrive.TotalFreeSpace > 0)
            {
                device.TotalStorage = Math.Round((double)(systemDrive.TotalSize / 1024 / 1024 / 1024), 2);
                var freeStorage = Math.Round((double)(systemDrive.TotalFreeSpace / 1024 / 1024 / 1024), 2);
                device.FreeStorage = freeStorage / device.TotalStorage;
            }

            Tuple <double, double> totalMemory = new Tuple <double, double>(0, 0);

            if (OSUtils.IsWindows)
            {
                totalMemory = GetWinMemoryInGB();
            }
            else if (OSUtils.IsLinux)
            {
                totalMemory = GetLinxMemoryInGB();
            }

            if (totalMemory.Item2 > 0)
            {
                device.FreeMemory = totalMemory.Item1 / totalMemory.Item2;
            }
            else
            {
                device.FreeMemory = 0;
            }
            device.TotalMemory = totalMemory.Item2;

            if (File.Exists("Remotely_Agent.dll"))
            {
                device.AgentVersion = FileVersionInfo.GetVersionInfo("Remotely_Agent.dll")?.FileVersion?.ToString()?.Trim();
            }

            return(device);
        }
Exemplo n.º 17
0
        public void IsOSPlatformEarlierThan_ReturnsTrue_ForNewerVersionOfCurrentOS(OSPlatform osPlatform)
        {
            // IsOSPlatformEarlierThan("xyz11.0") running as "xyz10.0" should return true

            bool    isCurrentPlatfom = RuntimeInformation.IsOSPlatform(osPlatform);
            Version current          = Environment.OSVersion.Version;

            Version newer = new Version(current.Major + 1, 0);

            Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformEarlierThan($"{osPlatform}{newer}"));
            Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformEarlierThan($"{osPlatform.ToString().ToLower()}{newer}"));
            Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformEarlierThan($"{osPlatform.ToString().ToUpper()}{newer}"));
            Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformEarlierThan(osPlatform, newer.Major));

            newer = new Version(current.Major, current.Minor + 1);
            Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformEarlierThan($"{osPlatform}{newer}"));
            Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformEarlierThan(osPlatform, newer.Major, newer.Minor));

            newer = new Version(current.Major, current.Minor, current.Build + 1);
            Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformEarlierThan($"{osPlatform}{newer}"));
            Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformEarlierThan(osPlatform, newer.Major, newer.Minor, newer.Build));

            newer = new Version(current.Major, current.Minor, current.Build, current.Revision + 1);
            Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformEarlierThan($"{osPlatform}{newer}"));
            Assert.Equal(isCurrentPlatfom, RuntimeInformation.IsOSPlatformEarlierThan(osPlatform, newer.Major, newer.Minor, newer.Build, newer.Revision));
        }
        internal void FormatWorkerPathIfNeeded(ISystemRuntimeInformation systemRuntimeInformation, IEnvironment environment, ILogger logger)
        {
            if (string.IsNullOrEmpty(DefaultWorkerPath))
            {
                return;
            }

            OSPlatform   os           = systemRuntimeInformation.GetOSPlatform();
            Architecture architecture = systemRuntimeInformation.GetOSArchitecture();
            string       version      = environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeVersionSettingName);

            logger.LogDebug($"EnvironmentVariable {RpcWorkerConstants.FunctionWorkerRuntimeVersionSettingName}: {version}");

            if (!string.IsNullOrEmpty(version))
            {
                DefaultRuntimeVersion = version;
            }

            ValidateDefaultWorkerPathFormatters(systemRuntimeInformation);

            DefaultWorkerPath = DefaultWorkerPath.Replace(RpcWorkerConstants.OSPlaceholder, os.ToString())
                                .Replace(RpcWorkerConstants.ArchitecturePlaceholder, architecture.ToString())
                                .Replace(RpcWorkerConstants.RuntimeVersionPlaceholder, DefaultRuntimeVersion);
        }
        internal void FormatWorkerPathIfNeeded(ISystemRuntimeInformation systemRuntimeInformation, IEnvironment environment, ILogger logger)
        {
            if (string.IsNullOrEmpty(DefaultWorkerPath))
            {
                return;
            }

            OSPlatform   os            = systemRuntimeInformation.GetOSPlatform();
            Architecture architecture  = systemRuntimeInformation.GetOSArchitecture();
            string       workerRuntime = environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeSettingName);
            string       version       = environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeVersionSettingName);

            logger.LogDebug($"EnvironmentVariable {RpcWorkerConstants.FunctionWorkerRuntimeVersionSettingName}: {version}");

            // Only over-write DefaultRuntimeVersion if workerRuntime matches language for the worker config
            if (!string.IsNullOrEmpty(workerRuntime) && workerRuntime.Equals(Language, StringComparison.OrdinalIgnoreCase) && !string.IsNullOrEmpty(version))
            {
                DefaultRuntimeVersion = GetSanitizedRuntimeVersion(version);
            }

            ValidateDefaultWorkerPathFormatters(systemRuntimeInformation);

            DefaultWorkerPath = DefaultWorkerPath.Replace(RpcWorkerConstants.OSPlaceholder, os.ToString())
                                .Replace(RpcWorkerConstants.ArchitecturePlaceholder, architecture.ToString())
                                .Replace(RpcWorkerConstants.RuntimeVersionPlaceholder, DefaultRuntimeVersion);
        }