General cleanup and refactor.

This commit is contained in:
2022-03-07 07:36:42 +00:00
parent 0deebadaa0
commit bd76adc35e
119 changed files with 1647 additions and 2151 deletions

View File

@@ -30,13 +30,13 @@
// Copyright © 2011-2022 Natalia Portillo
// ****************************************************************************/
namespace Aaru.Decoders.SecureDigital;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Text;
using Aaru.Helpers;
namespace Aaru.Decoders.SecureDigital;
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public class CID
@@ -59,7 +59,7 @@ public static partial class Decoders
if(response?.Length != 4)
return null;
byte[] data = new byte[16];
var data = new byte[16];
byte[] tmp = BitConverter.GetBytes(response[0]);
Array.Copy(tmp, 0, data, 0, 4);
@@ -87,7 +87,7 @@ public static partial class Decoders
CRC = (byte)((response[15] & 0xFE) >> 1)
};
byte[] tmp = new byte[2];
var tmp = new byte[2];
Array.Copy(response, 1, tmp, 0, 2);
cid.ApplicationID = StringHandlers.CToString(tmp);
tmp = new byte[5];

View File

@@ -30,12 +30,12 @@
// Copyright © 2011-2022 Natalia Portillo
// ****************************************************************************/
namespace Aaru.Decoders.SecureDigital;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Text;
namespace Aaru.Decoders.SecureDigital;
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public class CSD
@@ -79,7 +79,7 @@ public static partial class Decoders
if(response?.Length != 4)
return null;
byte[] data = new byte[16];
var data = new byte[16];
byte[] tmp = BitConverter.GetBytes(response[0]);
Array.Copy(tmp, 0, data, 0, 4);
@@ -148,7 +148,7 @@ public static partial class Decoders
double unitFactor = 0;
double multiplier = 0;
string unit = "";
var unit = "";
var sb = new StringBuilder();
sb.AppendLine("SecureDigital Device Specific Data Register:");
@@ -601,8 +601,7 @@ public static partial class Decoders
sb.AppendLine("\tDevice can't write protect regions");
}
sb.AppendFormat("\tWriting is {0} times slower than reading", Math.Pow(2, csd.WriteSpeedFactor)).
AppendLine();
sb.AppendFormat("\tWriting is {0} times slower than reading", Math.Pow(2, csd.WriteSpeedFactor)).AppendLine();
sb.AppendFormat("\tWrite block length is {0} bytes", Math.Pow(2, csd.WriteBlockLength)).AppendLine();

View File

@@ -30,13 +30,13 @@
// Copyright © 2011-2022 Natalia Portillo
// ****************************************************************************/
namespace Aaru.Decoders.SecureDigital;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Text;
using Aaru.Helpers;
namespace Aaru.Decoders.SecureDigital;
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "UnassignedField.Global"),
SuppressMessage("ReSharper", "NotAccessedField.Global")]

View File

@@ -30,12 +30,12 @@
// Copyright © 2011-2022 Natalia Portillo
// ****************************************************************************/
namespace Aaru.Decoders.SecureDigital;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Text;
namespace Aaru.Decoders.SecureDigital;
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")]
public class SCR
@@ -56,14 +56,17 @@ public class SCR
[Flags]
public enum BusWidth : byte
{
OneBit = 1 << 0, FourBit = 1 << 2
OneBit = 1 << 0,
FourBit = 1 << 2
}
[Flags]
public enum CommandSupport : byte
{
SpeedClassControl = 1 << 0, SetBlockCount = 1 << 1, ExtensionRegisterSingleBlock = 1 << 2,
ExtensionRegisterMultiBlock = 1 << 3
SpeedClassControl = 1 << 0,
SetBlockCount = 1 << 1,
ExtensionRegisterSingleBlock = 1 << 2,
ExtensionRegisterMultiBlock = 1 << 3
}
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "InconsistentNaming")]
@@ -74,7 +77,7 @@ public static partial class Decoders
if(response?.Length != 2)
return null;
byte[] data = new byte[8];
var data = new byte[8];
byte[] tmp = BitConverter.GetBytes(response[0]);
Array.Copy(tmp, 0, data, 0, 4);
@@ -195,8 +198,7 @@ public static partial class Decoders
break;
default:
sb.AppendFormat("\tDevice uses unknown CPRM specification with code {0}", scr.Security).
AppendLine();
sb.AppendFormat("\tDevice uses unknown CPRM specification with code {0}", scr.Security).AppendLine();
break;
}

View File

@@ -39,12 +39,12 @@ public static class VendorString
/// <param name="sdVendorId">SD vendor ID</param>
/// <returns>Manufacturer</returns>
public static string Prettify(byte sdVendorId) => sdVendorId switch
{
0x41 => "Kingston",
0x02 => "Kingston",
0x03 => "Sandisk",
0x27 => "CnMemory",
0xAA => "QEMU",
_ => $"Unknown manufacturer ID 0x{sdVendorId:X2}"
};
{
0x41 => "Kingston",
0x02 => "Kingston",
0x03 => "Sandisk",
0x27 => "CnMemory",
0xAA => "QEMU",
_ => $"Unknown manufacturer ID 0x{sdVendorId:X2}"
};
}