Code Analysis feedback tweaks.
This commit is contained in:
@ -18,10 +18,10 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
public override string ToString() => Name;
|
||||
|
||||
private static List<BrickColor> ByPalette;
|
||||
private static Dictionary<int, BrickColor> ByNumber;
|
||||
private static readonly List<BrickColor> ByPalette;
|
||||
private static readonly Dictionary<int, BrickColor> ByNumber;
|
||||
|
||||
private static Random RNG = new Random();
|
||||
private static readonly Random RNG = new Random();
|
||||
|
||||
private const string DefaultName = "Medium stone grey";
|
||||
private const int DefaultNumber = 194;
|
||||
|
@ -161,7 +161,7 @@ namespace RobloxFiles.DataTypes
|
||||
m31 = comp[9]; m32 = comp[10]; m33 = comp[11];
|
||||
}
|
||||
|
||||
private void initFromMatrix(Vector3 pos, Vector3 vX, Vector3 vY, Vector3 vZ = null)
|
||||
private void InitFromMatrix(Vector3 pos, Vector3 vX, Vector3 vY, Vector3 vZ = null)
|
||||
{
|
||||
if (vZ == null)
|
||||
vZ = vX.Cross(vY);
|
||||
@ -175,7 +175,7 @@ namespace RobloxFiles.DataTypes
|
||||
public CFrame(Vector3 pos, Vector3 vX, Vector3 vY, Vector3 vZ = null)
|
||||
{
|
||||
Contract.Requires(pos != null && vX != null && vY != null);
|
||||
initFromMatrix(pos, vX, vY, vZ);
|
||||
InitFromMatrix(pos, vX, vY, vZ);
|
||||
}
|
||||
|
||||
internal CFrame(Attribute attr)
|
||||
@ -194,7 +194,7 @@ namespace RobloxFiles.DataTypes
|
||||
NormalId yColumn = (NormalId)(orientId % 6);
|
||||
Vector3 vY = Vector3.FromNormalId(yColumn);
|
||||
|
||||
initFromMatrix(pos, vX, vY);
|
||||
InitFromMatrix(pos, vX, vY);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -202,7 +202,7 @@ namespace RobloxFiles.DataTypes
|
||||
vY = new Vector3(attr),
|
||||
vZ = new Vector3(attr);
|
||||
|
||||
initFromMatrix(pos, vX, vY, vZ);
|
||||
InitFromMatrix(pos, vX, vY, vZ);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,9 +44,9 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
internal Color3(Attribute attr)
|
||||
{
|
||||
R = attr.readFloat();
|
||||
G = attr.readFloat();
|
||||
B = attr.readFloat();
|
||||
R = attr.ReadFloat();
|
||||
G = attr.ReadFloat();
|
||||
B = attr.ReadFloat();
|
||||
}
|
||||
|
||||
public static Color3 FromRGB(uint r = 0, uint g = 0, uint b = 0)
|
||||
|
@ -90,7 +90,7 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
public ColorSequence(Attribute attr)
|
||||
{
|
||||
int numKeys = attr.readInt();
|
||||
int numKeys = attr.ReadInt();
|
||||
var keypoints = new ColorSequenceKeypoint[numKeys];
|
||||
|
||||
for (int i = 0; i < numKeys; i++)
|
||||
|
@ -21,8 +21,8 @@
|
||||
|
||||
internal ColorSequenceKeypoint(Attribute attr)
|
||||
{
|
||||
Envelope = attr.readInt();
|
||||
Time = attr.readFloat();
|
||||
Envelope = attr.ReadInt();
|
||||
Time = attr.ReadFloat();
|
||||
Value = new Color3(attr);
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
public static implicit operator string(Content content)
|
||||
{
|
||||
return content.Url;
|
||||
return content?.Url;
|
||||
}
|
||||
|
||||
public static implicit operator Content(string url)
|
||||
|
@ -25,7 +25,7 @@ namespace RobloxFiles.DataTypes
|
||||
Max = max;
|
||||
}
|
||||
|
||||
internal NumberRange(Attribute attr) : this(attr.readFloat(), attr.readFloat())
|
||||
internal NumberRange(Attribute attr) : this(attr.ReadFloat(), attr.ReadFloat())
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
public NumberSequence(Attribute attr)
|
||||
{
|
||||
int numKeys = attr.readInt();
|
||||
int numKeys = attr.ReadInt();
|
||||
var keypoints = new NumberSequenceKeypoint[numKeys];
|
||||
|
||||
for (int i = 0; i < numKeys; i++)
|
||||
|
@ -20,9 +20,9 @@
|
||||
|
||||
internal NumberSequenceKeypoint(Attribute attr)
|
||||
{
|
||||
Envelope = attr.readFloat();
|
||||
Time = attr.readFloat();
|
||||
Value = attr.readFloat();
|
||||
Envelope = attr.ReadFloat();
|
||||
Time = attr.ReadFloat();
|
||||
Value = attr.ReadFloat();
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
|
@ -39,12 +39,12 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
internal PhysicalProperties(Attribute attr)
|
||||
{
|
||||
Density = attr.readFloat();
|
||||
Friction = attr.readFloat();
|
||||
Elasticity = attr.readFloat();
|
||||
Density = attr.ReadFloat();
|
||||
Friction = attr.ReadFloat();
|
||||
Elasticity = attr.ReadFloat();
|
||||
|
||||
FrictionWeight = attr.readFloat();
|
||||
ElasticityWeight = attr.readFloat();
|
||||
FrictionWeight = attr.ReadFloat();
|
||||
ElasticityWeight = attr.ReadFloat();
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
|
@ -16,7 +16,7 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
public class SharedString
|
||||
{
|
||||
private static ConcurrentDictionary<string, byte[]> Lookup = new ConcurrentDictionary<string, byte[]>();
|
||||
private static readonly ConcurrentDictionary<string, byte[]> Lookup = new ConcurrentDictionary<string, byte[]>();
|
||||
public string Key { get; internal set; }
|
||||
public string ComputedKey { get; internal set; }
|
||||
|
||||
|
@ -15,8 +15,8 @@
|
||||
|
||||
internal UDim(Attribute attr)
|
||||
{
|
||||
Scale = attr.readFloat();
|
||||
Offset = attr.readInt();
|
||||
Scale = attr.ReadFloat();
|
||||
Offset = attr.ReadInt();
|
||||
}
|
||||
|
||||
public static UDim operator+(UDim a, UDim b)
|
||||
|
@ -37,8 +37,8 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
internal Vector2(Attribute attr)
|
||||
{
|
||||
X = attr.readFloat();
|
||||
Y = attr.readFloat();
|
||||
X = attr.ReadFloat();
|
||||
Y = attr.ReadFloat();
|
||||
}
|
||||
|
||||
private delegate Vector2 Operator(Vector2 a, Vector2 b);
|
||||
@ -55,10 +55,10 @@ namespace RobloxFiles.DataTypes
|
||||
return upcast(numVec, vec);
|
||||
}
|
||||
|
||||
private static Operator add = new Operator((a, b) => new Vector2(a.X + b.X, a.Y + b.Y));
|
||||
private static Operator sub = new Operator((a, b) => new Vector2(a.X - b.X, a.Y - b.Y));
|
||||
private static Operator mul = new Operator((a, b) => new Vector2(a.X * b.X, a.Y * b.Y));
|
||||
private static Operator div = new Operator((a, b) => new Vector2(a.X / b.X, a.Y / b.Y));
|
||||
private static readonly Operator add = new Operator((a, b) => new Vector2(a.X + b.X, a.Y + b.Y));
|
||||
private static readonly Operator sub = new Operator((a, b) => new Vector2(a.X - b.X, a.Y - b.Y));
|
||||
private static readonly Operator mul = new Operator((a, b) => new Vector2(a.X * b.X, a.Y * b.Y));
|
||||
private static readonly Operator div = new Operator((a, b) => new Vector2(a.X / b.X, a.Y / b.Y));
|
||||
|
||||
public static Vector2 operator +(Vector2 a, Vector2 b) => add(a, b);
|
||||
public static Vector2 operator +(Vector2 v, float n) => upcastFloatOp(v, n, add);
|
||||
|
@ -39,10 +39,10 @@ namespace RobloxFiles.DataTypes
|
||||
return upcast(numVec, vec);
|
||||
}
|
||||
|
||||
private static Operator add = new Operator((a, b) => new Vector2int16(a.X + b.X, a.Y + b.Y));
|
||||
private static Operator sub = new Operator((a, b) => new Vector2int16(a.X - b.X, a.Y - b.Y));
|
||||
private static Operator mul = new Operator((a, b) => new Vector2int16(a.X * b.X, a.Y * b.Y));
|
||||
private static Operator div = new Operator((a, b) =>
|
||||
private static readonly Operator add = new Operator((a, b) => new Vector2int16(a.X + b.X, a.Y + b.Y));
|
||||
private static readonly Operator sub = new Operator((a, b) => new Vector2int16(a.X - b.X, a.Y - b.Y));
|
||||
private static readonly Operator mul = new Operator((a, b) => new Vector2int16(a.X * b.X, a.Y * b.Y));
|
||||
private static readonly Operator div = new Operator((a, b) =>
|
||||
{
|
||||
if (b.X == 0 || b.Y == 0)
|
||||
throw new DivideByZeroException();
|
||||
|
@ -41,9 +41,9 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
internal Vector3(Attribute attr)
|
||||
{
|
||||
X = attr.readFloat();
|
||||
Y = attr.readFloat();
|
||||
Z = attr.readFloat();
|
||||
X = attr.ReadFloat();
|
||||
Y = attr.ReadFloat();
|
||||
Z = attr.ReadFloat();
|
||||
}
|
||||
|
||||
public static Vector3 FromAxis(Axis axis)
|
||||
@ -80,10 +80,10 @@ namespace RobloxFiles.DataTypes
|
||||
return upcast(numVec, vec);
|
||||
}
|
||||
|
||||
private static Operator add = new Operator((a, b) => new Vector3(a.X + b.X, a.Y + b.Y, a.Z + b.Z));
|
||||
private static Operator sub = new Operator((a, b) => new Vector3(a.X - b.X, a.Y - b.Y, a.Z - b.Z));
|
||||
private static Operator mul = new Operator((a, b) => new Vector3(a.X * b.X, a.Y * b.Y, a.Z * b.Z));
|
||||
private static Operator div = new Operator((a, b) => new Vector3(a.X / b.X, a.Y / b.Y, a.Z / b.Z));
|
||||
private static readonly Operator add = new Operator((a, b) => new Vector3(a.X + b.X, a.Y + b.Y, a.Z + b.Z));
|
||||
private static readonly Operator sub = new Operator((a, b) => new Vector3(a.X - b.X, a.Y - b.Y, a.Z - b.Z));
|
||||
private static readonly Operator mul = new Operator((a, b) => new Vector3(a.X * b.X, a.Y * b.Y, a.Z * b.Z));
|
||||
private static readonly Operator div = new Operator((a, b) => new Vector3(a.X / b.X, a.Y / b.Y, a.Z / b.Z));
|
||||
|
||||
public static Vector3 operator +(Vector3 a, Vector3 b) => add(a, b);
|
||||
public static Vector3 operator +(Vector3 v, float n) => upcastFloatOp(v, n, add);
|
||||
|
@ -46,10 +46,10 @@ namespace RobloxFiles.DataTypes
|
||||
return upcast(numVec, vec);
|
||||
}
|
||||
|
||||
private static Operator add = new Operator((a, b) => new Vector3int16(a.X + b.X, a.Y + b.Y, a.Z + b.Z));
|
||||
private static Operator sub = new Operator((a, b) => new Vector3int16(a.X - b.X, a.Y - b.Y, a.Z - b.Z));
|
||||
private static Operator mul = new Operator((a, b) => new Vector3int16(a.X * b.X, a.Y * b.Y, a.Z * b.Z));
|
||||
private static Operator div = new Operator((a, b) =>
|
||||
private static readonly Operator add = new Operator((a, b) => new Vector3int16(a.X + b.X, a.Y + b.Y, a.Z + b.Z));
|
||||
private static readonly Operator sub = new Operator((a, b) => new Vector3int16(a.X - b.X, a.Y - b.Y, a.Z - b.Z));
|
||||
private static readonly Operator mul = new Operator((a, b) => new Vector3int16(a.X * b.X, a.Y * b.Y, a.Z * b.Z));
|
||||
private static readonly Operator div = new Operator((a, b) =>
|
||||
{
|
||||
if (b.X == 0 || b.Y == 0 || b.Z == 0)
|
||||
throw new DivideByZeroException();
|
||||
|
Reference in New Issue
Block a user