From cfc1f948bf5cf7b040a96cc56afadee7dc632156 Mon Sep 17 00:00:00 2001
From: Phillip Sawyer <30532122+phillipsawyer@users.noreply.github.com>
Date: Tue, 4 Apr 2023 21:30:53 -0600
Subject: [PATCH] Added [NotNullWhen(true)]
---
.../NetDeamon.HassModel/Entities/EntityExtensions.cs | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/HassModel/NetDeamon.HassModel/Entities/EntityExtensions.cs b/src/HassModel/NetDeamon.HassModel/Entities/EntityExtensions.cs
index b612ae7c4..9f91bf18d 100644
--- a/src/HassModel/NetDeamon.HassModel/Entities/EntityExtensions.cs
+++ b/src/HassModel/NetDeamon.HassModel/Entities/EntityExtensions.cs
@@ -10,28 +10,28 @@ public static class EntityExtensions
///
/// The state to check
/// true if the state equals "on", otherwise false
- public static bool IsOn(this EntityState? entityState) => string.Equals(entityState?.State, "on", StringComparison.OrdinalIgnoreCase);
+ public static bool IsOn([NotNullWhen(true)] this EntityState? entityState) => string.Equals(entityState?.State, "on", StringComparison.OrdinalIgnoreCase);
///
/// Checks if an EntityState has the state "off"
///
/// The state to check
/// true if the state equals "off", otherwise false
- public static bool IsOff(this EntityState? entityState) => string.Equals(entityState?.State, "off", StringComparison.OrdinalIgnoreCase);
+ public static bool IsOff([NotNullWhen(true)] this EntityState? entityState) => string.Equals(entityState?.State, "off", StringComparison.OrdinalIgnoreCase);
///
/// Checks if an Entity has the state "on"
///
/// The state to check
/// true if the state equals "on", otherwise false
- public static bool IsOn(this Entity? entity) => entity?.EntityState?.IsOn() ?? false;
+ public static bool IsOn([NotNullWhen(true)] this Entity? entity) => entity?.EntityState?.IsOn() ?? false;
///
/// Checks if an Entity has the state "off"
///
/// The state to check
/// true if the state equals "off", otherwise false
- public static bool IsOff(this Entity? entity) => entity?.EntityState?.IsOff() ?? false;
+ public static bool IsOff([NotNullWhen(true)] this Entity? entity) => entity?.EntityState?.IsOff() ?? false;
/// Gets a NumericEntity from a given Entity
public static NumericEntity AsNumeric(this Entity entity) => new(entity);
@@ -56,4 +56,4 @@ public static NumericEntity WithAttributesAs(this Nume
internal static IObservable StateChangesOnly(this IObservable changes) where T : StateChange
=> changes.Where(c => c.New?.State != c.Old?.State);
-}
\ No newline at end of file
+}