Code Analysis feedback tweaks.

This commit is contained in:
CloneTrooper1019
2020-09-14 11:20:34 -05:00
parent 4240337863
commit 2a114e70b0
25 changed files with 100 additions and 104 deletions

View File

@ -7,7 +7,7 @@ namespace RobloxFiles.XmlFormat
{
public static class XmlRobloxFileReader
{
private static Func<string, Exception> createErrorHandler(string label)
private static Func<string, Exception> CreateErrorHandler(string label)
{
var errorHandler = new Func<string, Exception>((message) =>
{
@ -20,7 +20,7 @@ namespace RobloxFiles.XmlFormat
public static void ReadSharedStrings(XmlNode sharedStrings, XmlRobloxFile file)
{
var error = createErrorHandler("ReadSharedStrings");
var error = CreateErrorHandler("ReadSharedStrings");
if (sharedStrings.Name != "SharedStrings")
throw error("Provided XmlNode's class should be 'SharedStrings'!");
@ -56,7 +56,7 @@ namespace RobloxFiles.XmlFormat
public static void ReadMetadata(XmlNode meta, XmlRobloxFile file)
{
var error = createErrorHandler("ReadMetadata");
var error = CreateErrorHandler("ReadMetadata");
if (meta.Name != "Meta")
throw error("Provided XmlNode's class should be 'Meta'!");
@ -74,7 +74,7 @@ namespace RobloxFiles.XmlFormat
public static void ReadProperties(Instance instance, XmlNode propsNode)
{
var error = createErrorHandler("ReadProperties");
var error = CreateErrorHandler("ReadProperties");
if (propsNode.Name != "Properties")
throw error("Provided XmlNode's class should be 'Properties'!");
@ -121,7 +121,7 @@ namespace RobloxFiles.XmlFormat
public static Instance ReadInstance(XmlNode instNode, XmlRobloxFile file)
{
var error = createErrorHandler("ReadInstance");
var error = CreateErrorHandler("ReadInstance");
// Process the instance itself
if (instNode.Name != "Item")

View File

@ -161,29 +161,15 @@ namespace RobloxFiles.XmlFormat
object a = DefaultProperty.Get(instance, prop);
object b = prop.Value;
if (a is float)
{
float f0 = (float)a,
f1 = (float)b;
isDefault = f0.FuzzyEquals(f1);
}
else if (a is double)
{
double d0 = (double)a,
d1 = (double)b;
if (a is double d0 && b is double d1)
isDefault = d0.FuzzyEquals(d1);
}
else if (a is float f0 && b is float f1)
isDefault = f0.FuzzyEquals(f1);
else if (b != null)
{
isDefault = b.Equals(a);
}
else if (a == b)
{
isDefault = true;
}
if (!isDefault)
{
XmlNode propNode = WriteProperty(prop, doc, file);

View File

@ -23,9 +23,9 @@ namespace RobloxFiles
public XmlRobloxFile()
{
Name = "XmlRobloxFile";
ParentLocked = true;
Name = "Xml:";
Referent = "null";
ParentLocked = true;
}
protected override void ReadFile(byte[] buffer)