Merge pull request #309 from scamille/fb-varHints

Apply some of the hints that the compiler is giving.
This commit is contained in:
Michael Croes
2020-09-09 20:42:33 +02:00
committed by GitHub
4 changed files with 6 additions and 8 deletions

View File

@@ -324,9 +324,9 @@ namespace S7.Net
if (bitAdr != -1)
{
//Must be writing a bit value as bitAdr is specified
if (value is bool)
if (value is bool boolean)
{
await WriteBitAsync(dataType, db, startByteAdr, bitAdr, (bool) value);
await WriteBitAsync(dataType, db, startByteAdr, bitAdr, boolean);
}
else if (value is int intValue)
{

View File

@@ -289,9 +289,9 @@ namespace S7.Net
if (bitAdr != -1)
{
//Must be writing a bit value as bitAdr is specified
if (value is bool)
if (value is bool boolean)
{
WriteBit(dataType, db, startByteAdr, bitAdr, (bool) value);
WriteBit(dataType, db, startByteAdr, bitAdr, boolean);
}
else if (value is int intValue)
{
@@ -442,7 +442,6 @@ namespace S7.Net
private byte[] BuildWriteBitPackage(DataType dataType, int db, int startByteAdr, bool bitValue, int bitAdr)
{
var stream = GetStreamIfAvailable();
var value = new[] { bitValue ? (byte)1 : (byte)0 };
int varCount = 1;
// first create the header

View File

@@ -17,7 +17,6 @@ namespace S7.Net.Protocol
(ushort) (2 + paramSize));
var paramOffset = Header.Template.Length;
var dataOffset = paramOffset + paramSize;
var data = new ByteArray();
var itemCount = 0;

View File

@@ -75,9 +75,9 @@ namespace S7.Net.Protocol
{
var start = startByte * 8 + bitNumber;
buffer[index + 2] = (byte)start;
start = start >> 8;
start >>= 8;
buffer[index + 1] = (byte)start;
start = start >> 8;
start >>= 8;
buffer[index] = (byte)start;
}