From cf493d47f0d9917ccd2d3f18e82cde0e275b304b Mon Sep 17 00:00:00 2001 From: Serge Camille Date: Sun, 6 Sep 2020 15:04:20 +0200 Subject: [PATCH] Apply some of the hints that the compiler is giving. --- S7.Net/PlcAsynchronous.cs | 4 ++-- S7.Net/PlcSynchronous.cs | 5 ++--- S7.Net/Protocol/S7WriteMultiple.cs | 1 - S7.Net/Protocol/Serialization.cs | 4 ++-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/S7.Net/PlcAsynchronous.cs b/S7.Net/PlcAsynchronous.cs index c6d7388..2f481e4 100644 --- a/S7.Net/PlcAsynchronous.cs +++ b/S7.Net/PlcAsynchronous.cs @@ -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) { diff --git a/S7.Net/PlcSynchronous.cs b/S7.Net/PlcSynchronous.cs index bf0a1a3..8cf5f89 100644 --- a/S7.Net/PlcSynchronous.cs +++ b/S7.Net/PlcSynchronous.cs @@ -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 diff --git a/S7.Net/Protocol/S7WriteMultiple.cs b/S7.Net/Protocol/S7WriteMultiple.cs index 2738a34..853e1e5 100644 --- a/S7.Net/Protocol/S7WriteMultiple.cs +++ b/S7.Net/Protocol/S7WriteMultiple.cs @@ -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; diff --git a/S7.Net/Protocol/Serialization.cs b/S7.Net/Protocol/Serialization.cs index 5e4c98e..3ecee55 100644 --- a/S7.Net/Protocol/Serialization.cs +++ b/S7.Net/Protocol/Serialization.cs @@ -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; }