From 6905f1a71af60d03d4a9ef3cc38556fa42ba6645 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 10 Mar 2024 16:56:12 +0000 Subject: [PATCH] cosmetics --- .../Framework/Servers/BaseOpenSimServer.cs | 7 +- OpenSim/Framework/Servers/ServerBase.cs | 76 +++++++++---------- OpenSim/Framework/Util.cs | 3 +- prebuild.xml | 4 +- 4 files changed, 39 insertions(+), 51 deletions(-) diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 1309351e2b..1ae12a24bd 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -180,11 +180,8 @@ namespace OpenSim.Framework.Servers m_log.Info("[STARTUP]: Beginning startup processing"); m_log.Info("[STARTUP]: version: " + m_version); - m_log.InfoFormat("[STARTUP]: Operating system version: {0}, .NET platform {1}, Runtime {2}", - Environment.OSVersion, Util.RuntimePlatformStr, Environment.Version.ToString()); - m_log.InfoFormat("[STARTUP]: Processor Architecture: {0}({1} {2}bit)", - RuntimeInformation.ProcessArchitecture.ToString(), - BitConverter.IsLittleEndian ?"le":"be", Environment.Is64BitProcess ? "64" : "32"); + m_log.Info($"[STARTUP]: Operating system version: {Environment.OSVersion}, .NET platform {Util.RuntimePlatformStr}, Runtime {Environment.Version}"); + m_log.Info($"[STARTUP]: Processor Architecture: {RuntimeInformation.ProcessArchitecture}({(BitConverter.IsLittleEndian ? "le" : "be")} {(Environment.Is64BitProcess ? "64" : "32")}bit)"); try { StartupSpecific(); diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs index 9eb653e900..79f9abc099 100755 --- a/OpenSim/Framework/Servers/ServerBase.cs +++ b/OpenSim/Framework/Servers/ServerBase.cs @@ -82,9 +82,7 @@ namespace OpenSim.Framework.Servers protected void CreatePIDFile(string path) { if (File.Exists(path)) - m_log.ErrorFormat( - "[SERVER BASE]: Previous pid file {0} still exists on startup. Possibly previously unclean shutdown.", - path); + m_log.Error($"[SERVER BASE]: Previous pid file {path} still exists on startup. Possibly previously unclean shutdown."); try { @@ -108,7 +106,7 @@ namespace OpenSim.Framework.Servers protected void RemovePIDFile() { - if (m_pidFile != String.Empty) + if (!string.IsNullOrEmpty(m_pidFile)) { try { @@ -116,7 +114,7 @@ namespace OpenSim.Framework.Servers } catch (Exception e) { - m_log.Error(string.Format("[SERVER BASE]: Error whilst removing {0} ", m_pidFile), e); + m_log.Error($"[SERVER BASE]: Error whilst removing {m_pidFile}", e); } m_pidFile = String.Empty; @@ -131,16 +129,15 @@ namespace OpenSim.Framework.Servers { // FIXME: This should be done down in ServerBase but we need to sort out and refactor the log4net // XmlConfigurator calls first accross servers. - m_log.InfoFormat("[SERVER BASE]: Starting in {0}", m_startupDirectory); + m_log.Info($"[SERVER BASE]: Starting in {m_startupDirectory}"); - m_log.InfoFormat("[SERVER BASE]: OpenSimulator version: {0}", m_version); + m_log.Info($"[SERVER BASE]: OpenSimulator version: {m_version}"); // clr version potentially is more confusing than helpful, since it doesn't tell us if we're running under Mono/MS .NET and // the clr version number doesn't match the project version number under Mono. //m_log.Info("[STARTUP]: Virtual machine runtime version: " + Environment.Version + Environment.NewLine); - m_log.InfoFormat( - "[SERVER BASE]: Operating system version: {0}, .NET platform {1}, {2}-bit", - Environment.OSVersion, Util.RuntimePlatformStr, Environment.Is64BitProcess ? "64" : "32"); + m_log.Info( + $"[SERVER BASE]: Operating system version: {Environment.OSVersion}, .NET platform {Util.RuntimePlatformStr}, {(Environment.Is64BitProcess ? "64" : "32")}-bit"); } public void RegisterCommonAppenders(IConfig startupConfig) @@ -298,11 +295,11 @@ namespace OpenSim.Framework.Servers + " 3 = full stack trace, including common threads\n", HandleDebugThreadpoolLevel); -// m_console.Commands.AddCommand( -// "Debug", false, "show threadpool calls active", -// "show threadpool calls active", -// "Show details about threadpool calls that are still active (currently waiting or in progress)", -// HandleShowThreadpoolCallsActive); + //m_console.Commands.AddCommand( + // "Debug", false, "show threadpool calls active", + // "show threadpool calls active", + // "Show details about threadpool calls that are still active (currently waiting or in progress)", + // HandleShowThreadpoolCallsActive); m_console.Commands.AddCommand( "Debug", false, "show threadpool calls complete", @@ -334,7 +331,7 @@ namespace OpenSim.Framework.Servers public void RegisterCommonComponents(IConfigSource configSource) { -// IConfig networkConfig = configSource.Configs["Network"]; + //IConfig networkConfig = configSource.Configs["Network"]; m_serverStatsCollector = new ServerStatsCollector(); m_serverStatsCollector.Initialise(configSource); @@ -417,9 +414,7 @@ namespace OpenSim.Framework.Servers return; } - int newThreads; - - if (!ConsoleUtil.TryParseConsoleInt(m_console, args[5], out newThreads)) + if (!ConsoleUtil.TryParseConsoleInt(m_console, args[5], out int newThreads)) return; string poolType = args[3]; @@ -469,10 +464,8 @@ namespace OpenSim.Framework.Servers } else { - int minWorkerThreads, maxWorkerThreads, minIocpThreads, maxIocpThreads; - - ThreadPool.GetMinThreads(out minWorkerThreads, out minIocpThreads); - ThreadPool.GetMaxThreads(out maxWorkerThreads, out maxIocpThreads); + ThreadPool.GetMinThreads(out int minWorkerThreads, out int minIocpThreads); + ThreadPool.GetMaxThreads(out int maxWorkerThreads, out int maxIocpThreads); Notice("Min worker threads now {0}", minWorkerThreads); Notice("Min IOCP threads now {0}", minIocpThreads); @@ -756,48 +749,48 @@ namespace OpenSim.Framework.Servers /// protected void EnhanceVersionInformation() { + const string manualVersionFileName = ".version"; string buildVersion = string.Empty; - string manualVersionFileName = ".version"; - - string gitDir = "../.git/"; - string gitRefPointerPath = gitDir + "HEAD"; - if (File.Exists(manualVersionFileName)) { using (StreamReader CommitFile = File.OpenText(manualVersionFileName)) buildVersion = CommitFile.ReadLine(); - m_version += buildVersion ?? ""; + if (!string.IsNullOrEmpty(buildVersion)) + m_version += buildVersion[..7]; + return; } - else if (File.Exists(gitRefPointerPath)) + + string gitDir = Path.Combine("..", ".git"); + string gitRefPointerPath = Path.Combine(gitDir, "HEAD"); + if (File.Exists(gitRefPointerPath)) { -// m_log.DebugFormat("[SERVER BASE]: Found {0}", gitRefPointerPath); + //m_log.DebugFormat("[SERVER BASE]: Found {0}", gitRefPointerPath); string rawPointer = ""; using (StreamReader pointerFile = File.OpenText(gitRefPointerPath)) rawPointer = pointerFile.ReadLine(); -// m_log.DebugFormat("[SERVER BASE]: rawPointer [{0}]", rawPointer); + //m_log.DebugFormat("[SERVER BASE]: rawPointer [{0}]", rawPointer); Match m = Regex.Match(rawPointer, "^ref: (.+)$"); if (m.Success) { -// m_log.DebugFormat("[SERVER BASE]: Matched [{0}]", m.Groups[1].Value); + //m_log.DebugFormat("[SERVER BASE]: Matched [{0}]", m.Groups[1].Value); string gitRef = m.Groups[1].Value; - string gitRefPath = gitDir + gitRef; + string gitRefPath = Path.Combine(gitDir, gitRef); if (File.Exists(gitRefPath)) { -// m_log.DebugFormat("[SERVER BASE]: Found gitRefPath [{0}]", gitRefPath); - + //m_log.DebugFormat("[SERVER BASE]: Found gitRefPath [{0}]", gitRefPath); using (StreamReader refFile = File.OpenText(gitRefPath)) - { - string gitHash = refFile.ReadLine(); - m_version += gitHash.Substring(0, 7); - } + buildVersion = refFile.ReadLine(); + + if (!string.IsNullOrEmpty(buildVersion)) + m_version += buildVersion[..7]; } } } @@ -805,8 +798,7 @@ namespace OpenSim.Framework.Servers public string GetVersionText() { - return String.Format("Version: {0} (SIMULATION/{1} - SIMULATION/{2})", - m_version, VersionInfo.SimulationServiceVersionSupportedMin, VersionInfo.SimulationServiceVersionSupportedMax); + return $"Version: {m_version} (SIM-{VersionInfo.SimulationServiceVersionSupportedMin}/{VersionInfo.SimulationServiceVersionSupportedMax})"; } /// diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 62fd51a994..aa5755661c 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -1476,8 +1476,7 @@ namespace OpenSim.Framework using MemoryStream memoryStream = new(buffer); using CryptoStream cryptoStream = new(memoryStream, decryptor, CryptoStreamMode.Read); using StreamReader streamReader = new(cryptoStream); - - //string ret = streamReader.ReadToEnd(); + return streamReader.ReadToEnd(); } diff --git a/prebuild.xml b/prebuild.xml index 83231af184..f324aea385 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -10,7 +10,7 @@ true 4 false - CA1416,SYSLIB0011,SYSLIB0014 + CA1416,SYSLIB0011,SYSLIB0014,SYSLIB0039 bin true true @@ -28,7 +28,7 @@ true 4 false - CA1416,SYSLIB0011,SYSLIB0014 + CA1416,SYSLIB0011,SYSLIB0014,SYSLIB0039 bin false true