Use 'nameof' operator.
This commit is contained in:
parent
45f1a4b64f
commit
b2a28339d1
|
@ -59,7 +59,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException(string.Format("DisplayType {0} is invalid for this type of Watch", type.ToString()), "type");
|
||||
throw new ArgumentException(string.Format("DisplayType {0} is invalid for this type of Watch", type.ToString()), nameof(type));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -276,7 +276,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
public void SetAudioParameters(int sampleRate, int channels, int bits)
|
||||
{
|
||||
if (bits != 16)
|
||||
throw new ArgumentOutOfRangeException("bits", "Sampling depth must be 16 bits!");
|
||||
throw new ArgumentOutOfRangeException(nameof(bits), "Sampling depth must be 16 bits!");
|
||||
this.sampleRate = sampleRate;
|
||||
this.channels = channels;
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
static void WriteVarU(int v, Stream stream)
|
||||
{
|
||||
if (v < 0)
|
||||
throw new ArgumentOutOfRangeException("v", "unsigned must be non-negative");
|
||||
throw new ArgumentOutOfRangeException(nameof(v), "unsigned must be non-negative");
|
||||
WriteVarU((ulong)v, stream);
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
static void WriteVarU(long v, Stream stream)
|
||||
{
|
||||
if (v < 0)
|
||||
throw new ArgumentOutOfRangeException("v", "unsigned must be non-negative");
|
||||
throw new ArgumentOutOfRangeException(nameof(v), "unsigned must be non-negative");
|
||||
WriteVarU((ulong)v, stream);
|
||||
}
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
public void SetAudioParameters(int sampleRate, int channels, int bits)
|
||||
{
|
||||
if (bits != 16)
|
||||
throw new ArgumentOutOfRangeException("bits", "Audio depth must be 16 bit!");
|
||||
throw new ArgumentOutOfRangeException(nameof(bits), "Audio depth must be 16 bit!");
|
||||
this.sampleRate = sampleRate;
|
||||
this.channels = channels;
|
||||
}
|
||||
|
|
|
@ -51,10 +51,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
: base(false)
|
||||
{
|
||||
if (maxColors > 255)
|
||||
throw new ArgumentOutOfRangeException("maxColors", maxColors, "The number of colors should be less than 256");
|
||||
throw new ArgumentOutOfRangeException(nameof(maxColors), maxColors, "The number of colors should be less than 256");
|
||||
|
||||
if ((maxColorBits < 1) |(maxColorBits > 8))
|
||||
throw new ArgumentOutOfRangeException("maxColorBits", maxColorBits, "This should be between 1 and 8");
|
||||
throw new ArgumentOutOfRangeException(nameof(maxColorBits), maxColorBits, "This should be between 1 and 8");
|
||||
|
||||
_octree = new Octree(maxColorBits);
|
||||
_maxColors = maxColors;
|
||||
|
|
|
@ -107,7 +107,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
/// </summary>
|
||||
static List<string> StringChunkSplit(string s, int len)
|
||||
{
|
||||
if (len == 0) throw new ArgumentException("Invalid len", "len");
|
||||
if (len == 0) throw new ArgumentException("Invalid len", nameof(len));
|
||||
|
||||
int numChunks = (s.Length + len - 1) / len;
|
||||
List<string> output = new List<string>(numChunks);
|
||||
|
|
|
@ -136,7 +136,7 @@ namespace BizHawk.Client.EmuHawk.CustomControls
|
|||
public void SetButtons(string[] names, DialogResult[] results, int def)
|
||||
{
|
||||
if (names == null)
|
||||
throw new ArgumentNullException("names", "Button Text is null");
|
||||
throw new ArgumentNullException(nameof(names), "Button Text is null");
|
||||
|
||||
int count = names.Length;
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace BizHawk.Emulation.Common
|
|||
{
|
||||
if (provider == null)
|
||||
{
|
||||
throw new ArgumentNullException("provider");
|
||||
throw new ArgumentNullException(nameof(provider));
|
||||
}
|
||||
|
||||
Services[typeof(T)] = provider;
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace BizHawk.Emulation.Common
|
|||
if ((ulong)addr < (ulong)Size)
|
||||
return ((byte*)Data)[addr];
|
||||
else
|
||||
throw new ArgumentOutOfRangeException("addr");
|
||||
throw new ArgumentOutOfRangeException(nameof(addr));
|
||||
}
|
||||
|
||||
public override void PokeByte(long addr, byte val)
|
||||
|
@ -79,7 +79,7 @@ namespace BizHawk.Emulation.Common
|
|||
if ((ulong)addr < (ulong)Size)
|
||||
((byte*)Data)[addr] = val;
|
||||
else
|
||||
throw new ArgumentOutOfRangeException("addr");
|
||||
throw new ArgumentOutOfRangeException(nameof(addr));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ namespace BizHawk.Emulation.Common
|
|||
if ((ulong)addr < (ulong)Size)
|
||||
return ((byte*)Data)[addr ^ 1];
|
||||
else
|
||||
throw new ArgumentOutOfRangeException("addr");
|
||||
throw new ArgumentOutOfRangeException(nameof(addr));
|
||||
}
|
||||
|
||||
public override void PokeByte(long addr, byte val)
|
||||
|
@ -118,7 +118,7 @@ namespace BizHawk.Emulation.Common
|
|||
if ((ulong)addr < (ulong)Size)
|
||||
((byte*)Data)[addr ^ 1] = val;
|
||||
else
|
||||
throw new ArgumentOutOfRangeException("addr");
|
||||
throw new ArgumentOutOfRangeException(nameof(addr));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace BizHawk.Emulation.Common
|
|||
}
|
||||
else if (bitSize > 64 || bitSize == 0)
|
||||
{
|
||||
throw new System.ArgumentOutOfRangeException("bitSize", "BitSize must be in 1..64");
|
||||
throw new System.ArgumentOutOfRangeException(nameof(bitSize), "BitSize must be in 1..64");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
{
|
||||
if (scanline < 0 || scanline > 227)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("scanline", "Scanline must be in [0, 227]!");
|
||||
throw new ArgumentOutOfRangeException(nameof(scanline), "Scanline must be in [0, 227]!");
|
||||
}
|
||||
|
||||
if (callback == null)
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
{
|
||||
if (scanline < 0 || scanline > 227)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("scanline", "Scanline must be in [0, 227]!");
|
||||
throw new ArgumentOutOfRangeException(nameof(scanline), "Scanline must be in [0, 227]!");
|
||||
}
|
||||
if (callback == null)
|
||||
{
|
||||
|
|
|
@ -523,7 +523,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("line", "line must be in [0, 153]");
|
||||
throw new ArgumentOutOfRangeException(nameof(line), "line must be in [0, 153]");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
public static bool ValidString(string s, out string why)
|
||||
{
|
||||
if (s == null)
|
||||
throw new ArgumentNullException("s");
|
||||
throw new ArgumentNullException(nameof(s));
|
||||
if (!s.Length.In(MIN_DIGITS, MAX_DIGITS))
|
||||
{
|
||||
why = string.Format("String must be {0} or {1} digits long!", MIN_DIGITS, MAX_DIGITS);
|
||||
|
|
|
@ -215,10 +215,10 @@ namespace BizHawk.Emulation.Cores
|
|||
public Stream GetStream(ulong start, ulong length, bool writer)
|
||||
{
|
||||
if (start < Start)
|
||||
throw new ArgumentOutOfRangeException("start");
|
||||
throw new ArgumentOutOfRangeException(nameof(start));
|
||||
|
||||
if (start + length > End)
|
||||
throw new ArgumentOutOfRangeException("length");
|
||||
throw new ArgumentOutOfRangeException(nameof(length));
|
||||
|
||||
return new MemoryViewStream(!writer, writer, (long)start, (long)length, this);
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ namespace BizHawk.Emulation.Cores
|
|||
case Protection.R: p = Kernel32.MemoryProtection.READONLY; break;
|
||||
case Protection.RW: p = Kernel32.MemoryProtection.READWRITE; break;
|
||||
case Protection.RX: p = Kernel32.MemoryProtection.EXECUTE_READ; break;
|
||||
default: throw new ArgumentOutOfRangeException("prot");
|
||||
default: throw new ArgumentOutOfRangeException(nameof(prot));
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.GdiPlus
|
|||
public void SetCornerColors(OpenTK.Graphics.Color4[] colors)
|
||||
{
|
||||
Flush(); //dont really need to flush with current implementation. we might as well roll modulate color into it too.
|
||||
if (colors.Length != 4) throw new ArgumentException("array must be size 4", "colors");
|
||||
if (colors.Length != 4) throw new ArgumentException("array must be size 4", nameof(colors));
|
||||
for (int i = 0; i < 4; i++)
|
||||
CornerColors[i] = colors[i];
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace Cyotek.Drawing.BitmapFont
|
|||
string[] lines;
|
||||
|
||||
if (string.IsNullOrEmpty(fileName))
|
||||
throw new ArgumentNullException("fileName", "File name not specified");
|
||||
throw new ArgumentNullException(nameof(fileName), "File name not specified");
|
||||
else if (!File.Exists(fileName))
|
||||
throw new FileNotFoundException(string.Format("Cannot find file '{0}'", fileName), fileName);
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
public void SetCornerColors(OpenTK.Graphics.Color4[] colors)
|
||||
{
|
||||
Flush(); //dont really need to flush with current implementation. we might as well roll modulate color into it too.
|
||||
if (colors.Length != 4) throw new ArgumentException("array must be size 4", "colors");
|
||||
if (colors.Length != 4) throw new ArgumentException("array must be size 4", nameof(colors));
|
||||
for (int i = 0; i < 4; i++)
|
||||
CornerColors[i] = colors[i];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue