diff --git a/.editorconfig b/.editorconfig index 7b3f63dc7c..8d57dda4ac 100644 --- a/.editorconfig +++ b/.editorconfig @@ -634,6 +634,9 @@ dotnet_diagnostic.CA1047.severity = warning # Declare types in namespaces. dotnet_diagnostic.CA1050.severity = warning +# Static holder types should be 'Static' or 'NotInheritable'. +dotnet_diagnostic.CA1052.severity = warning + # Do not hide base class methods. dotnet_diagnostic.CA1061.severity = warning diff --git a/OpenRA.Game/Map/TerrainInfo.cs b/OpenRA.Game/Map/TerrainInfo.cs index e1ccc343b6..24b3d12fd0 100644 --- a/OpenRA.Game/Map/TerrainInfo.cs +++ b/OpenRA.Game/Map/TerrainInfo.cs @@ -69,7 +69,7 @@ namespace OpenRA // HACK: Temporary placeholder to avoid having to change all the traits that reference this constant. // This can be removed after the palette references have been moved from traits to sequences. - public class TileSet + public static class TileSet { public const string TerrainPaletteInternalName = "terrain"; } diff --git a/OpenRA.Game/Network/GeoIP.cs b/OpenRA.Game/Network/GeoIP.cs index 834dd8f644..fee2056058 100644 --- a/OpenRA.Game/Network/GeoIP.cs +++ b/OpenRA.Game/Network/GeoIP.cs @@ -19,7 +19,7 @@ using ICSharpCode.SharpZipLib.Zip; namespace OpenRA.Network { - public class GeoIP + public static class GeoIP { sealed class IP2LocationReader { diff --git a/OpenRA.Game/Network/Nat.cs b/OpenRA.Game/Network/Nat.cs index 8d008a74a6..b26d54051f 100644 --- a/OpenRA.Game/Network/Nat.cs +++ b/OpenRA.Game/Network/Nat.cs @@ -17,7 +17,7 @@ namespace OpenRA.Network { public enum NatStatus { Enabled, Disabled, NotSupported } - public class Nat + public static class Nat { public static NatStatus Status => NatUtility.IsSearching ? natDevice != null ? NatStatus.Enabled : NatStatus.NotSupported : NatStatus.Disabled; diff --git a/OpenRA.Game/Support/HttpClientFactory.cs b/OpenRA.Game/Support/HttpClientFactory.cs index d947d7ad34..7450e9d3aa 100644 --- a/OpenRA.Game/Support/HttpClientFactory.cs +++ b/OpenRA.Game/Support/HttpClientFactory.cs @@ -14,7 +14,7 @@ using System.Net.Http; namespace OpenRA.Support { - public class HttpClientFactory + public static class HttpClientFactory { #if NET5_0_OR_GREATER const int MaxConnectionPerServer = 20; diff --git a/OpenRA.Mods.Common/FileFormats/ImaAdpcmReader.cs b/OpenRA.Mods.Common/FileFormats/ImaAdpcmReader.cs index 018103a40d..795c77fd3c 100644 --- a/OpenRA.Mods.Common/FileFormats/ImaAdpcmReader.cs +++ b/OpenRA.Mods.Common/FileFormats/ImaAdpcmReader.cs @@ -13,7 +13,7 @@ using System.IO; namespace OpenRA.Mods.Common.FileFormats { - public class ImaAdpcmReader + public static class ImaAdpcmReader { static readonly int[] IndexAdjust = { -1, -1, -1, -1, 2, 4, 6, 8 }; static readonly int[] StepTable = diff --git a/OpenRA.Mods.Common/FileFormats/WestwoodCompressedReader.cs b/OpenRA.Mods.Common/FileFormats/WestwoodCompressedReader.cs index 6cd73ec394..97b509ced5 100644 --- a/OpenRA.Mods.Common/FileFormats/WestwoodCompressedReader.cs +++ b/OpenRA.Mods.Common/FileFormats/WestwoodCompressedReader.cs @@ -15,7 +15,7 @@ using System; namespace OpenRA.Mods.Common.FileFormats { - public class WestwoodCompressedReader + public static class WestwoodCompressedReader { static readonly int[] AudWsStepTable2 = { -2, -1, 0, 1 }; static readonly int[] AudWsStepTable4 = { -9, -8, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 8 }; diff --git a/OpenRA.Mods.Common/Installer/InstallerUtils.cs b/OpenRA.Mods.Common/Installer/InstallerUtils.cs index 0f0f71a42e..726da2ac01 100644 --- a/OpenRA.Mods.Common/Installer/InstallerUtils.cs +++ b/OpenRA.Mods.Common/Installer/InstallerUtils.cs @@ -16,7 +16,7 @@ using FS = OpenRA.FileSystem.FileSystem; namespace OpenRA.Mods.Common.Installer { - public class InstallerUtils + public static class InstallerUtils { public static bool IsValidSourcePath(string path, ModContent.ModSource source) { diff --git a/OpenRA.Mods.Common/Lint/LintExts.cs b/OpenRA.Mods.Common/Lint/LintExts.cs index de50114419..5803dad879 100644 --- a/OpenRA.Mods.Common/Lint/LintExts.cs +++ b/OpenRA.Mods.Common/Lint/LintExts.cs @@ -19,7 +19,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Lint { - public class LintExts + public static class LintExts { public static IEnumerable GetFieldValues(object ruleInfo, FieldInfo fieldInfo, LintDictionaryReference dictionaryReference = LintDictionaryReference.None) diff --git a/OpenRA.Mods.Common/Traits/Encyclopedia.cs b/OpenRA.Mods.Common/Traits/Encyclopedia.cs index e978764c42..232b6ad312 100644 --- a/OpenRA.Mods.Common/Traits/Encyclopedia.cs +++ b/OpenRA.Mods.Common/Traits/Encyclopedia.cs @@ -27,9 +27,8 @@ namespace OpenRA.Mods.Common.Traits public override object Create(ActorInitializer init) { return Encyclopedia.Instance; } } - public class Encyclopedia + public readonly struct Encyclopedia { - public static readonly Encyclopedia Instance = new(); - Encyclopedia() { } + public static readonly object Instance = default(Encyclopedia); } } diff --git a/OpenRA.Mods.Common/Traits/Render/RenderUtils.cs b/OpenRA.Mods.Common/Traits/Render/RenderUtils.cs index a59078e790..59a46a67f7 100644 --- a/OpenRA.Mods.Common/Traits/Render/RenderUtils.cs +++ b/OpenRA.Mods.Common/Traits/Render/RenderUtils.cs @@ -11,7 +11,7 @@ namespace OpenRA.Mods.Common.Traits.Render { - public class RenderUtils + public static class RenderUtils { public static int ZOffsetFromCenter(Actor self, WPos pos, int offset) { diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/OrderButtonsChromeLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/OrderButtonsChromeLogic.cs index 797d46e7d3..4f57c7f502 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/OrderButtonsChromeLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/OrderButtonsChromeLogic.cs @@ -55,7 +55,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic } } - public class OrderButtonsChromeUtils + public static class OrderButtonsChromeUtils { public static void BindOrderButton(World world, ButtonWidget w, string icon) where T : IOrderGenerator, new()