Code Analysis feedback tweaks.
This commit is contained in:
@ -56,17 +56,17 @@ namespace RobloxFiles
|
||||
internal BinaryReader reader;
|
||||
// internal BinaryWriter writer;
|
||||
|
||||
internal int readInt() => reader.ReadInt32();
|
||||
internal int ReadInt() => reader.ReadInt32();
|
||||
internal byte readByte() => reader.ReadByte();
|
||||
internal bool readBool() => reader.ReadBoolean();
|
||||
internal short readShort() => reader.ReadInt16();
|
||||
internal float readFloat() => reader.ReadSingle();
|
||||
internal double readDouble() => reader.ReadDouble();
|
||||
internal string readString() => reader.ReadString(true);
|
||||
internal float ReadFloat() => reader.ReadSingle();
|
||||
internal double ReadDouble() => reader.ReadDouble();
|
||||
internal string ReadString() => reader.ReadString(true);
|
||||
|
||||
internal Attribute[] readArray()
|
||||
internal Attribute[] ReadArray()
|
||||
{
|
||||
int count = readInt();
|
||||
int count = ReadInt();
|
||||
var result = new Attribute[count];
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
@ -77,8 +77,8 @@ namespace RobloxFiles
|
||||
|
||||
internal object readEnum()
|
||||
{
|
||||
string name = readString();
|
||||
int value = readInt();
|
||||
string name = ReadString();
|
||||
int value = ReadInt();
|
||||
|
||||
try
|
||||
{
|
||||
@ -107,22 +107,22 @@ namespace RobloxFiles
|
||||
case AttributeType.Null:
|
||||
break;
|
||||
case AttributeType.String:
|
||||
Value = readString();
|
||||
Value = ReadString();
|
||||
break;
|
||||
case AttributeType.Bool:
|
||||
Value = readBool();
|
||||
break;
|
||||
case AttributeType.Int:
|
||||
Value = readInt();
|
||||
Value = ReadInt();
|
||||
break;
|
||||
case AttributeType.Float:
|
||||
Value = readFloat();
|
||||
Value = ReadFloat();
|
||||
break;
|
||||
case AttributeType.Double:
|
||||
Value = readDouble();
|
||||
Value = ReadDouble();
|
||||
break;
|
||||
case AttributeType.Array:
|
||||
Value = readArray();
|
||||
Value = ReadArray();
|
||||
break;
|
||||
case AttributeType.Dictionary:
|
||||
Value = new Attributes(reader);
|
||||
@ -137,13 +137,13 @@ namespace RobloxFiles
|
||||
Value = new Ray(this);
|
||||
break;
|
||||
case AttributeType.Faces:
|
||||
Value = (Faces)readInt();
|
||||
Value = (Faces)ReadInt();
|
||||
break;
|
||||
case AttributeType.Axes:
|
||||
Value = (Axes)readInt();
|
||||
Value = (Axes)ReadInt();
|
||||
break;
|
||||
case AttributeType.BrickColor:
|
||||
Value = (BrickColor)readInt();
|
||||
Value = (BrickColor)ReadInt();
|
||||
break;
|
||||
case AttributeType.Color3:
|
||||
Value = new Color3(this);
|
||||
@ -225,7 +225,7 @@ namespace RobloxFiles
|
||||
|
||||
public class Attributes : Dictionary<string, Attribute>
|
||||
{
|
||||
private void initialize(BinaryReader reader)
|
||||
private void Initialize(BinaryReader reader)
|
||||
{
|
||||
Stream stream = reader.BaseStream;
|
||||
|
||||
@ -245,14 +245,14 @@ namespace RobloxFiles
|
||||
|
||||
internal Attributes(BinaryReader reader)
|
||||
{
|
||||
initialize(reader);
|
||||
Initialize(reader);
|
||||
}
|
||||
|
||||
internal Attributes(MemoryStream stream)
|
||||
{
|
||||
using (BinaryReader reader = new BinaryReader(stream))
|
||||
{
|
||||
initialize(reader);
|
||||
Initialize(reader);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ namespace RobloxFiles
|
||||
public string ClassName => GetType().Name;
|
||||
|
||||
/// <summary>Internal list of properties that are under this Instance.</summary>
|
||||
private Dictionary<string, Property> props = new Dictionary<string, Property>();
|
||||
private readonly Dictionary<string, Property> props = new Dictionary<string, Property>();
|
||||
|
||||
/// <summary>A list of properties that are defined under this Instance.</summary>
|
||||
public IReadOnlyDictionary<string, Property> Properties => props;
|
||||
@ -45,7 +45,7 @@ namespace RobloxFiles
|
||||
public override string ToString() => Name;
|
||||
|
||||
/// <summary>A unique identifier for this instance when being serialized.</summary>
|
||||
public string Referent { get; internal set; }
|
||||
public string Referent { get; set; }
|
||||
|
||||
/// <summary>Indicates whether the parent of this object is locked.</summary>
|
||||
public bool ParentLocked { get; internal set; }
|
||||
@ -438,7 +438,7 @@ namespace RobloxFiles
|
||||
/// <summary>
|
||||
/// Returns a string describing the index traversal of this Instance, starting from its root ancestor.
|
||||
/// </summary>
|
||||
public string GetFullName(string separator = ".")
|
||||
public string GetFullName(string separator = "\\")
|
||||
{
|
||||
string fullName = Name;
|
||||
Instance at = Parent;
|
||||
@ -512,6 +512,8 @@ namespace RobloxFiles
|
||||
if (field.GetCustomAttribute<ObsoleteAttribute>() != null)
|
||||
continue;
|
||||
|
||||
// A few specific edge case hacks. I wish these didn't need to exist :(
|
||||
|
||||
if (fieldName == "Archivable" || fieldName.EndsWith("k__BackingField"))
|
||||
continue;
|
||||
else if (fieldName == "Bevel_Roundness")
|
||||
|
@ -125,10 +125,19 @@ namespace RobloxFiles
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (RawValue is long)
|
||||
Type = PropertyType.Int64;
|
||||
|
||||
switch (Type)
|
||||
{
|
||||
case PropertyType.Int:
|
||||
if (Value is long)
|
||||
{
|
||||
Type = PropertyType.Int64;
|
||||
goto case PropertyType.Int64;
|
||||
}
|
||||
|
||||
RawBuffer = BitConverter.GetBytes((int)Value);
|
||||
break;
|
||||
case PropertyType.Bool:
|
||||
@ -307,7 +316,7 @@ namespace RobloxFiles
|
||||
string result = Name;
|
||||
|
||||
if (Instance != null)
|
||||
result = Instance.GetFullName() + '.' + result;
|
||||
result = Instance.GetFullName() + "->" + result;
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -329,8 +338,8 @@ namespace RobloxFiles
|
||||
|
||||
if (typeof(T) == typeof(string))
|
||||
result = Value?.ToString() ?? "";
|
||||
else if (Value is T)
|
||||
result = (T)Value;
|
||||
else if (Value is T typedValue)
|
||||
result = typedValue;
|
||||
else
|
||||
result = default(T);
|
||||
|
||||
|
Reference in New Issue
Block a user