Enable SA1121 and fix noncompliance

"Use built-in type alias"
This commit is contained in:
YoshiRulz 2020-06-21 09:57:16 +10:00 committed by zeromus
parent 0021cfee70
commit 14e0c96fd8
11 changed files with 47 additions and 50 deletions

View File

@ -336,9 +336,6 @@
<!-- Comments should contain text --> <!-- Comments should contain text -->
<Rule Id="SA1120" Action="Hidden" /> <Rule Id="SA1120" Action="Hidden" />
<!-- Use built-in type alias -->
<Rule Id="SA1121" Action="Hidden" />
<!-- Use string.Empty for empty strings --> <!-- Use string.Empty for empty strings -->
<Rule Id="SA1122" Action="Hidden" /> <Rule Id="SA1122" Action="Hidden" />

View File

@ -140,7 +140,7 @@ namespace BizHawk.Client.EmuHawk
throw new InvalidOperationException("Tried to start recording an AVI with no video codec token set"); throw new InvalidOperationException("Tried to start recording an AVI with no video codec token set");
} }
threadQ = new System.Collections.Concurrent.BlockingCollection<Object>(30); threadQ = new System.Collections.Concurrent.BlockingCollection<object>(30);
workerT = new System.Threading.Thread(new System.Threading.ThreadStart(threadproc)); workerT = new System.Threading.Thread(new System.Threading.ThreadStart(threadproc));
workerT.Start(); workerT.Start();
} }
@ -558,7 +558,7 @@ namespace BizHawk.Client.EmuHawk
/// set metadata parameters; should be called before opening file /// set metadata parameters; should be called before opening file
/// NYI /// NYI
/// </summary> /// </summary>
public void SetMetaData(string gameName, string authors, UInt64 lengthMS, UInt64 rerecords) public void SetMetaData(string gameName, string authors, ulong lengthMS, ulong rerecords)
{ {
} }

View File

@ -126,7 +126,7 @@ namespace BizHawk.Client.EmuHawk
//ToDo: //ToDo:
//Make this better? //Make this better?
//We need to have i at 1 and not zero because Controls Count doesn't start at zero (sort of) //We need to have i at 1 and not zero because Controls Count doesn't start at zero (sort of)
Int32 i = 1; var i = 1;
//For Each Control box we have, loop //For Each Control box we have, loop
foreach (Control ctrl in FileSelectorPanel.Controls) foreach (Control ctrl in FileSelectorPanel.Controls)
{ {

View File

@ -50,7 +50,7 @@ namespace BizHawk.Common
{ {
if (EnabledLogDomains.Contains(domain)) if (EnabledLogDomains.Contains(domain))
{ {
LogAction(String.Format(msg, vals)); LogAction(string.Format(msg, vals));
} }
} }

View File

@ -8,38 +8,38 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// </summary> /// </summary>
public static class StreamHelper public static class StreamHelper
{ {
public static void Write(Stream stream, Int32 value) public static void Write(Stream stream, int value)
{ {
byte[] data = BitConverter.GetBytes(value); byte[] data = BitConverter.GetBytes(value);
stream.Write(data, 0, data.Length); stream.Write(data, 0, data.Length);
} }
public static void Write(Stream stream, UInt32 value) public static void Write(Stream stream, uint value)
{ {
byte[] data = BitConverter.GetBytes(value); byte[] data = BitConverter.GetBytes(value);
stream.Write(data, 0, data.Length); stream.Write(data, 0, data.Length);
} }
public static void Write(Stream stream, Int16 value) public static void Write(Stream stream, short value)
{ {
byte[] data = BitConverter.GetBytes(value); byte[] data = BitConverter.GetBytes(value);
stream.Write(data, 0, data.Length); stream.Write(data, 0, data.Length);
} }
public static void Write(Stream stream, UInt16 value) public static void Write(Stream stream, ushort value)
{ {
byte[] data = BitConverter.GetBytes(value); byte[] data = BitConverter.GetBytes(value);
stream.Write(data, 0, data.Length); stream.Write(data, 0, data.Length);
} }
public static void Write(Stream stream, Byte value) public static void Write(Stream stream, byte value)
{ {
byte[] data = new byte[1]; byte[] data = new byte[1];
data[0] = value; data[0] = value;
stream.Write(data, 0, data.Length); stream.Write(data, 0, data.Length);
} }
public static void Write(Stream stream, SByte value) public static void Write(Stream stream, sbyte value)
{ {
byte[] data = new byte[1]; byte[] data = new byte[1];
data[0] = (byte)value; data[0] = (byte)value;
@ -52,7 +52,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
} }
public static void Read(Stream stream, out Int32 value) public static void Read(Stream stream, out int value)
{ {
byte[] data = new byte[4]; byte[] data = new byte[4];
stream.Read(data, 0, data.Length); stream.Read(data, 0, data.Length);
@ -61,35 +61,35 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
value = BitConverter.ToInt32(data, 0); value = BitConverter.ToInt32(data, 0);
} }
public static void Read(Stream stream, out UInt32 value) public static void Read(Stream stream, out uint value)
{ {
byte[] data = new byte[4]; byte[] data = new byte[4];
stream.Read(data, 0, data.Length); stream.Read(data, 0, data.Length);
value = BitConverter.ToUInt32(data, 0); value = BitConverter.ToUInt32(data, 0);
} }
public static void Read(Stream stream, out Int16 value) public static void Read(Stream stream, out short value)
{ {
byte[] data = new byte[2]; byte[] data = new byte[2];
stream.Read(data, 0, data.Length); stream.Read(data, 0, data.Length);
value = BitConverter.ToInt16(data, 0); value = BitConverter.ToInt16(data, 0);
} }
public static void Read(Stream stream, out UInt16 value) public static void Read(Stream stream, out ushort value)
{ {
byte[] data = new byte[2]; byte[] data = new byte[2];
stream.Read(data, 0, data.Length); stream.Read(data, 0, data.Length);
value = BitConverter.ToUInt16(data, 0); value = BitConverter.ToUInt16(data, 0);
} }
public static void Read(Stream stream, out Byte value) public static void Read(Stream stream, out byte value)
{ {
byte[] data = new byte[1]; byte[] data = new byte[1];
stream.Read(data, 0, data.Length); stream.Read(data, 0, data.Length);
value = data[0]; value = data[0];
} }
public static void Read(Stream stream, out SByte value) public static void Read(Stream stream, out sbyte value)
{ {
byte[] data = new byte[1]; byte[] data = new byte[1];
stream.Read(data, 0, data.Length); stream.Read(data, 0, data.Length);

View File

@ -10,24 +10,24 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
public class WavHeader public class WavHeader
{ {
// RIFF chunk (12 bytes) // RIFF chunk (12 bytes)
public Int32 chunkID; // "RIFF" public int chunkID; // "RIFF"
public Int32 fileSize; public int fileSize;
public Int32 riffType; // "WAVE" public int riffType; // "WAVE"
// Format chunk (24 bytes) // Format chunk (24 bytes)
public Int32 fmtID; // "fmt " public int fmtID; // "fmt "
public Int32 fmtSize; public int fmtSize;
public Int16 fmtCode; public short fmtCode;
public Int16 channels; public short channels;
public Int32 sampleRate; public int sampleRate;
public Int32 fmtAvgBPS; public int fmtAvgBPS;
public Int16 fmtBlockAlign; public short fmtBlockAlign;
public Int16 bitDepth; public short bitDepth;
public Int16 fmtExtraSize; public short fmtExtraSize;
// Data chunk // Data chunk
public Int32 dataID; // "data" public int dataID; // "data"
public Int32 dataSize; // The data size should be file size - 36 bytes. public int dataSize; // The data size should be file size - 36 bytes.
public void Deserialize(Stream stream) public void Deserialize(Stream stream)
@ -43,8 +43,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
{ {
throw new FormatException($"Not supported RIFF type: '{Encoding.ASCII.GetString(BitConverter.GetBytes(riffType))}'"); throw new FormatException($"Not supported RIFF type: '{Encoding.ASCII.GetString(BitConverter.GetBytes(riffType))}'");
} }
Int32 chunkId; int chunkId;
Int32 chunkSize; int chunkSize;
while (stream.Position < stream.Length) while (stream.Position < stream.Length)
{ {
StreamHelper.Read(stream, out chunkId); StreamHelper.Read(stream, out chunkId);

View File

@ -21,7 +21,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
public int Count => m_header.dataSize / m_header.fmtBlockAlign; public int Count => m_header.dataSize / m_header.fmtBlockAlign;
public Int32 ReadNext() public int ReadNext()
{ {
// check - sample should be in PCM format // check - sample should be in PCM format
if (m_header.fmtCode != WAVE_FORMAT_PCM && if (m_header.fmtCode != WAVE_FORMAT_PCM &&
@ -54,19 +54,19 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
throw new NotSupportedException($"Not supported audio format ({(m_header.fmtCode == WAVE_FORMAT_PCM ? "PCM" : "FLOAT")}/{m_header.bitDepth} bit)"); throw new NotSupportedException($"Not supported audio format ({(m_header.fmtCode == WAVE_FORMAT_PCM ? "PCM" : "FLOAT")}/{m_header.bitDepth} bit)");
} }
private Int32 getSamplePcm8(byte[] bufferRaw, int offset, int channel) private int getSamplePcm8(byte[] bufferRaw, int offset, int channel)
{ {
return bufferRaw[offset + channel] - 128; return bufferRaw[offset + channel] - 128;
} }
private Int32 getSamplePcm16(byte[] bufferRaw, int offset, int channel) private int getSamplePcm16(byte[] bufferRaw, int offset, int channel)
{ {
return BitConverter.ToInt16(bufferRaw, offset + 2 * channel); return BitConverter.ToInt16(bufferRaw, offset + 2 * channel);
} }
private Int32 getSamplePcm24(byte[] bufferRaw, int offset, int channel) private int getSamplePcm24(byte[] bufferRaw, int offset, int channel)
{ {
Int32 result; int result;
int subOffset = offset + channel * 3; int subOffset = offset + channel * 3;
if (BitConverter.IsLittleEndian) if (BitConverter.IsLittleEndian)
{ {
@ -83,23 +83,23 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
return result; return result;
} }
private Int32 getSamplePcm32(byte[] bufferRaw, int offset, int channel) private int getSamplePcm32(byte[] bufferRaw, int offset, int channel)
{ {
return BitConverter.ToInt32(bufferRaw, offset + 4 * channel); return BitConverter.ToInt32(bufferRaw, offset + 4 * channel);
} }
private Int32 getSampleFloat32(byte[] data, int offset, int channel) private int getSampleFloat32(byte[] data, int offset, int channel)
{ {
float fSample = BitConverter.ToSingle(data, offset + 4 * channel); float fSample = BitConverter.ToSingle(data, offset + 4 * channel);
// convert to 32 bit integer // convert to 32 bit integer
return (Int32)(fSample * Int32.MaxValue); return (int) (fSample * int.MaxValue);
} }
private Int32 getSampleFloat64(byte[] data, int offset, int channel) private int getSampleFloat64(byte[] data, int offset, int channel)
{ {
double fSample = BitConverter.ToDouble(data, offset + 8 * channel); double fSample = BitConverter.ToDouble(data, offset + 8 * channel);
// convert to 32 bit integer // convert to 32 bit integer
return (Int32)(fSample * Int32.MaxValue); return (int) (fSample * int.MaxValue);
} }
private const int WAVE_FORMAT_PCM = 1; /* PCM */ private const int WAVE_FORMAT_PCM = 1; /* PCM */

View File

@ -485,7 +485,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
// CYCLE LENGTH: L // CYCLE LENGTH: L
case ROMC_01: case ROMC_01:
Read_Func(DB, PC0l, PC0h); Read_Func(DB, PC0l, PC0h);
RegPC0 += (ushort)((SByte) Regs[DB]); RegPC0 += (ushort)((sbyte) Regs[DB]);
break; break;
// The device whose DC0 address addresses a memory word within the address space of that device must place on the data bus the contents // The device whose DC0 address addresses a memory word within the address space of that device must place on the data bus the contents

View File

@ -173,7 +173,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
public static extern void BizSetRegister(IntPtr ctx, int index, int value); public static extern void BizSetRegister(IntPtr ctx, int index, int value);
[DllImport(dll, CallingConvention = cc)] [DllImport(dll, CallingConvention = cc)]
public static extern UInt64 BizGetGlobalTime(IntPtr ctx); public static extern ulong BizGetGlobalTime(IntPtr ctx);
[DllImport(dll, CallingConvention = cc)] [DllImport(dll, CallingConvention = cc)]
public static extern void BizWriteBus(IntPtr ctx, uint addr, byte val); public static extern void BizWriteBus(IntPtr ctx, uint addr, byte val);

View File

@ -27,7 +27,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
for (int i = 1; i < 32; i++) // r0 is always zero for (int i = 1; i < 32; i++) // r0 is always zero
{ {
UInt64 val = (regs[GPRnames[i] + "_hi"].Value << 32) | regs[GPRnames[i] + "_lo"].Value; var val = (regs[GPRnames[i] + "_hi"].Value << 32) | regs[GPRnames[i] + "_lo"].Value;
string name = GPRnames[i]; string name = GPRnames[i];
sb.Append($"{name}:{val:X16} "); sb.Append($"{name}:{val:X16} ");
} }
@ -40,7 +40,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
for (int i = 0; i < 32; i++) // r0 is always zero for (int i = 0; i < 32; i++) // r0 is always zero
{ {
UInt64 val = (regs["CP1 FGR REG" + i + "_hi"].Value << 32) | regs["CP1 FGR REG" + i + "_lo"].Value; var val = (regs["CP1 FGR REG" + i + "_hi"].Value << 32) | regs["CP1 FGR REG" + i + "_lo"].Value;
sb.Append($"f{i}:{val:X16} "); sb.Append($"f{i}:{val:X16} ");
} }

View File

@ -33,7 +33,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate Int32 GetScreenTextureID(); private delegate int GetScreenTextureID();
GetScreenTextureID GFXGetScreenTextureID; GetScreenTextureID GFXGetScreenTextureID;
public mupen64plusVideoApi(mupen64plusApi core, VideoPluginSettings settings) public mupen64plusVideoApi(mupen64plusApi core, VideoPluginSettings settings)