Silence IDE0290.
This rule recommends use of primary constructors. Apply the suggestions on simple POCOs, adjusting some to readonly/structs/records at the same time. For more complex classes, the use of primary constructors is more distracting than helpful, so silence the rule. IDEs can still offer fixes for using primary constructors, but it will not show up as a build issue.
This commit is contained in:
committed by
Gustas Kažukauskas
parent
3de6a5fd5a
commit
36660b89e9
@@ -40,18 +40,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public class ExternalCondition : ITick, INotifyCreated, INotifyOwnerChanged
|
||||
{
|
||||
readonly struct TimedToken
|
||||
readonly struct TimedToken(int token, Actor self, object source, int duration)
|
||||
{
|
||||
public readonly int Expires;
|
||||
public readonly int Token;
|
||||
public readonly object Source;
|
||||
|
||||
public TimedToken(int token, Actor self, object source, int duration)
|
||||
{
|
||||
Token = token;
|
||||
Expires = self.World.WorldTick + duration;
|
||||
Source = source;
|
||||
}
|
||||
public readonly int Expires = self.World.WorldTick + duration;
|
||||
public readonly int Token = token;
|
||||
public readonly object Source = source;
|
||||
}
|
||||
|
||||
public readonly ExternalConditionInfo Info;
|
||||
|
||||
@@ -30,20 +30,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public class Demolishable : ConditionalTrait<DemolishableInfo>, IDemolishable, ITick, INotifyOwnerChanged
|
||||
{
|
||||
sealed class DemolishAction
|
||||
sealed class DemolishAction(Actor saboteur, int delay, int token, BitSet<DamageType> damageTypes)
|
||||
{
|
||||
public readonly Actor Saboteur;
|
||||
public readonly int Token;
|
||||
public int Delay;
|
||||
public readonly BitSet<DamageType> DamageTypes;
|
||||
|
||||
public DemolishAction(Actor saboteur, int delay, int token, BitSet<DamageType> damageTypes)
|
||||
{
|
||||
Saboteur = saboteur;
|
||||
Delay = delay;
|
||||
Token = token;
|
||||
DamageTypes = damageTypes;
|
||||
}
|
||||
public readonly Actor Saboteur = saboteur;
|
||||
public readonly int Token = token;
|
||||
public int Delay = delay;
|
||||
public readonly BitSet<DamageType> DamageTypes = damageTypes;
|
||||
}
|
||||
|
||||
readonly List<DemolishAction> actions = [];
|
||||
|
||||
@@ -23,15 +23,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public sealed class LocomotorReferenceAttribute : Attribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public sealed class NotificationReferenceAttribute : Attribute
|
||||
public sealed class NotificationReferenceAttribute(string type = null, string typeFromField = null) : Attribute
|
||||
{
|
||||
public readonly string NotificationTypeFieldName = null;
|
||||
public readonly string NotificationType = null;
|
||||
|
||||
public NotificationReferenceAttribute(string type = null, string typeFromField = null)
|
||||
{
|
||||
NotificationType = type;
|
||||
NotificationTypeFieldName = typeFromField;
|
||||
}
|
||||
public readonly string NotificationTypeFieldName = typeFromField;
|
||||
public readonly string NotificationType = type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,14 +40,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
bool isRendering;
|
||||
bool created;
|
||||
|
||||
sealed class FrozenState
|
||||
sealed class FrozenState(FrozenActor frozenActor)
|
||||
{
|
||||
public readonly FrozenActor FrozenActor;
|
||||
public readonly FrozenActor FrozenActor = frozenActor;
|
||||
public bool IsVisible;
|
||||
public FrozenState(FrozenActor frozenActor)
|
||||
{
|
||||
FrozenActor = frozenActor;
|
||||
}
|
||||
}
|
||||
|
||||
public FrozenUnderFog(ActorInitializer init, FrozenUnderFogInfo info)
|
||||
|
||||
@@ -170,18 +170,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return points;
|
||||
}
|
||||
|
||||
sealed class Arrow
|
||||
{
|
||||
public Sprite Sprite { get; }
|
||||
public double EndAngle { get; }
|
||||
public WAngle Direction { get; }
|
||||
|
||||
public Arrow(Sprite sprite, double endAngle, WAngle direction)
|
||||
{
|
||||
Sprite = sprite;
|
||||
EndAngle = endAngle;
|
||||
Direction = direction;
|
||||
}
|
||||
}
|
||||
sealed record Arrow(Sprite Sprite, double EndAngle, WAngle Direction);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,19 +130,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public class Locomotor : IWorldLoaded
|
||||
{
|
||||
readonly struct CellCache
|
||||
{
|
||||
public readonly LongBitSet<PlayerBitMask> Immovable;
|
||||
public readonly LongBitSet<PlayerBitMask> Crushable;
|
||||
public readonly CellFlag CellFlag;
|
||||
|
||||
public CellCache(LongBitSet<PlayerBitMask> immovable, CellFlag cellFlag, LongBitSet<PlayerBitMask> crushable)
|
||||
{
|
||||
Immovable = immovable;
|
||||
Crushable = crushable;
|
||||
CellFlag = cellFlag;
|
||||
}
|
||||
}
|
||||
readonly record struct CellCache(LongBitSet<PlayerBitMask> Immovable, CellFlag CellFlag, LongBitSet<PlayerBitMask> Crushable);
|
||||
|
||||
public readonly LocomotorInfo Info;
|
||||
|
||||
|
||||
@@ -378,17 +378,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
disposed = true;
|
||||
}
|
||||
|
||||
readonly struct MapLine
|
||||
{
|
||||
public readonly float2 Start;
|
||||
public readonly float2 End;
|
||||
|
||||
public MapLine(float2 start, float2 end)
|
||||
{
|
||||
Start = start;
|
||||
End = end;
|
||||
}
|
||||
}
|
||||
readonly record struct MapLine(float2 Start, float2 End);
|
||||
|
||||
IEnumerable<IRenderable> IRenderAnnotations.RenderAnnotations(Actor self, WorldRenderer wr)
|
||||
{
|
||||
|
||||
@@ -17,17 +17,11 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public readonly struct ResourceLayerContents
|
||||
public readonly struct ResourceLayerContents(string type, int density)
|
||||
{
|
||||
public static readonly ResourceLayerContents Empty = default;
|
||||
public readonly string Type;
|
||||
public readonly int Density;
|
||||
|
||||
public ResourceLayerContents(string type, int density)
|
||||
{
|
||||
Type = type;
|
||||
Density = density;
|
||||
}
|
||||
public readonly string Type = type;
|
||||
public readonly int Density = density;
|
||||
}
|
||||
|
||||
[TraitLocation(SystemActors.World)]
|
||||
|
||||
@@ -94,16 +94,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
BottomLeft
|
||||
}
|
||||
|
||||
readonly struct TileInfo
|
||||
readonly struct TileInfo(in float3 screenPosition, byte variant)
|
||||
{
|
||||
public readonly float3 ScreenPosition;
|
||||
public readonly byte Variant;
|
||||
|
||||
public TileInfo(in float3 screenPosition, byte variant)
|
||||
{
|
||||
ScreenPosition = screenPosition;
|
||||
Variant = variant;
|
||||
}
|
||||
public readonly float3 ScreenPosition = screenPosition;
|
||||
public readonly byte Variant = variant;
|
||||
}
|
||||
|
||||
readonly ShroudRendererInfo info;
|
||||
|
||||
@@ -35,22 +35,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public sealed class TerrainLighting : ITerrainLighting
|
||||
{
|
||||
sealed class LightSource
|
||||
sealed class LightSource(WPos pos, CPos cell, WDist range, float intensity, in float3 tint)
|
||||
{
|
||||
public readonly WPos Pos;
|
||||
public readonly CPos Cell;
|
||||
public readonly WDist Range;
|
||||
public readonly float Intensity;
|
||||
public readonly float3 Tint;
|
||||
|
||||
public LightSource(WPos pos, CPos cell, WDist range, float intensity, in float3 tint)
|
||||
{
|
||||
Pos = pos;
|
||||
Cell = cell;
|
||||
Range = range;
|
||||
Intensity = intensity;
|
||||
Tint = tint;
|
||||
}
|
||||
public readonly WPos Pos = pos;
|
||||
public readonly CPos Cell = cell;
|
||||
public readonly WDist Range = range;
|
||||
public readonly float Intensity = intensity;
|
||||
public readonly float3 Tint = tint;
|
||||
}
|
||||
|
||||
readonly TerrainLightingInfo info;
|
||||
|
||||
@@ -28,22 +28,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public class WarheadDebugOverlay : IRenderAnnotations
|
||||
{
|
||||
sealed class WHImpact
|
||||
sealed class WHImpact(WPos pos, WDist[] range, int time, Color color)
|
||||
{
|
||||
public readonly WPos CenterPosition;
|
||||
public readonly WDist[] Range;
|
||||
public readonly Color Color;
|
||||
public int Time;
|
||||
public readonly WPos CenterPosition = pos;
|
||||
public readonly WDist[] Range = range;
|
||||
public readonly Color Color = color;
|
||||
public int Time = time;
|
||||
|
||||
public WDist OuterRange => Range[^1];
|
||||
|
||||
public WHImpact(WPos pos, WDist[] range, int time, Color color)
|
||||
{
|
||||
CenterPosition = pos;
|
||||
Range = range;
|
||||
Color = color;
|
||||
Time = time;
|
||||
}
|
||||
}
|
||||
|
||||
readonly WarheadDebugOverlayInfo info;
|
||||
|
||||
Reference in New Issue
Block a user