Correct some stuff spotted by the .net analysis tools (where I agree with them!)

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon
2019-02-03 10:23:41 +00:00
parent 0564ee3d86
commit 0ca57d8641
8 changed files with 59 additions and 62 deletions
+6 -15
View File
@@ -4,22 +4,13 @@
{
protected Chip() { }
public static void ClearFlag(ref byte f, byte flag) => f &= (byte)~flag;
public static void SetFlag(ref byte f, byte flag) => f |= flag;
public static byte SetFlag(byte input, byte flag) => (byte)(input | flag);
public static byte SetFlag(byte input, byte flag, int condition) => SetFlag(input, flag, condition != 0);
public static byte SetFlag(byte input, byte flag, bool condition) => condition ? SetFlag(input, flag) : ClearFlag(input, flag);
public static void SetFlag(ref byte f, byte flag, int condition) => SetFlag(ref f, flag, condition != 0);
public static void SetFlag(ref byte f, byte flag, bool condition)
{
if (condition)
SetFlag(ref f, flag);
else
ClearFlag(ref f, flag);
}
public static void ClearFlag(ref byte f, byte flag, int condition) => ClearFlag(ref f, flag, condition != 0);
public static void ClearFlag(ref byte f, byte flag, bool condition) => SetFlag(ref f, flag, !condition);
public static byte ClearFlag(byte input, byte flag) => (byte)(input & (byte)~flag);
public static byte ClearFlag(byte input, byte flag, int condition) => ClearFlag(input, flag, condition != 0);
public static byte ClearFlag(byte input, byte flag, bool condition) => SetFlag(input, flag, !condition);
public static byte HighByte(int value) => (byte)(value >> 8);
public static byte HighByte(ushort value) => HighByte((int)value);
+1
View File
@@ -32,6 +32,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>latest</LangVersion>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>