diff --git a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs index 423c1dc75e..7aa8b1ae1e 100644 --- a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs +++ b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs @@ -222,7 +222,7 @@ namespace OpenSim.Framework.Serialization.External using (StringWriter sw = new StringWriter()) using (XmlTextWriter writer = new XmlTextWriter(sw)) using (XmlTextReader wrappedReader = new XmlTextReader(xmlData, XmlNodeType.Element, null)) - using (XmlReader reader = XmlReader.Create(wrappedReader, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment, DtdProcessing = DtdProcessing.Ignore})) + using (XmlReader reader = XmlReader.Create(wrappedReader, Util.SharedXmlReaderSettings)) { TransformXml(reader, writer, sceneName, homeURL, userService, scopeID); diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 0a539a3e96..d2524f1af2 100755 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -1160,8 +1160,7 @@ namespace OpenSim.Region.CoreModules.Asset gatherer.AddGathered(s.RegionInfo.RegionSettings.TerrainTexture4, (sbyte)AssetType.Texture); gatherer.AddGathered(s.RegionInfo.RegionSettings.TerrainImageID, (sbyte)AssetType.Texture); - if (s.RegionEnvironment is not null) - s.RegionEnvironment.GatherAssets(gatheredids); + s.RegionEnvironment?.GatherAssets(gatheredids); if (s.LandChannel is not null) { diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index c6ae3fc3ee..3209c630c1 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -372,41 +372,37 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends public virtual bool SendFriendsOnlineIfNeeded(IClientAPI client) { - if (client == null) + if (client is null) return false; - UUID agentID = client.AgentId; - // Check if the online friends list is needed lock (m_NeedsListOfOnlineFriends) { - if (!m_NeedsListOfOnlineFriends.Remove(agentID)) + if (!m_NeedsListOfOnlineFriends.Remove(client.AgentId)) return false; } // Send the friends online - List online = GetOnlineFriends(agentID); + List online = GetOnlineFriends(client.AgentId); if (online.Count > 0) client.SendAgentOnline(online.ToArray()); // Send outstanding friendship offers List outstanding = new List(); - FriendInfo[] friends = GetFriendsFromCache(agentID); + FriendInfo[] friends = GetFriendsFromCache(client.AgentId); foreach (FriendInfo fi in friends) { if (fi.TheirFlags == -1) outstanding.Add(fi.Friend); } - GridInstantMessage im = new GridInstantMessage(client.Scene, UUID.Zero, String.Empty, agentID, (byte)InstantMessageDialog.FriendshipOffered, + GridInstantMessage im = new GridInstantMessage(client.Scene, UUID.Zero, String.Empty, client.AgentId, (byte)InstantMessageDialog.FriendshipOffered, "Will you be my friend?", true, Vector3.Zero); foreach (string fid in outstanding) { - UUID fromAgentID; - string firstname = "Unknown", lastname = "UserFMSFOIN"; - if (!GetAgentInfo(client.Scene.RegionInfo.ScopeID, fid, out fromAgentID, out firstname, out lastname)) + if (!GetAgentInfo(client.Scene.RegionInfo.ScopeID, fid, out UUID fromAgentID, out string firstname, out string lastname)) { m_log.DebugFormat("[FRIENDS MODULE]: skipping malformed friend {0}", fid); continue; @@ -418,7 +414,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends im.imSessionID = im.fromAgentID; im.message = FriendshipMessage(fid); - LocalFriendshipOffered(agentID, im); + LocalFriendshipOffered(client.AgentId, im); } return true; diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs index 6d58968ce9..031c12647d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs @@ -203,10 +203,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends if (base.SendFriendsOnlineIfNeeded(client)) { AgentCircuitData aCircuit = ((Scene)client.Scene).AuthenticateHandler.GetAgentCircuitData(client.AgentId); - if (aCircuit != null && (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0) + if (aCircuit is not null && (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0) { UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, client.AgentId); - if (account == null) // foreign + if (account is null) // foreign { FriendInfo[] friends = GetFriendsFromCache(client.AgentId); foreach (FriendInfo f in friends) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 459d349ece..523710e857 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2579,7 +2579,7 @@ namespace OpenSim.Region.Framework.Scenes { using (XmlTextReader wrappedReader = new XmlTextReader(xmlData, XmlNodeType.Element, null)) { - using (XmlReader reader = XmlReader.Create(wrappedReader, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment, DtdProcessing = DtdProcessing.Ignore})) + using (XmlReader reader = XmlReader.Create(wrappedReader, Util.SharedXmlReaderSettings)) { reader.Read(); bool isSingleObject = reader.Name != "CoalescedObject"; diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 2ad5689167..6d0ddb0f3b 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -59,7 +59,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization string fixedData = ExternalRepresentationUtils.SanitizeXml(xmlData); using (XmlTextReader wrappedReader = new(fixedData, XmlNodeType.Element, null)) { - using (XmlReader reader = XmlReader.Create(wrappedReader, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment, DtdProcessing = DtdProcessing.Ignore })) + using (XmlReader reader = XmlReader.Create(wrappedReader, Util.SharedXmlReaderSettings)) { try { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 2b626c5409..75e474d95e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3467,7 +3467,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGiveMoney(LSL_Key destination, LSL_Integer amount) { - if (m_item.PermsGranter.IsZero()) return 0; @@ -3484,17 +3483,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } IMoneyModule money = World.RequestModuleInterface(); - if (money == null) + if (money is null) { NotImplemented("llGiveMoney"); return 0; } - Action act = dontcare => + void act(string _) { money.ObjectGiveMoney(m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, - toID, amount,UUID.Zero, out string reason); - }; + toID, amount, UUID.Zero, out _); + } m_AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, act); return 0; diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRDelegateCommon.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRDelegateCommon.cs index 0a49ffe835..041d11ab92 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRDelegateCommon.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRDelegateCommon.cs @@ -38,8 +38,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine private string sig; // rettype(arg1type,arg2type,...), eg, "void(list,string,integer)" private Type type; // resultant delegate type - private static Dictionary delegateCommons = new Dictionary(); - private static Dictionary delegateCommonsBySysType = new Dictionary(); + private readonly static Dictionary delegateCommons = new(); + private readonly static Dictionary delegateCommonsBySysType = new(); private static ModuleBuilder delegateModuleBuilder = null; public static Type[] constructorArgTypes = new Type[] { typeof(object), typeof(IntPtr) }; @@ -54,9 +54,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine { if(!delegateCommons.TryGetValue(sig, out dc)) { - dc = new DelegateCommon(); - dc.sig = sig; - dc.type = CreateDelegateType(sig, ret, args); + dc = new DelegateCommon + { + sig = sig, + type = CreateDelegateType(sig, ret, args) + }; delegateCommons.Add(sig, dc); delegateCommonsBySysType.Add(dc.type, dc); } @@ -72,7 +74,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine if(!delegateCommons.TryGetValue(sig, out dc)) dc = null; } - return (dc == null) ? null : dc.type; + return dc?.type; } public static string TryGetName(Type t) @@ -83,7 +85,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine if(!delegateCommonsBySysType.TryGetValue(t, out dc)) dc = null; } - return (dc == null) ? null : dc.sig; + return dc?.sig; } // http://blog.bittercoder.com/PermaLink,guid,a770377a-b1ad-4590-9145-36381757a52b.aspx @@ -91,8 +93,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine { if(delegateModuleBuilder == null) { - AssemblyName assembly = new AssemblyName(); - assembly.Name = "CustomDelegateAssembly"; + AssemblyName assembly = new() + { + Name = "CustomDelegateAssembly" + }; AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(assembly, AssemblyBuilderAccess.Run); delegateModuleBuilder = assemblyBuilder.DefineDynamicModule("CustomDelegateModule"); } diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRInternalFuncDict.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRInternalFuncDict.cs index ca7c372d6d..65d428cd94 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRInternalFuncDict.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRInternalFuncDict.cs @@ -68,12 +68,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine TokenName name = new TokenName(null, param.Name); argDecl.AddArg(type, name); } - TokenDeclVar declFunc = new TokenDeclVar(null, null, null); - declFunc.name = new TokenName(null, key); - declFunc.retType = TokenType.FromSysType(null, ifaceMethod.ReturnType); - declFunc.argDecl = argDecl; + TokenDeclVar declFunc = new TokenDeclVar(null, null, null) + { + name = new TokenName(null, key), + retType = TokenType.FromSysType(null, ifaceMethod.ReturnType), + argDecl = argDecl + }; - // Add the TokenDeclVar struct to the dictionary. + // Add the TokenDeclVar struct to the dictionary. this.AddEntry(declFunc); } catch(Exception except) @@ -82,7 +84,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine string msg = except.ToString(); int i = msg.IndexOf("\n"); if(i > 0) - msg = msg.Substring(0, i); + msg = msg[..i]; Console.WriteLine("InternalFuncDict*: {0}: {1}", key, msg); ///??? IGNORE ANY THAT FAIL - LIKE UNRECOGNIZED TYPE ???/// diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptReduce.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptReduce.cs index b31681ad38..869628d8c2 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptReduce.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptReduce.cs @@ -5144,10 +5144,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine // It leaves the types in retStr/argStrs for resolution after // all definitions have been read from the object file in case // there are forward references. - if(retType == null) - { - retType = MakeTypeToken(retStr); - } + retType ??= MakeTypeToken(retStr); if(argTypes == null) { nArgs = argStrs.Length; @@ -5196,16 +5193,16 @@ namespace OpenSim.Region.ScriptEngine.Yengine // Name it after the whole signature string. StringBuilder sb = new StringBuilder("$inline"); sb.Append(retType.ToString()); - sb.Append("("); + sb.Append('('); bool first = true; foreach(TokenType at in argTypes) { if(!first) - sb.Append(","); + sb.Append(','); sb.Append(at.ToString()); first = false; } - sb.Append(")"); + sb.Append(')'); string inlname = sb.ToString(); if(!inlines.TryGetValue(inlname, out decldel)) { @@ -5505,16 +5502,16 @@ namespace OpenSim.Region.ScriptEngine.Yengine // No such luck, create a new anonymous declaration. StringBuilder sb = new StringBuilder("$anondel$"); sb.Append(retType.ToString()); - sb.Append("("); + sb.Append('('); bool first = true; foreach(TokenType at in argTypes) { if(!first) - sb.Append(","); + sb.Append(','); sb.Append(at.ToString()); first = false; } - sb.Append(")"); + sb.Append(')'); TokenName name = new TokenName(t, sb.ToString()); decldel = new TokenDeclSDTypeDelegate(name); decldel.SetRetArgTypes(retType, argTypes); @@ -5666,10 +5663,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine private string argSig = null; public string GetArgSig() { - if(argSig == null) - { - argSig = ScriptCodeGen.ArgSigString(types); - } + argSig ??= ScriptCodeGen.ArgSigString(types); return argSig; } } @@ -6688,7 +6682,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine t.DebString(sb); first = false; } - sb.Append(")"); + sb.Append(')'); } } @@ -7934,7 +7928,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine { sb.Append("if "); testRVal.DebString(sb); - sb.Append(" "); + sb.Append(' '); trueStmt.DebString(sb); if(elseStmt != null) {