Ensure editorconfig naming styles align with StyleCop SA13XX style rules.
Aligns the naming conventions defined in editorconfig (dotnet_naming_style, dotnet_naming_symbols, dotnet_naming_rule) which are reported under the IDE1006 rule with the existing StyleCop rules from the SA13XX range. This ensures the two rulesets agree when rejecting and accepting naming conventions within the IDE, with a few edges cases where only one ruleset can enforce the convention. IDE1006 allows use to specify a naming convention for type parameters, const locals and protected readonly fields which SA13XX cannot enforce. Some StyleCop SA13XX rules such as SA1309 'Field names should not begin with underscore' are not possible to enforce with the naming rules of IDE1006. Therefore we enable the IDE1006 as a build time warning to enforce conventions and extend them. We disable SA13XX rules that can now be covered by IDE1006 to avoid double-reporting but leave the remaining SA13XX rules that cover additional cases enabled. We also re-enable the SA1311 rule convention but enforce it via IDE1006, requiring some violations to be fixed or duplication of existing suppressions. Most violations fixes are trivial renames with the following exception. In ActorInitializer.cs, we prefer to make the fields private instead. ValueActorInit provides a publicly accessible property for access and OwnerInit provides a publicly accessible method. Health.cs is adjusted to access the property base instead when overriding. The reflection calls must be adjusted to target the base class specifically, as searching for a private field from the derived class will fail to locate it on the base class. Unused suppressions were removed.
This commit is contained in:
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.FileFormats
|
||||
public static readonly int MAXBITS = 13; // maximum code length
|
||||
public static readonly int MAXWIN = 4096; // maximum window size
|
||||
|
||||
static readonly byte[] litlen =
|
||||
static readonly byte[] LitLen =
|
||||
{
|
||||
11, 124, 8, 7, 28, 7, 188, 13, 76, 4,
|
||||
10, 8, 12, 10, 12, 10, 8, 23, 8, 9,
|
||||
@@ -40,28 +40,28 @@ namespace OpenRA.Mods.Common.FileFormats
|
||||
};
|
||||
|
||||
// bit lengths of length codes 0..15
|
||||
static readonly byte[] lenlen = { 2, 35, 36, 53, 38, 23 };
|
||||
static readonly byte[] LenLen = { 2, 35, 36, 53, 38, 23 };
|
||||
|
||||
// bit lengths of distance codes 0..63
|
||||
static readonly byte[] distlen = { 2, 20, 53, 230, 247, 151, 248 };
|
||||
static readonly byte[] DistLen = { 2, 20, 53, 230, 247, 151, 248 };
|
||||
|
||||
// base for length codes
|
||||
static readonly short[] lengthbase =
|
||||
static readonly short[] LengthBase =
|
||||
{
|
||||
3, 2, 4, 5, 6, 7, 8, 9, 10, 12,
|
||||
16, 24, 40, 72, 136, 264
|
||||
};
|
||||
|
||||
// extra bits for length codes
|
||||
static readonly byte[] extra =
|
||||
static readonly byte[] Extra =
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 2,
|
||||
3, 4, 5, 6, 7, 8
|
||||
};
|
||||
|
||||
static readonly Huffman litcode = new Huffman(litlen, litlen.Length, 256);
|
||||
static readonly Huffman lencode = new Huffman(lenlen, lenlen.Length, 16);
|
||||
static readonly Huffman distcode = new Huffman(distlen, distlen.Length, 64);
|
||||
static readonly Huffman LitCode = new Huffman(LitLen, LitLen.Length, 256);
|
||||
static readonly Huffman LenCode = new Huffman(LenLen, LenLen.Length, 16);
|
||||
static readonly Huffman DistCode = new Huffman(DistLen, DistLen.Length, 64);
|
||||
|
||||
/// <summary>PKWare Compression Library stream.</summary>
|
||||
/// <param name="input">Compressed input stream.</param>
|
||||
@@ -98,8 +98,8 @@ namespace OpenRA.Mods.Common.FileFormats
|
||||
if (br.ReadBits(1) == 1)
|
||||
{
|
||||
// Length
|
||||
var symbol = Decode(lencode, br);
|
||||
var len = lengthbase[symbol] + br.ReadBits(extra[symbol]);
|
||||
var symbol = Decode(LenCode, br);
|
||||
var len = LengthBase[symbol] + br.ReadBits(Extra[symbol]);
|
||||
|
||||
// Magic number for "done"
|
||||
if (len == 519)
|
||||
@@ -113,7 +113,7 @@ namespace OpenRA.Mods.Common.FileFormats
|
||||
|
||||
// Distance
|
||||
symbol = len == 2 ? 2 : dict;
|
||||
var dist = Decode(distcode, br) << symbol;
|
||||
var dist = Decode(DistCode, br) << symbol;
|
||||
dist += br.ReadBits(symbol);
|
||||
dist++;
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace OpenRA.Mods.Common.FileFormats
|
||||
else
|
||||
{
|
||||
// literal value
|
||||
var symbol = encodedLiterals ? Decode(litcode, br) : br.ReadBits(8);
|
||||
var symbol = encodedLiterals ? Decode(LitCode, br) : br.ReadBits(8);
|
||||
outBuffer[next++] = (byte)symbol;
|
||||
if (next == MAXWIN)
|
||||
{
|
||||
|
||||
@@ -55,8 +55,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
: base(wr, ai, info, init)
|
||||
{
|
||||
this.info = info;
|
||||
var previewInit = new ActorPreviewInitializer(actorInfo, wr, init);
|
||||
preview = actorInfo.TraitInfos<IRenderActorPreviewInfo>()
|
||||
var previewInit = new ActorPreviewInitializer(ActorInfo, wr, init);
|
||||
preview = ActorInfo.TraitInfos<IRenderActorPreviewInfo>()
|
||||
.SelectMany(rpi => rpi.RenderPreview(previewInit))
|
||||
.ToArray();
|
||||
}
|
||||
@@ -72,7 +72,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
protected override IEnumerable<IRenderable> RenderInner(WorldRenderer wr, CPos topLeft, Dictionary<CPos, PlaceBuildingCellType> footprint)
|
||||
{
|
||||
var centerPosition = wr.World.Map.CenterOfCell(topLeft) + centerOffset;
|
||||
var centerPosition = wr.World.Map.CenterOfCell(topLeft) + CenterOffset;
|
||||
var previewRenderables = preview
|
||||
.SelectMany(p => p.Render(wr, centerPosition));
|
||||
|
||||
|
||||
@@ -46,8 +46,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public class FootprintPlaceBuildingPreviewPreview : IPlaceBuildingPreview
|
||||
{
|
||||
protected readonly ActorInfo actorInfo;
|
||||
protected readonly WVec centerOffset;
|
||||
protected readonly ActorInfo ActorInfo;
|
||||
protected readonly WVec CenterOffset;
|
||||
readonly FootprintPlaceBuildingPreviewInfo info;
|
||||
readonly IPlaceBuildingDecorationInfo[] decorations;
|
||||
readonly int2 topLeftScreenOffset;
|
||||
@@ -56,13 +56,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public FootprintPlaceBuildingPreviewPreview(WorldRenderer wr, ActorInfo ai, FootprintPlaceBuildingPreviewInfo info, TypeDictionary init)
|
||||
{
|
||||
actorInfo = ai;
|
||||
ActorInfo = ai;
|
||||
this.info = info;
|
||||
decorations = actorInfo.TraitInfos<IPlaceBuildingDecorationInfo>().ToArray();
|
||||
decorations = ActorInfo.TraitInfos<IPlaceBuildingDecorationInfo>().ToArray();
|
||||
|
||||
var world = wr.World;
|
||||
centerOffset = actorInfo.TraitInfo<BuildingInfo>().CenterOffset(world);
|
||||
topLeftScreenOffset = -wr.ScreenPxOffset(centerOffset);
|
||||
CenterOffset = ActorInfo.TraitInfo<BuildingInfo>().CenterOffset(world);
|
||||
topLeftScreenOffset = -wr.ScreenPxOffset(CenterOffset);
|
||||
|
||||
var tileset = world.Map.Tileset.ToLowerInvariant();
|
||||
if (world.Map.Rules.Sequences.HasSequence("overlay", $"build-valid-{tileset}"))
|
||||
@@ -106,9 +106,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
protected virtual IEnumerable<IRenderable> RenderAnnotations(WorldRenderer wr, CPos topLeft)
|
||||
{
|
||||
var centerPosition = wr.World.Map.CenterOfCell(topLeft) + centerOffset;
|
||||
var centerPosition = wr.World.Map.CenterOfCell(topLeft) + CenterOffset;
|
||||
foreach (var d in decorations)
|
||||
foreach (var r in d.RenderAnnotations(wr, wr.World, actorInfo, centerPosition))
|
||||
foreach (var r in d.RenderAnnotations(wr, wr.World, ActorInfo, centerPosition))
|
||||
yield return r;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return parents;
|
||||
|
||||
var sma = world.WorldActor.Trait<SpawnMapActors>();
|
||||
return value.Select(n => sma.Actors[n]).ToArray();
|
||||
return Value.Select(n => sma.Actors[n]).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
foreach (var r in RenderFootprint(wr, topLeft, footprint, info.FootprintUnderPreview))
|
||||
yield return r;
|
||||
|
||||
var centerPosition = wr.World.Map.CenterOfCell(topLeft) + centerOffset;
|
||||
var centerPosition = wr.World.Map.CenterOfCell(topLeft) + CenterOffset;
|
||||
foreach (var r in preview.Render(centerPosition, WVec.Zero, 0, palette))
|
||||
{
|
||||
if (info.SequenceAlpha < 1f && r is IModifyableRenderable mr)
|
||||
|
||||
@@ -252,6 +252,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
get
|
||||
{
|
||||
var value = base.Value;
|
||||
if (value < 0 || (value == 0 && !allowZero))
|
||||
return 1;
|
||||
|
||||
|
||||
@@ -27,11 +27,11 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
IDecoration[] decorations;
|
||||
IDecoration[] selectedDecorations;
|
||||
|
||||
protected readonly SelectionDecorationsBaseInfo info;
|
||||
protected readonly SelectionDecorationsBaseInfo Info;
|
||||
|
||||
public SelectionDecorationsBase(SelectionDecorationsBaseInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
Info = info;
|
||||
}
|
||||
|
||||
void INotifyCreated.Created(Actor self)
|
||||
@@ -86,7 +86,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
var displayExtra = selected || rollover || (regularWorld && statusBars != StatusBarsType.Standard);
|
||||
|
||||
if (selected)
|
||||
foreach (var r in RenderSelectionBox(self, wr, info.SelectionBoxColor))
|
||||
foreach (var r in RenderSelectionBox(self, wr, Info.SelectionBoxColor))
|
||||
yield return r;
|
||||
|
||||
if (displayHealth || displayExtra)
|
||||
|
||||
@@ -57,14 +57,14 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
|
||||
public abstract class WithDecorationBase<InfoType> : ConditionalTrait<InfoType>, IDecoration where InfoType : WithDecorationBaseInfo
|
||||
{
|
||||
protected readonly Actor self;
|
||||
protected readonly Actor Self;
|
||||
int2 conditionalOffset;
|
||||
BlinkState[] blinkPattern;
|
||||
|
||||
public WithDecorationBase(Actor self, InfoType info)
|
||||
: base(info)
|
||||
{
|
||||
this.self = self;
|
||||
Self = self;
|
||||
blinkPattern = info.BlinkPattern;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common.UpdateRules.Rules;
|
||||
|
||||
@@ -30,8 +29,6 @@ namespace OpenRA.Mods.Common.UpdateRules
|
||||
// can be merged back into bleed by replacing the forking-playtest-to-bleed path
|
||||
// with the prep playtest-to-playtest-to-release paths and finally a new/modified
|
||||
// release-to-bleed path.
|
||||
[SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1118:ParameterMustNotSpanMultipleLines",
|
||||
Justification = "Extracting update lists to temporary variables obfuscates the definitions.")]
|
||||
static readonly UpdatePath[] Paths =
|
||||
{
|
||||
new UpdatePath("release-20200202", "release-20200503", new UpdateRule[]
|
||||
|
||||
@@ -331,7 +331,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
}
|
||||
|
||||
// TODO: fix this -- will have bitrotted pretty badly.
|
||||
static readonly Dictionary<string, Color> namedColorMapping = new Dictionary<string, Color>()
|
||||
static readonly Dictionary<string, Color> NamedColorMapping = new Dictionary<string, Color>()
|
||||
{
|
||||
{ "gold", Color.FromArgb(246, 214, 121) },
|
||||
{ "blue", Color.FromArgb(226, 230, 246) },
|
||||
@@ -353,7 +353,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
OwnsWorld = section == "Neutral",
|
||||
NonCombatant = section == "Neutral",
|
||||
Faction = faction,
|
||||
Color = namedColorMapping[color]
|
||||
Color = NamedColorMapping[color]
|
||||
};
|
||||
|
||||
var neutral = new[] { "Neutral" };
|
||||
|
||||
@@ -11,15 +11,12 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
[SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1203:ConstantsMustAppearBeforeFields",
|
||||
Justification = "SystemInformation version should be defined next to the dictionary it refers to.")]
|
||||
public class SystemInfoPromptLogic : ChromeLogic
|
||||
{
|
||||
// Increment the version number when adding new stats
|
||||
|
||||
Reference in New Issue
Block a user