Enable SA1130 and fix noncompliance

"Use lambda syntax"
This commit is contained in:
YoshiRulz 2020-06-21 09:32:08 +10:00 committed by zeromus
parent 0a3cb5f23f
commit 0021cfee70
14 changed files with 28 additions and 56 deletions

View File

@ -351,9 +351,6 @@
<!-- Do not use default value type constructor -->
<Rule Id="SA1129" Action="Hidden" />
<!-- Use lambda syntax -->
<Rule Id="SA1130" Action="Hidden" />
<!-- Use readable conditions -->
<Rule Id="SA1131" Action="Hidden" />

View File

@ -17,7 +17,7 @@ namespace BizHawk.Client.Common
LuaFile = luaFile;
Guid = Guid.NewGuid();
Callback = delegate
Callback = () =>
{
try
{
@ -29,10 +29,7 @@ namespace BizHawk.Client.Common
}
};
MemCallback = delegate
{
Callback();
};
MemCallback = (address, value, flags) => Callback();
}
public Guid Guid { get; }

View File

@ -2652,7 +2652,7 @@ namespace BizHawk.Client.EmuHawk
private void FdsInsertDiskMenuAdd(string name, string button, string msg)
{
FDSControlsMenuItem.DropDownItems.Add(name, null, delegate
FDSControlsMenuItem.DropDownItems.Add(name, null, (sender, e) =>
{
if (Emulator.ControllerDefinition.BoolButtons.Contains(button)
&& !MovieSession.Movie.IsPlaying())

View File

@ -152,10 +152,7 @@ namespace BizHawk.Client.EmuHawk
var tempBox = box;
var tempPath = path.Type;
var tempSystem = path.System;
btn.Click += delegate
{
BrowseFolder(tempBox, tempPath, tempSystem);
};
btn.Click += (sender, args) => BrowseFolder(tempBox, tempPath, tempSystem);
int infoPadding = UIHelper.ScaleX(0);
if (t.Name.Contains("Global") && path.Type == "Firmware")
@ -172,7 +169,7 @@ namespace BizHawk.Client.EmuHawk
Anchor = AnchorStyles.Top | AnchorStyles.Right
};
firmwareButton.Click += delegate
firmwareButton.Click += (sender, e) =>
{
if (Owner is FirmwaresConfig)
{

View File

@ -39,7 +39,7 @@ namespace BizHawk.Client.EmuHawk
DirectoryMonitor.Created += DirectoryMonitor_Created;
DirectoryMonitor.EnableRaisingEvents = true;
ClientApi.RomLoaded += delegate { BuildToolStrip(); };
ClientApi.RomLoaded += (sender, e) => BuildToolStrip();
BuildToolStrip();
}

View File

@ -671,7 +671,7 @@ namespace BizHawk.Client.EmuHawk
{
Form form = (Form)f;
// close becomes hide
form.FormClosing += delegate(object sender, FormClosingEventArgs e)
form.FormClosing += (sender, e) =>
{
e.Cancel = true;
listBoxWidgets.Items.Add(sender);

View File

@ -527,10 +527,7 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME
{
return _peek(addr, firstOffset, size);
},
read == "rom" ? (Action<long, byte>)null : delegate (long addr, byte val)
{
_poke(addr, val, firstOffset, size);
},
read == "rom" ? (Action<long, byte>) null : (addr, val) => _poke(addr, val, firstOffset, size),
dataWidth));
}
}

View File

@ -318,7 +318,7 @@ namespace BizHawk.Emulation.Cores.Components.H6280
public Func<int, byte> ReadMemory21;
public Action<int, byte> WriteMemory21;
public Action<int, byte> WriteVDC;
public Action<int> ThinkAction = delegate { };
public Action<int> ThinkAction = i => {};
public IMemoryCallbackSystem MemoryCallbacks;

View File

@ -88,7 +88,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
// special combined ram memory domain
_cwram.Peek =
delegate (long addr)
addr =>
{
if (addr < 0 || addr >= (256 + 32) * 1024)
{
@ -103,7 +103,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
return PeekWRAM(s.wram, addr);
};
_cwram.Poke =
delegate (long addr, byte val)
(addr, val) =>
{
if (addr < 0 || addr >= (256 + 32) * 1024)
{

View File

@ -437,10 +437,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
}
else if (line >= 0 && line <= 153)
{
scanlinecb = delegate
{
callback(LibGambatte.gambatte_cpuread(GambatteState, 0xff40));
};
scanlinecb = () => callback(LibGambatte.gambatte_cpuread(GambatteState, 0xff40));
LibGambatte.gambatte_setscanlinecallback(GambatteState, scanlinecb, line);
}
else

View File

@ -113,15 +113,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
{
var mcs = MemoryCallbacks;
api.BreakpointHit += delegate(uint address, mupen64plusApi.BreakType type)
api.BreakpointHit += (address, type) => api.OnBreakpoint(new mupen64plusApi.BreakParams
{
api.OnBreakpoint(new mupen64plusApi.BreakParams
{
_type = type,
_addr = address,
_mcs = mcs
});
};
_type = type,
_addr = address,
_mcs = mcs
});
}
private void AddBreakpoint(IMemoryCallback callback)

View File

@ -30,7 +30,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
if (swizzled)
{
peekByte = delegate(long addr)
peekByte = addr =>
{
if (addr < 0 || addr >= size)
{
@ -39,7 +39,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
return Marshal.ReadByte(memPtr, (int)(addr ^ 3));
};
pokeByte = delegate(long addr, byte val)
pokeByte = (addr, val) =>
{
if (addr < 0 || addr >= size)
{
@ -51,7 +51,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
}
else
{
peekByte = delegate(long addr)
peekByte = addr =>
{
if (addr < 0 || addr >= size)
{
@ -60,7 +60,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
return Marshal.ReadByte(memPtr, (int)(addr));
};
pokeByte = delegate(long addr, byte val)
pokeByte = (addr, val) =>
{
if (addr < 0 || addr >= size)
{
@ -117,18 +117,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
}
Func<long, byte> peekByte;
Action<long, byte> pokeByte;
peekByte = delegate(long addr)
{
return api.m64p_read_memory_8((uint)addr);
};
pokeByte = delegate(long addr, byte val)
{
api.m64p_write_memory_8((uint)addr, val);
};
Func<long, byte> peekByte = addr => api.m64p_read_memory_8((uint) addr);
Action<long, byte> pokeByte = (addr, val) => api.m64p_write_memory_8((uint) addr, val);
_memoryDomains.Add(new MemoryDomainDelegate
(

View File

@ -109,7 +109,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
string name = $"P{player} {button.Name}";
ControllerDef.BoolButtons.Add(name);
var buttonFlag = button.Key;
_converts.Add(delegate
_converts.Add(() =>
{
if (_source.IsPressed(name))
{
@ -124,7 +124,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
ControllerDef.AddXYPair($"P{player} Mouse {{0}}", AxisPairOrientation.RightAndUp, -256, 0, 255); //TODO verify direction against hardware
var nx = $"P{player} Mouse X";
var ny = $"P{player} Mouse Y";
_converts.Add(delegate
_converts.Add(() =>
{
_target.analog[(2 * idx) + 0] = (short)_source.AxisValue(nx);
_target.analog[(2 * idx) + 1] = (short)_source.AxisValue(ny);
@ -137,7 +137,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
ControllerDef.AddXYPair($"P{player} Lightgun {{0}}", AxisPairOrientation.RightAndUp, 0, 5000, 10000); //TODO verify direction against hardware
var nx = $"P{player} Lightgun X";
var ny = $"P{player} Lightgun Y";
_converts.Add(delegate
_converts.Add(() =>
{
_target.analog[(2 * idx) + 0] = (short)(_source.AxisValue(nx) / 10000.0f * (ScreenWidth - 1));
_target.analog[(2 * idx) + 1] = (short)(_source.AxisValue(ny) / 10000.0f * (ScreenHeight - 1));
@ -150,7 +150,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
var nx = $"P{player} Stick X";
var ny = $"P{player} Stick Y";
var nz = $"P{player} Stick Z";
_converts.Add(delegate
_converts.Add(() =>
{
_target.analog[(2 * idx) + 0] = (short)_source.AxisValue(nx);
_target.analog[(2 * idx) + 1] = (short)_source.AxisValue(ny);

View File

@ -21,7 +21,7 @@ namespace BizHawk.Emulation.Cores.Components
public const byte PlaybackMode_LoopOnCompletion = 2;
public const byte PlaybackMode_CallbackOnCompletion = 3;
public Action CallbackAction = delegate { };
public Action CallbackAction = () => {};
public Disc Disc;
public DiscSectorReader DiscSectorReader;