mirror of
https://github.com/S7NetPlus/s7netplus.git
synced 2026-02-17 14:28:25 +08:00
Add nullable support throughout the whole library.
This requires reference types that can be null to be annotated by a ? operator, similar to value types. This gives the advantage that the compiler can warn against any null dereference exceptions, of which this commits elimits a few. To make the underlying protocol implementation not any more complicated and to eliminate existing problems, and not that precise error reporting, I replaced some return null statements with explicit Exceptions. This lead to the assumption that those core protocoll functions always return non-null objects if they do not throw, making the PLC code simpler. Adjust some NotConnected tests to look for explicit PlcException instead of NullReferenceException.
This commit is contained in:
@@ -82,7 +82,7 @@ namespace S7.Net
|
||||
/// <param name="varCount"></param>
|
||||
/// <param name="bitAdr"></param>
|
||||
/// <returns></returns>
|
||||
private object ParseBytes(VarType varType, byte[] bytes, int varCount, byte bitAdr = 0)
|
||||
private object? ParseBytes(VarType varType, byte[] bytes, int varCount, byte bitAdr = 0)
|
||||
{
|
||||
if (bytes == null || bytes.Length == 0)
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user