Add readonly to structs

This commit is contained in:
teinarss
2021-01-29 16:56:11 +01:00
committed by abcdefg30
parent 65c796dec7
commit 6b74093c04
83 changed files with 146 additions and 125 deletions

View File

@@ -65,7 +65,7 @@ namespace OpenRA.Primitives
}
}
struct DelayedAction : IComparable<DelayedAction>
readonly struct DelayedAction : IComparable<DelayedAction>
{
public readonly long Time;
public readonly Action Action;

View File

@@ -75,7 +75,7 @@ namespace OpenRA.Primitives
}
}
public struct BitSet<T> : IEnumerable<string>, IEquatable<BitSet<T>> where T : class
public readonly struct BitSet<T> : IEnumerable<string>, IEquatable<BitSet<T>> where T : class
{
readonly BitSetIndex bits;

View File

@@ -15,7 +15,7 @@ using OpenRA.Scripting;
namespace OpenRA.Primitives
{
public struct Color : IEquatable<Color>, IScriptBindable
public readonly struct Color : IEquatable<Color>, IScriptBindable
{
readonly long argb;

View File

@@ -13,7 +13,7 @@ using System;
namespace OpenRA
{
public struct Int32Matrix4x4 : IEquatable<Int32Matrix4x4>
public readonly struct Int32Matrix4x4 : IEquatable<Int32Matrix4x4>
{
public readonly int M11, M12, M13, M14, M21, M22, M23, M24, M31, M32, M33, M34, M41, M42, M43, M44;

View File

@@ -92,7 +92,7 @@ namespace OpenRA.Primitives
}
// Opitmized BitSet to be used only when guaranteed to be no more than 64 values.
public struct LongBitSet<T> : IEnumerable<string>, IEquatable<LongBitSet<T>> where T : class
public readonly struct LongBitSet<T> : IEnumerable<string>, IEquatable<LongBitSet<T>> where T : class
{
readonly long bits;

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Primitives
/// <summary>
/// Provides a mapping of players to values, as well as fast lookup by player index.
/// </summary>
public struct PlayerDictionary<T> : IReadOnlyList<T>, IReadOnlyDictionary<Player, T> where T : class
public readonly struct PlayerDictionary<T> : IReadOnlyList<T>, IReadOnlyDictionary<Player, T> where T : class
{
readonly T[] valueByPlayerIndex;
readonly Dictionary<Player, T> valueByPlayer;

View File

@@ -14,13 +14,13 @@ using System.Linq;
namespace OpenRA.Primitives
{
public struct Polygon
public readonly struct Polygon
{
public static readonly Polygon Empty = new Polygon(Rectangle.Empty);
public readonly Rectangle BoundingRect;
public readonly int2[] Vertices;
bool isRectangle;
readonly bool isRectangle;
public Polygon(Rectangle bounds)
{

View File

@@ -13,7 +13,7 @@ using System;
namespace OpenRA.Primitives
{
public struct Size : IEquatable<Size>
public readonly struct Size : IEquatable<Size>
{
public readonly int Width;
public readonly int Height;

View File

@@ -18,7 +18,7 @@ namespace OpenRA
{
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Mimic a built-in type alias.")]
[StructLayout(LayoutKind.Sequential)]
public struct float2 : IEquatable<float2>
public readonly struct float2 : IEquatable<float2>
{
public readonly float X, Y;

View File

@@ -16,7 +16,7 @@ using OpenRA.Primitives;
namespace OpenRA
{
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Mimic a built-in type alias.")]
public struct int2 : IEquatable<int2>
public readonly struct int2 : IEquatable<int2>
{
public readonly int X, Y;
public int2(int x, int y) { X = x; Y = y; }