hash =
- new Rfc2898DeriveBytes(plainPassword, salt.ToArray(), iterations, m_Algorithm).GetBytes(m_HashSize);
+ new Rfc2898DeriveBytes(plainPassword, salt.ToArray(), iterations, HashAlgorithmName.SHA256).GetBytes(m_HashSize);
return hash.SequenceEqual(encryptedBytes.Slice(m_SaltSize + 2));
}
diff --git a/Projects/UOContent/Accounting/Security/SHA1PasswordProtection.cs b/Projects/UOContent/Accounting/Security/SHA1PasswordProtection.cs
index c0c73ffe7..bd0a091cc 100644
--- a/Projects/UOContent/Accounting/Security/SHA1PasswordProtection.cs
+++ b/Projects/UOContent/Accounting/Security/SHA1PasswordProtection.cs
@@ -22,7 +22,9 @@ namespace Server.Accounting.Security
public class SHA1PasswordProtection : IPasswordProtection
{
public static IPasswordProtection Instance = new SHA1PasswordProtection();
+#pragma warning disable CA5350
private readonly SHA1CryptoServiceProvider m_SHA1HashProvider = new SHA1CryptoServiceProvider();
+#pragma warning restore CA5350
public string EncryptPassword(string plainPassword)
{
diff --git a/Projects/UOContent/Commands/Attributes.cs b/Projects/UOContent/Commands/Attributes.cs
index 0703ac091..2abf56ce7 100644
--- a/Projects/UOContent/Commands/Attributes.cs
+++ b/Projects/UOContent/Commands/Attributes.cs
@@ -2,6 +2,7 @@ using System;
namespace Server
{
+ [AttributeUsage(AttributeTargets.Method)]
public class UsageAttribute : Attribute
{
public UsageAttribute(string usage) => Usage = usage;
@@ -9,6 +10,7 @@ namespace Server
public string Usage { get; }
}
+ [AttributeUsage(AttributeTargets.Method)]
public class DescriptionAttribute : Attribute
{
public DescriptionAttribute(string description) => Description = description;
@@ -16,6 +18,7 @@ namespace Server
public string Description { get; }
}
+ [AttributeUsage(AttributeTargets.Method)]
public class AliasesAttribute : Attribute
{
public AliasesAttribute(params string[] aliases) => Aliases = aliases;
diff --git a/Projects/UOContent/Commands/Batch.cs b/Projects/UOContent/Commands/Batch.cs
index 257126153..c04584b34 100644
--- a/Projects/UOContent/Commands/Batch.cs
+++ b/Projects/UOContent/Commands/Batch.cs
@@ -187,8 +187,7 @@ namespace Server.Commands
CommandSystem.Register("Batch", AccessLevel.Counselor, Batch_OnCommand);
}
- [Usage("Batch")]
- [Description("Allows multiple commands to be run at the same time.")]
+ [Usage("Batch"), Description("Allows multiple commands to be run at the same time.")]
public static void Batch_OnCommand(CommandEventArgs e)
{
e.Mobile.SendGump(new BatchGump(e.Mobile, new Batch()));
@@ -209,7 +208,7 @@ namespace Server.Commands
public void GetDetails(out string command, out string argString, out string[] args)
{
- var indexOf = Command.IndexOf(' ');
+ var indexOf = Command.IndexOf(' ', StringComparison.Ordinal);
if (indexOf >= 0)
{
diff --git a/Projects/UOContent/Commands/Docs.cs b/Projects/UOContent/Commands/Docs.cs
index 7864ecb38..63371c36b 100644
--- a/Projects/UOContent/Commands/Docs.cs
+++ b/Projects/UOContent/Commands/Docs.cs
@@ -11,7 +11,7 @@ using Server.Network;
namespace Server.Commands
{
- public class Docs
+ public static class Docs
{
private const int Iron = 0xCCCCDD;
private const int DullCopper = 0xAAAAAA;
@@ -109,8 +109,7 @@ namespace Server.Commands
CommandSystem.Register("DocGen", AccessLevel.Administrator, DocGen_OnCommand);
}
- [Usage("DocGen")]
- [Description("Generates RunUO documentation.")]
+ [Usage("DocGen"), Description("Generates RunUO documentation.")]
private static void DocGen_OnCommand(CommandEventArgs e)
{
World.Broadcast(0x35, true, "Documentation is being generated, please wait.");
@@ -332,7 +331,7 @@ namespace Server.Commands
if (type.IsGenericType)
{
- var index = type.Name.IndexOf('`');
+ var index = type.Name.IndexOf('`', StringComparison.Ordinal);
if (index > 0)
{
@@ -346,7 +345,7 @@ namespace Server.Commands
: new StringBuilder($"{rootType}");
nameBuilder.Append("<");
- fnamBuilder.Append("-");
+ fnamBuilder.Append('-');
linkBuilder.Append("<");
var typeArguments = type.GetGenericArguments();
@@ -364,7 +363,7 @@ namespace Server.Commands
var aliasedName = AliasForName(sanitizedName);
nameBuilder.Append(sanitizedName);
- fnamBuilder.Append("T");
+ fnamBuilder.Append('T');
if (DontLink(typeArguments[i]))
{
linkBuilder.Append($"{aliasedName}");
@@ -378,7 +377,7 @@ namespace Server.Commands
}
nameBuilder.Append(">");
- fnamBuilder.Append("-");
+ fnamBuilder.Append('-');
linkBuilder.Append(">");
name = nameBuilder.ToString();
@@ -407,7 +406,7 @@ namespace Server.Commands
public static string SanitizeType(string name)
{
- var anonymousType = name.Contains("<");
+ var anonymousType = name.Contains('<', StringComparison.Ordinal);
var sb = new StringBuilder(name);
for (var i = 0; i < ReplaceChars.Length; ++i)
{
@@ -466,7 +465,7 @@ namespace Server.Commands
return true;
}
- if (type.Namespace.StartsWith("Server"))
+ if (type.Namespace.StartsWith("Server", StringComparison.Ordinal))
{
return false;
}
@@ -489,11 +488,12 @@ namespace Server.Commands
}
var index = 0;
- var file = string.Concat(name, ext);
+ var file = $"{name}{ext}";
while (File.Exists(Path.Combine(root, file)))
{
- file = string.Concat(name, ++index, ext);
+ index++;
+ file = $"{name}{index}{ext}";
}
return file;
@@ -604,7 +604,7 @@ namespace Server.Commands
if (realType?.IsGenericType == true)
{
FormatGeneric(realType, out _, out _, out var linkName);
- aliased = linkName.Replace("@directory@", null);
+ aliased = linkName.Replace("@directory@", null, StringComparison.Ordinal);
}
else
{
@@ -621,7 +621,7 @@ namespace Server.Commands
aliased ??= realType?.Name ?? "";
}
- return string.Concat(prepend, aliased, append, name);
+ return $"{prepend}{aliased}{append}{name}";
}
private static bool Document()
@@ -1719,7 +1719,7 @@ namespace Server.Commands
{
line = line.Trim();
- if (line.Length == 0 || line.StartsWith("#"))
+ if (line.Length == 0 || line.StartsWith("#", StringComparison.Ordinal))
{
continue;
}
@@ -2029,16 +2029,11 @@ namespace Server.Commands
var aliases = attrs.Length == 0 ? null : attrs[0] as AliasesAttribute;
- var descString = desc.Description.Replace("<", "<").Replace(">", ">");
+ var descString = desc.Description
+ .Replace("<", "<", StringComparison.Ordinal)
+ .Replace(">", ">", StringComparison.Ordinal);
- if (aliases == null)
- {
- list.Add(new DocCommandEntry(e.AccessLevel, e.Command, null, usage.Usage, descString));
- }
- else
- {
- list.Add(new DocCommandEntry(e.AccessLevel, e.Command, aliases.Aliases, usage.Usage, descString));
- }
+ list.Add(new DocCommandEntry(e.AccessLevel, e.Command, aliases?.Aliases, usage.Usage, descString));
}
for (var i = 0; i < TargetCommands.AllCommands.Count; ++i)
@@ -2062,7 +2057,9 @@ namespace Server.Commands
aliases[j] = cmds[j + 1];
}
- desc = desc.Replace("<", "<").Replace(">", ">");
+ desc = desc
+ .Replace("<", "<", StringComparison.Ordinal)
+ .Replace(">", ">", StringComparison.Ordinal);
if (command.Supports != CommandSupport.Single)
{
@@ -2138,7 +2135,9 @@ namespace Server.Commands
aliases[j] = cmds[j + 1];
}
- desc = desc.Replace("<", "<").Replace(">", ">");
+ desc = desc
+ .Replace("<", "<", StringComparison.Ordinal)
+ .Replace(">", ">", StringComparison.Ordinal);
list.Add(new DocCommandEntry(command.AccessLevel, cmd, aliases, usage, desc));
}
@@ -2237,7 +2236,9 @@ namespace Server.Commands
{
html.Write(
"Usage: {0} {1} | ",
- usage.Replace("<", "<").Replace(">", ">"),
+ usage
+ .Replace("<", "<", StringComparison.Ordinal)
+ .Replace(">", ">", StringComparison.Ordinal),
desc
);
}
@@ -2245,7 +2246,9 @@ namespace Server.Commands
{
html.Write(
"Usage: {0} Alias{1}: ",
- usage.Replace("<", "<").Replace(">", ">"),
+ usage
+ .Replace("<", "<", StringComparison.Ordinal)
+ .Replace(">", ">", StringComparison.Ordinal),
aliases.Length == 1 ? "" : "es"
);
@@ -2564,7 +2567,7 @@ namespace Server.Commands
if (ifaceInfo == null)
{
FormatGeneric(iface, out _, out _, out var linkName);
- typeHtml.Write($"{linkName.Replace("@directory@", null)}");
+ typeHtml.Write($"{linkName.Replace("@directory@", null, StringComparison.Ordinal)}");
}
else
{
@@ -2910,7 +2913,7 @@ namespace Server.Commands
public string FileName => m_FileName;
public string TypeName => m_TypeName;
- public string LinkName(string dirRoot) => m_LinkName.Replace("@directory@", dirRoot);
+ public string LinkName(string dirRoot) => m_LinkName.Replace("@directory@", dirRoot, StringComparison.Ordinal);
}
private class SpeechEntry
@@ -3009,7 +3012,7 @@ namespace Server.Commands
return Body == e?.Body && BodyType == e.BodyType && Name == e.Name;
}
- public override int GetHashCode() => Body.BodyID ^ (int)BodyType ^ Name.GetHashCode();
+ public override int GetHashCode() => Body.BodyID ^ (int)BodyType ^ Name.GetHashCode(StringComparison.Ordinal);
}
public class BodyEntrySorter : IComparer
diff --git a/Projects/UOContent/Commands/DragEffects.cs b/Projects/UOContent/Commands/DragEffects.cs
index d67d0d393..d9ef33a38 100644
--- a/Projects/UOContent/Commands/DragEffects.cs
+++ b/Projects/UOContent/Commands/DragEffects.cs
@@ -7,8 +7,7 @@ namespace Server.Commands
CommandSystem.Register("DragEffects", AccessLevel.Developer, DragEffects_OnCommand);
}
- [Usage("DragEffects [enable=false]")]
- [Description("Enables or disables the item drag and drop effects.")]
+ [Usage("DragEffects [enable=false]"), Description("Enables or disables the item drag and drop effects.")]
public static void DragEffects_OnCommand(CommandEventArgs e)
{
if (e.Length == 0)
diff --git a/Projects/UOContent/Commands/Dupe.cs b/Projects/UOContent/Commands/Dupe.cs
index d78e616c3..a5f3d7c01 100644
--- a/Projects/UOContent/Commands/Dupe.cs
+++ b/Projects/UOContent/Commands/Dupe.cs
@@ -13,8 +13,7 @@ namespace Server.Commands
CommandSystem.Register("DupeInBag", AccessLevel.GameMaster, DupeInBag_OnCommand);
}
- [Usage("Dupe [amount]")]
- [Description("Dupes a targeted item.")]
+ [Usage("Dupe [amount]"), Description("Dupes a targeted item.")]
private static void Dupe_OnCommand(CommandEventArgs e)
{
var amount = 1;
@@ -27,8 +26,7 @@ namespace Server.Commands
e.Mobile.SendMessage("What do you wish to dupe?");
}
- [Usage("DupeInBag ")]
- [Description("Dupes an item at it's current location (count) number of times.")]
+ [Usage("DupeInBag "), Description("Dupes an item at it's current location (count) number of times.")]
private static void DupeInBag_OnCommand(CommandEventArgs e)
{
var amount = 1;
diff --git a/Projects/UOContent/Commands/ExportWSC.cs b/Projects/UOContent/Commands/ExportWSC.cs
index 67e9c4c52..2ab02bbe8 100644
--- a/Projects/UOContent/Commands/ExportWSC.cs
+++ b/Projects/UOContent/Commands/ExportWSC.cs
@@ -4,7 +4,7 @@ using Server.Items;
namespace Server.Commands
{
- public class ExportCommand
+ public static class ExportCommand
{
private const string ExportFile = @"C:\Uo\WorldForge\items.wsc";
diff --git a/Projects/UOContent/Commands/Generic/Commands/Commands.cs b/Projects/UOContent/Commands/Generic/Commands/Commands.cs
index c03abb594..5485ffed0 100644
--- a/Projects/UOContent/Commands/Generic/Commands/Commands.cs
+++ b/Projects/UOContent/Commands/Generic/Commands/Commands.cs
@@ -12,7 +12,7 @@ using Server.Spells;
namespace Server.Commands.Generic
{
- public class TargetCommands
+ public static class TargetCommands
{
public static List AllCommands { get; } = new List();
@@ -788,7 +788,7 @@ namespace Server.Commands.Generic
var result = Properties.GetValue(e.Mobile, obj, e.GetString(i));
if (result == "Property not found." || result == "Property is write only." ||
- result.StartsWith("Getting this property"))
+ result.StartsWith("Getting this property", StringComparison.Ordinal))
{
LogFailure(result);
}
diff --git a/Projects/UOContent/Commands/Generic/Implementors/BaseCommandImplementor.cs b/Projects/UOContent/Commands/Generic/Implementors/BaseCommandImplementor.cs
index 9e4321a90..b7d94c243 100644
--- a/Projects/UOContent/Commands/Generic/Implementors/BaseCommandImplementor.cs
+++ b/Projects/UOContent/Commands/Generic/Implementors/BaseCommandImplementor.cs
@@ -194,7 +194,7 @@ namespace Server.Commands.Generic
sb.Append(' ');
}
- if (args[i].IndexOf(' ') >= 0)
+ if (args[i].Contains(' ', StringComparison.Ordinal))
{
sb.Append('"');
sb.Append(args[i]);
diff --git a/Projects/UOContent/Commands/Generic/Implementors/IPAddressCommandImplementor.cs b/Projects/UOContent/Commands/Generic/Implementors/IPAddressCommandImplementor.cs
index 8af8c9c1b..39f06d8ab 100644
--- a/Projects/UOContent/Commands/Generic/Implementors/IPAddressCommandImplementor.cs
+++ b/Projects/UOContent/Commands/Generic/Implementors/IPAddressCommandImplementor.cs
@@ -38,11 +38,8 @@ namespace Server.Commands.Generic
var list = new List |