Fix or ignore build warnings

This commit is contained in:
Peter Butzhammer
2024-04-25 10:19:17 +02:00
parent 1672ca906d
commit 87d69fb614
6 changed files with 23 additions and 14 deletions

View File

@@ -1,5 +1,7 @@
#nullable enable
using System.Diagnostics.CodeAnalysis;
namespace Sharp7.Rx;
public static class S7ErrorCodes
@@ -7,12 +9,12 @@ public static class S7ErrorCodes
/// <summary>
/// This list is not exhaustive and should be considered work in progress.
/// </summary>
private static readonly HashSet<int> notDisconnectedErrorCodes = new HashSet<int>
{
private static readonly HashSet<int> notDisconnectedErrorCodes =
[
0x000000, // OK
0xC00000, // CPU: Item not available
0x900000, // CPU: Address out of range
};
0x900000 // CPU: Address out of range
];
private static readonly IReadOnlyDictionary<int, string> additionalErrorTexts = new Dictionary<int, string>
{
@@ -31,11 +33,9 @@ public static class S7ErrorCodes
/// Other error codes indicate a user error, like reading from an unavailable DB or exceeding
/// the DBs range. In this case the driver should not consider the connection to be lost.
/// </summary>
public static bool AssumeConnectionLost(int errorCode)
{
return !notDisconnectedErrorCodes.Contains(errorCode);
}
public static bool AssumeConnectionLost(int errorCode) =>
!notDisconnectedErrorCodes.Contains(errorCode);
public static string? GetAdditionalErrorText(int errorCode) =>
additionalErrorTexts.TryGetValue(errorCode, out var text) ? text : null;
additionalErrorTexts.GetValueOrDefault(errorCode);
}